agentworkshop 0.7.62 → 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.
Files changed (31) hide show
  1. package/.AgentWorkShop/prompts/host-tools.json +2488 -2526
  2. package/.output/.AgentWorkShop/prompts/host-tools.json +2488 -2526
  3. package/.output/nitro.json +1 -1
  4. package/.output/public/_nuxt/builds/latest.json +1 -1
  5. package/.output/public/_nuxt/builds/meta/1809e625-ff1d-4fd5-9ad2-28cea81f06ab.json +1 -0
  6. package/.output/server/chunks/_/nitro.mjs +924 -1022
  7. package/.output/server/chunks/_/nitro.mjs.map +1 -1
  8. package/.output/server/package.json +1 -1
  9. package/README-zh.md +946 -945
  10. package/README.md +970 -969
  11. package/config.yml +180 -180
  12. package/docs/cli.en.md +447 -447
  13. package/docs/cli.md +412 -412
  14. package/docs/full-test-plan.md +1 -1
  15. package/docs/plugins.en.md +1 -1
  16. package/docs/plugins.md +1 -1
  17. package/docs/sdk.en.md +1 -1
  18. package/docs/sdk.md +1 -1
  19. package/package.json +181 -181
  20. package/scripts/e2e-plc-plugin-closedloop.mjs +1 -1
  21. package/server/plugins-builtin/diag-bridge/host/diagnosis.mjs +13 -3
  22. package/server/plugins-builtin/diag-bridge/host/intents.mjs +62 -0
  23. package/server/plugins-builtin/diag-bridge/host/plugin.mjs +28 -14
  24. package/server/plugins-builtin/diag-bridge/host/sweep.mjs +26 -18
  25. package/server/services/workshop/agents/host-tool-bridge/dispatch.ts +241 -243
  26. package/server/services/workshop/agents/host-tool-bridge/tools/industrial.ts +96 -98
  27. package/server/services/workshop/agents/industrial/dcw-tools.ts +210 -255
  28. package/server/services/workshop/agents/industrial/index.ts +32 -32
  29. package/server/services/workshop/agents/industrial/param-tools.ts +0 -40
  30. package/server/services/workshop/prompts/loader.ts +15 -2
  31. package/.output/public/_nuxt/builds/meta/603a62a6-71d7-4d9c-bb1d-e8264a58798e.json +0 -1
@@ -1,6 +1,6 @@
1
1
  # AgentWorkShop 全功能测试流程 Plan
2
2
 
3
- > 版本无关的常备测试手册(撰写时基线 v0.7.48)。用途:后续直接指令 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.58**. `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.58**。`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.58) —
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.58)
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,181 +1,181 @@
1
- {
2
- "name": "agentworkshop",
3
- "version": "0.7.62",
4
- "type": "module",
5
- "description": "AgentWorkShop 软件开发系统 - 基于 Nuxt 4 的配置驱动运行范式",
6
- "license": "Apache-2.0",
7
- "exports": {
8
- ".": {
9
- "types": "./sdk/index.d.mts",
10
- "default": "./sdk/index.mjs"
11
- },
12
- "./sdk": {
13
- "types": "./sdk/index.d.mts",
14
- "default": "./sdk/index.mjs"
15
- },
16
- "./sdk/client": {
17
- "types": "./sdk/client.d.mts",
18
- "default": "./sdk/client.mjs"
19
- },
20
- "./package.json": "./package.json"
21
- },
22
- "bin": {
23
- "aw": "bin/aw.mjs",
24
- "agentworkshop": "bin/aw.mjs"
25
- },
26
- "files": [
27
- ".output",
28
- "bin",
29
- "cli",
30
- "sdk",
31
- "app",
32
- "server",
33
- "shared",
34
- "i18n",
35
- "public",
36
- "scripts",
37
- ".AgentWorkShop/prompts",
38
- "server/plugins-builtin",
39
- "mcp",
40
- "config.yml",
41
- "nuxt.config.ts",
42
- "tsconfig.json",
43
- "uno.config.ts",
44
- "docker-compose.yml",
45
- ".env.example",
46
- "README-zh.md",
47
- "docs/cli.md",
48
- "docs/cli.en.md",
49
- "docs/plugins.md",
50
- "docs/plugins.en.md",
51
- "docs/sdk.md",
52
- "docs/sdk.en.md",
53
- "docs/aml.md",
54
- "docs/mcp.md",
55
- "docs/mcp.en.md",
56
- "docs/tui.md",
57
- "docs/full-test-plan.md",
58
- "docs/multi-harness-architecture.md",
59
- "tui"
60
- ],
61
- "packageManager": "pnpm@11.9.0",
62
- "engines": {
63
- "node": ">=23.4.0"
64
- },
65
- "scripts": {
66
- "dev": "node bin/aw.mjs dev",
67
- "build": "node bin/aw.mjs build",
68
- "start": "node bin/aw.mjs start",
69
- "generate": "nuxt generate",
70
- "preview": "node bin/aw.mjs start",
71
- "cli": "node bin/aw.mjs",
72
- "tui": "node tui/aw-tui.mjs",
73
- "postinstall": "node scripts/home-bootstrap.mjs",
74
- "prepublishOnly": "node bin/aw.mjs build",
75
- "lint": "eslint .",
76
- "lint:fix": "eslint . --fix",
77
- "typecheck": "node scripts/typecheck.mjs",
78
- "docs:check": "node scripts/check-docs-sync.mjs",
79
- "docs:dev": "cd docs/site && npx vitepress dev",
80
- "docs:build": "cd docs/site && npx vitepress build",
81
- "test:plugin-lifecycle": "node scripts/test-plugin-lifecycle.mjs",
82
- "test:sdk-surface": "node scripts/test-sdk-surface.mjs",
83
- "test:twin-provider": "tsx --test tests/aml-twin-provider-registry.test.ts",
84
- "test:unit": "tsx --tsconfig .nuxt/tsconfig.server.json --test --test-force-exit tests/*.test.ts",
85
- "prepare": "husky",
86
- "test:api-live": "node scripts/api-live-e2e.mjs",
87
- "test:mcp": "tsx --tsconfig .nuxt/tsconfig.server.json --test --test-force-exit tests/aw-mcp-server.test.ts",
88
- "test:skills": "node scripts/test-aw-skills.mjs",
89
- "test:mcp-live": "node scripts/_audit/aw-mcp-live-e2e.mjs",
90
- "test:skills-guided": "node scripts/_audit/skills-guided-e2e.mjs",
91
- "ui:seed": "node scripts/ui/seed-demo.mjs",
92
- "ui:shots": "node scripts/ui/shots.mjs",
93
- "ui:audit": "node scripts/ui/audit-layout.mjs",
94
- "ui:verify": "node scripts/ui/verify-responsive.mjs",
95
- "ui:verify-nav": "node scripts/ui/verify-nav.mjs",
96
- "readme:lint": "node scripts/ui/md-lint.mjs README.md README-zh.md",
97
- "readme:assets": "node scripts/ui/readme-assets.mjs",
98
- "game:verify": "node scripts/verify-game.mjs",
99
- "game:build-assets": "node scripts/build-player-sheet.mjs",
100
- "game:build-wuwa": "node scripts/build-wuwa-assets.mjs",
101
- "game:build-models": "node scripts/build-character-models.mjs",
102
- "game:build-world": "node scripts/build-world-map.mjs",
103
- "game:build-model3d": "node scripts/build-model-3d.mjs"
104
- },
105
- "lint-staged": {
106
- "*.{js,mjs,cjs,ts,vue}": "eslint --fix"
107
- },
108
- "dependencies": {
109
- "@ant-design-vue/nuxt": "^1.4.6",
110
- "@ant-design/icons-vue": "^7.0.1",
111
- "@anthropic-ai/claude-agent-sdk": "0.3.266",
112
- "@earendil-works/pi-tui": "^0.84.4",
113
- "@fontsource-variable/fraunces": "^5.3.0",
114
- "@fontsource-variable/geist": "^5.3.0",
115
- "@fontsource-variable/geist-mono": "^5.3.0",
116
- "@fontsource-variable/inter": "^5.3.0",
117
- "@fontsource/eb-garamond": "^5.3.0",
118
- "@fontsource/ibm-plex-mono": "^5.3.0",
119
- "@iconify-json/tabler": "^1.2.0",
120
- "@modelcontextprotocol/sdk": "^1.30.0",
121
- "@nuxtjs/i18n": "^9.0.0",
122
- "@pinia/nuxt": "^0.11.0",
123
- "@unocss/nuxt": "^66.0.0",
124
- "@unocss/preset-attributify": "^66.0.0",
125
- "@unocss/preset-icons": "^66.7.5",
126
- "@unocss/preset-typography": "^66.0.0",
127
- "@vueuse/core": "^13.0.0",
128
- "@vueuse/nuxt": "^13.0.0",
129
- "@xterm/addon-fit": "^0.11.0",
130
- "@xterm/xterm": "^6.0.0",
131
- "ant-design-vue": "^4.2.6",
132
- "axios": "^1.7.9",
133
- "echarts": "^5.6.0",
134
- "h3": "2.0.1-rc.26",
135
- "js-yaml": "^4.1.0",
136
- "minio": "^8.0.7",
137
- "modbus-serial": "^8.0.25",
138
- "mqtt": "^5.15.2",
139
- "node-opcua": "2.178.0",
140
- "nuxt": "^4.0.0",
141
- "nuxt-auth-utils": "^0.5.0",
142
- "pg": "^8.23.0",
143
- "phaser": "^4.0.0",
144
- "pinia": "^3.0.0",
145
- "pinia-plugin-persistedstate": "^4.2.0",
146
- "sqlite-vec": "^0.1.9",
147
- "three": "^0.185.1",
148
- "unocss": "^66.0.0",
149
- "unplugin-icons": "^22.0.0",
150
- "vue": "^3.5.13",
151
- "vue-echarts": "^7.0.3",
152
- "vue-router": "^4.5.0",
153
- "zod": "^3.24.1"
154
- },
155
- "optionalDependencies": {
156
- "onnxruntime-node": "^1.20.1",
157
- "serialport": "^13.0.0"
158
- },
159
- "devDependencies": {
160
- "@commitlint/cli": "^19.6.1",
161
- "@commitlint/config-conventional": "^19.6.0",
162
- "@nuxt/eslint": "^1.0.0",
163
- "@types/js-yaml": "^4.0.9",
164
- "@types/node": "^26.2.0",
165
- "@types/pg": "^8.23.1",
166
- "@types/three": "^0.185.4",
167
- "eslint": "^9.17.0",
168
- "husky": "^9.1.7",
169
- "lint-staged": "^15.3.0",
170
- "pngjs": "^7.0.0",
171
- "puppeteer-core": "^25.5.0",
172
- "tsx": "^4.23.12",
173
- "typescript": "^5.7.3",
174
- "vue-tsc": "^3.3.10"
175
- },
176
- "pnpm": {
177
- "ignoredBuiltDependencies": [
178
- "@serialport/bindings-cpp"
179
- ]
180
- }
181
- }
1
+ {
2
+ "name": "agentworkshop",
3
+ "version": "0.7.64",
4
+ "type": "module",
5
+ "description": "AgentWorkShop 软件开发系统 - 基于 Nuxt 4 的配置驱动运行范式",
6
+ "license": "Apache-2.0",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./sdk/index.d.mts",
10
+ "default": "./sdk/index.mjs"
11
+ },
12
+ "./sdk": {
13
+ "types": "./sdk/index.d.mts",
14
+ "default": "./sdk/index.mjs"
15
+ },
16
+ "./sdk/client": {
17
+ "types": "./sdk/client.d.mts",
18
+ "default": "./sdk/client.mjs"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "bin": {
23
+ "aw": "bin/aw.mjs",
24
+ "agentworkshop": "bin/aw.mjs"
25
+ },
26
+ "files": [
27
+ ".output",
28
+ "bin",
29
+ "cli",
30
+ "sdk",
31
+ "app",
32
+ "server",
33
+ "shared",
34
+ "i18n",
35
+ "public",
36
+ "scripts",
37
+ ".AgentWorkShop/prompts",
38
+ "server/plugins-builtin",
39
+ "mcp",
40
+ "config.yml",
41
+ "nuxt.config.ts",
42
+ "tsconfig.json",
43
+ "uno.config.ts",
44
+ "docker-compose.yml",
45
+ ".env.example",
46
+ "README-zh.md",
47
+ "docs/cli.md",
48
+ "docs/cli.en.md",
49
+ "docs/plugins.md",
50
+ "docs/plugins.en.md",
51
+ "docs/sdk.md",
52
+ "docs/sdk.en.md",
53
+ "docs/aml.md",
54
+ "docs/mcp.md",
55
+ "docs/mcp.en.md",
56
+ "docs/tui.md",
57
+ "docs/full-test-plan.md",
58
+ "docs/multi-harness-architecture.md",
59
+ "tui"
60
+ ],
61
+ "packageManager": "pnpm@11.9.0",
62
+ "engines": {
63
+ "node": ">=23.4.0"
64
+ },
65
+ "scripts": {
66
+ "dev": "node bin/aw.mjs dev",
67
+ "build": "node bin/aw.mjs build",
68
+ "start": "node bin/aw.mjs start",
69
+ "generate": "nuxt generate",
70
+ "preview": "node bin/aw.mjs start",
71
+ "cli": "node bin/aw.mjs",
72
+ "tui": "node tui/aw-tui.mjs",
73
+ "postinstall": "node scripts/home-bootstrap.mjs",
74
+ "prepublishOnly": "node bin/aw.mjs build",
75
+ "lint": "eslint .",
76
+ "lint:fix": "eslint . --fix",
77
+ "typecheck": "node scripts/typecheck.mjs",
78
+ "docs:check": "node scripts/check-docs-sync.mjs",
79
+ "docs:dev": "cd docs/site && npx vitepress dev",
80
+ "docs:build": "cd docs/site && npx vitepress build",
81
+ "test:plugin-lifecycle": "node scripts/test-plugin-lifecycle.mjs",
82
+ "test:sdk-surface": "node scripts/test-sdk-surface.mjs",
83
+ "test:twin-provider": "tsx --test tests/aml-twin-provider-registry.test.ts",
84
+ "test:unit": "tsx --tsconfig .nuxt/tsconfig.server.json --test --test-force-exit tests/*.test.ts",
85
+ "prepare": "husky",
86
+ "test:api-live": "node scripts/api-live-e2e.mjs",
87
+ "test:mcp": "tsx --tsconfig .nuxt/tsconfig.server.json --test --test-force-exit tests/aw-mcp-server.test.ts",
88
+ "test:skills": "node scripts/test-aw-skills.mjs",
89
+ "test:mcp-live": "node scripts/_audit/aw-mcp-live-e2e.mjs",
90
+ "test:skills-guided": "node scripts/_audit/skills-guided-e2e.mjs",
91
+ "ui:seed": "node scripts/ui/seed-demo.mjs",
92
+ "ui:shots": "node scripts/ui/shots.mjs",
93
+ "ui:audit": "node scripts/ui/audit-layout.mjs",
94
+ "ui:verify": "node scripts/ui/verify-responsive.mjs",
95
+ "ui:verify-nav": "node scripts/ui/verify-nav.mjs",
96
+ "readme:lint": "node scripts/ui/md-lint.mjs README.md README-zh.md",
97
+ "readme:assets": "node scripts/ui/readme-assets.mjs",
98
+ "game:verify": "node scripts/verify-game.mjs",
99
+ "game:build-assets": "node scripts/build-player-sheet.mjs",
100
+ "game:build-wuwa": "node scripts/build-wuwa-assets.mjs",
101
+ "game:build-models": "node scripts/build-character-models.mjs",
102
+ "game:build-world": "node scripts/build-world-map.mjs",
103
+ "game:build-model3d": "node scripts/build-model-3d.mjs"
104
+ },
105
+ "lint-staged": {
106
+ "*.{js,mjs,cjs,ts,vue}": "eslint --fix"
107
+ },
108
+ "dependencies": {
109
+ "@ant-design-vue/nuxt": "^1.4.6",
110
+ "@ant-design/icons-vue": "^7.0.1",
111
+ "@anthropic-ai/claude-agent-sdk": "0.3.266",
112
+ "@earendil-works/pi-tui": "^0.84.4",
113
+ "@fontsource-variable/fraunces": "^5.3.0",
114
+ "@fontsource-variable/geist": "^5.3.0",
115
+ "@fontsource-variable/geist-mono": "^5.3.0",
116
+ "@fontsource-variable/inter": "^5.3.0",
117
+ "@fontsource/eb-garamond": "^5.3.0",
118
+ "@fontsource/ibm-plex-mono": "^5.3.0",
119
+ "@iconify-json/tabler": "^1.2.0",
120
+ "@modelcontextprotocol/sdk": "^1.30.0",
121
+ "@nuxtjs/i18n": "^9.0.0",
122
+ "@pinia/nuxt": "^0.11.0",
123
+ "@unocss/nuxt": "^66.0.0",
124
+ "@unocss/preset-attributify": "^66.0.0",
125
+ "@unocss/preset-icons": "^66.7.5",
126
+ "@unocss/preset-typography": "^66.0.0",
127
+ "@vueuse/core": "^13.0.0",
128
+ "@vueuse/nuxt": "^13.0.0",
129
+ "@xterm/addon-fit": "^0.11.0",
130
+ "@xterm/xterm": "^6.0.0",
131
+ "ant-design-vue": "^4.2.6",
132
+ "axios": "^1.7.9",
133
+ "echarts": "^5.6.0",
134
+ "h3": "2.0.1-rc.26",
135
+ "js-yaml": "^4.1.0",
136
+ "minio": "^8.0.7",
137
+ "modbus-serial": "^8.0.25",
138
+ "mqtt": "^5.15.2",
139
+ "node-opcua": "2.178.0",
140
+ "nuxt": "^4.0.0",
141
+ "nuxt-auth-utils": "^0.5.0",
142
+ "pg": "^8.23.0",
143
+ "phaser": "^4.0.0",
144
+ "pinia": "^3.0.0",
145
+ "pinia-plugin-persistedstate": "^4.2.0",
146
+ "sqlite-vec": "^0.1.9",
147
+ "three": "^0.185.1",
148
+ "unocss": "^66.0.0",
149
+ "unplugin-icons": "^22.0.0",
150
+ "vue": "^3.5.13",
151
+ "vue-echarts": "^7.0.3",
152
+ "vue-router": "^4.5.0",
153
+ "zod": "^3.24.1"
154
+ },
155
+ "optionalDependencies": {
156
+ "onnxruntime-node": "^1.20.1",
157
+ "serialport": "^13.0.0"
158
+ },
159
+ "devDependencies": {
160
+ "@commitlint/cli": "^19.6.1",
161
+ "@commitlint/config-conventional": "^19.6.0",
162
+ "@nuxt/eslint": "^1.0.0",
163
+ "@types/js-yaml": "^4.0.9",
164
+ "@types/node": "^26.2.0",
165
+ "@types/pg": "^8.23.1",
166
+ "@types/three": "^0.185.4",
167
+ "eslint": "^9.17.0",
168
+ "husky": "^9.1.7",
169
+ "lint-staged": "^15.3.0",
170
+ "pngjs": "^7.0.0",
171
+ "puppeteer-core": "^25.5.0",
172
+ "tsx": "^4.23.12",
173
+ "typescript": "^5.7.3",
174
+ "vue-tsc": "^3.3.10"
175
+ },
176
+ "pnpm": {
177
+ "ignoredBuiltDependencies": [
178
+ "@serialport/bindings-cpp"
179
+ ]
180
+ }
181
+ }
@@ -535,7 +535,7 @@ console.log('\n── H Harness 集成面 ──')
535
535
  const names = (list?.json?.data?.tools ?? list?.json?.tools ?? []).map(t => t?.name)
536
536
  // rag 侧工具面已收敛为单入口 kb_agent(+kb_agent_status);diag 侧仍是 diag_run/diag_status
537
537
  for (const t of ['kb_agent', 'kb_agent_status', 'diag_run', 'diag_status']) ok(names.includes(t), `omp 执行器工具清单含 ${t}`)
538
- for (const t of ['daq_query', 'dcw_control', 'dcw_judge', 'dcw_read', 'line_context']) ok(names.includes(t), `omp 执行器工业工具含 ${t}`)
538
+ for (const t of ['daq_query', 'dcw_control', 'dcw_judge', 'line_context']) ok(names.includes(t), `omp 执行器工业工具含 ${t}`)
539
539
  const ctxT = await invoke(exec, 'line_context', {}, 60000)
540
540
  ok(!resultText(ctxT).startsWith('工具') || resultText(ctxT).length > 0, 'line_context 可用(工业链路)', resultText(ctxT).slice(0, 60))
541
541
  }
@@ -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 }) {
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,7 +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 q = question || `${line} 产线该时窗数据深度根因诊断`
27
+ // 按情景注入业务提示词:调用方显式 question 优先,否则用意图目录的模板(分析语义在此,执行解耦在 IDD)
28
+ const q = question || defaultQuestionFor(intent, { line, fromMs, toMs })
23
29
  const sceneName = scene || `${line}_diag`
24
30
  // v2.1:统一走 IDD 任务管理面 /api/diagnosis/tasks——接收即返 task_id,
25
31
  // 诊断在 IDD 后台线程执行(内部 start+execute),Channel 绝不等待。
@@ -32,6 +38,9 @@ export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene,
32
38
  sceneName,
33
39
  userQuestion: q,
34
40
  harness: harness || harnessOf(ctx), // 缺省落 claude 引擎会因无 key 失败,必须显式(系统配置 plugins.diag-bridge.harness → kv → omp;diag_run 可按次覆盖)
41
+ ...(intent && intent !== 'deep-diagnosis' ? { analysisIntent: intent } : {}), // 分析意图透传(缺省意图不传,由 IDD 兜底)
42
+ ...(model ? { model: String(model) } : {}), // 引擎模型按次覆盖(合法性由 IDD validateEngineOption 校验,不合法 400)
43
+ ...(permissionMode ? { permissionMode: String(permissionMode) } : {}),
35
44
  enhancement: 'off',
36
45
  reportLanguage: 'zh',
37
46
  maxTurns: maxTurnsOf(ctx), // 修复循环会加转数;150 不够走完全管线
@@ -42,6 +51,7 @@ export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene,
42
51
  if (!runId) return { ok: false, error: `tasks 响应缺少 data.task_id: ${short(started)}` }
43
52
  ctx.kv.set(runKey(runId), {
44
53
  line, fromMs, toMs, question: q, scene: sceneName,
54
+ intent: intent || 'deep-diagnosis',
45
55
  status: 'running', createdAt: Date.now(), source,
46
56
  csvPath: snap.csvPath,
47
57
  files: Array.isArray(dataPaths) ? dataPaths.length : 0,
@@ -49,7 +59,7 @@ export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene,
49
59
  // 归因:发起 Agent 完成后的结果回执靠它寻址(平台通告面 deliver)
50
60
  agentId: agentId || '', channelId: channelId || '',
51
61
  })
52
- 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 }
53
63
  }
54
64
  catch (err) {
55
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
+ }