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.
- package/.AgentWorkShop/prompts/host-tools.json +2488 -2526
- package/.output/.AgentWorkShop/prompts/host-tools.json +2488 -2526
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/1809e625-ff1d-4fd5-9ad2-28cea81f06ab.json +1 -0
- package/.output/server/chunks/_/nitro.mjs +924 -1022
- package/.output/server/chunks/_/nitro.mjs.map +1 -1
- package/.output/server/package.json +1 -1
- package/README-zh.md +946 -945
- package/README.md +970 -969
- package/config.yml +180 -180
- package/docs/cli.en.md +447 -447
- package/docs/cli.md +412 -412
- package/docs/full-test-plan.md +1 -1
- package/docs/plugins.en.md +1 -1
- package/docs/plugins.md +1 -1
- package/docs/sdk.en.md +1 -1
- package/docs/sdk.md +1 -1
- package/package.json +181 -181
- package/scripts/e2e-plc-plugin-closedloop.mjs +1 -1
- package/server/plugins-builtin/diag-bridge/host/diagnosis.mjs +13 -3
- package/server/plugins-builtin/diag-bridge/host/intents.mjs +62 -0
- package/server/plugins-builtin/diag-bridge/host/plugin.mjs +28 -14
- package/server/plugins-builtin/diag-bridge/host/sweep.mjs +26 -18
- package/server/services/workshop/agents/host-tool-bridge/dispatch.ts +241 -243
- package/server/services/workshop/agents/host-tool-bridge/tools/industrial.ts +96 -98
- package/server/services/workshop/agents/industrial/dcw-tools.ts +210 -255
- package/server/services/workshop/agents/industrial/index.ts +32 -32
- package/server/services/workshop/agents/industrial/param-tools.ts +0 -40
- package/server/services/workshop/prompts/loader.ts +15 -2
- package/.output/public/_nuxt/builds/meta/603a62a6-71d7-4d9c-bb1d-e8264a58798e.json +0 -1
|
@@ -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,21 +95,28 @@ export default {
|
|
|
94
95
|
// 工具 ×2
|
|
95
96
|
ctx.omp.registerTool({
|
|
96
97
|
name: 'diag_run',
|
|
97
|
-
label: '
|
|
98
|
-
description: '
|
|
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: '
|
|
108
|
-
|
|
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: '
|
|
117
|
+
harness: { type: 'string', description: '分析引擎按次覆盖(omp/claude/mock;缺省用插件设置)' },
|
|
118
|
+
model: { type: 'string', description: '可选:引擎模型按次覆盖(合法性由 IDD 校验,不合法返回 400 说明)' },
|
|
119
|
+
permission_mode: { type: 'string', description: '可选:引擎权限模式按次覆盖(合法性由 IDD 校验)' },
|
|
112
120
|
},
|
|
113
121
|
required: [],
|
|
114
122
|
},
|
|
@@ -158,6 +166,9 @@ export default {
|
|
|
158
166
|
dataPath: dataPathDirect || undefined,
|
|
159
167
|
dataPaths,
|
|
160
168
|
harness: args.harness ? String(args.harness) : undefined,
|
|
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,
|
|
161
172
|
// 归因(分发层注入的调用方上下文):诊断完成后平台据此把结果回执给发起 Agent
|
|
162
173
|
agentId: agent?.agentId ?? '',
|
|
163
174
|
channelId: agent?.channelId ?? '',
|
|
@@ -190,14 +201,14 @@ export default {
|
|
|
190
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) 查询。` }
|
|
191
202
|
}
|
|
192
203
|
if (status === 'failed' || status === 'stopped') {
|
|
193
|
-
return { text:
|
|
204
|
+
return { text: `分析任务 ${r.runId} 以 ${status} 结束:${st?.result?.error ?? '详见 diag_status'}`, isError: true }
|
|
194
205
|
}
|
|
195
206
|
}
|
|
196
|
-
return { text:
|
|
207
|
+
return { text: `已发起${intentLabel(r.intent)}任务 task_id=${r.runId}(${via})。同步等待 ${timeoutS}s 超时,分析仍在后台运行——完成后平台会自动把结果回执到你的信箱并唤醒你;也可 diag_status(run_id=${r.runId}) 主动查询。注入的分析问题:${r.question}` }
|
|
197
208
|
}
|
|
198
209
|
}
|
|
199
210
|
return {
|
|
200
|
-
text:
|
|
211
|
+
text: `已发起「${intentLabel(r.intent)}」异步分析任务 task_id=${r.runId}(${via})。IDD 在后台以对应 skill 协议执行,Channel 无需等待——可继续其他任务;完成后平台会自动把结果回执到你的信箱并唤醒你(空闲时也可用 diag_status(run_id=${r.runId}) 主动查询;完成后按指引调 kb_agent 把报告入库知识库)。注入的分析问题:${r.question}`,
|
|
201
212
|
}
|
|
202
213
|
}
|
|
203
214
|
catch (err) {
|
|
@@ -208,8 +219,8 @@ export default {
|
|
|
208
219
|
|
|
209
220
|
ctx.omp.registerTool({
|
|
210
221
|
name: 'diag_status',
|
|
211
|
-
label: '
|
|
212
|
-
description: '
|
|
222
|
+
label: '分析任务状态',
|
|
223
|
+
description: '查询后台分析任务进度:传 run_id 看单条实时状态(完成时含评分/结论/总结/报告路径),不传看最近 5 条概要。适用 diag_run 发起的全部意图(深度诊断/产线报告/快速筛查/DOE/经验挖掘/优化战役)。',
|
|
213
224
|
parameters: {
|
|
214
225
|
type: 'object',
|
|
215
226
|
properties: {
|
|
@@ -226,7 +237,7 @@ export default {
|
|
|
226
237
|
.slice(0, 5)
|
|
227
238
|
if (!runs.length) return { text: '暂无诊断记录。用 diag_run 发起一次深度诊断。' }
|
|
228
239
|
const lines = runs.map(({ id: rid, meta }) =>
|
|
229
|
-
`- ${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 ?? ''}`)
|
|
230
241
|
return { text: `最近 ${runs.length} 条诊断:\n${lines.join('\n')}` }
|
|
231
242
|
}
|
|
232
243
|
const meta = ctx.kv.get(runKey(id))
|
|
@@ -243,6 +254,7 @@ export default {
|
|
|
243
254
|
engineStatus: st.status,
|
|
244
255
|
score: st.result.score ?? null,
|
|
245
256
|
judge_verdict: st.result.verdict ?? null,
|
|
257
|
+
summary: st.result.summary ?? '',
|
|
246
258
|
report_path: st.result.report_md_path ?? st.report_path ?? null,
|
|
247
259
|
error_message: st.result.error ?? st.error_message ?? null,
|
|
248
260
|
}
|
|
@@ -261,6 +273,7 @@ export default {
|
|
|
261
273
|
`run_id=${id}`,
|
|
262
274
|
`name=${st?.name ?? meta?.name ?? '?'}`,
|
|
263
275
|
`产线=${meta?.line ?? st?.scene_name ?? '?'}`,
|
|
276
|
+
`意图=${meta?.intent ?? 'deep-diagnosis'}(${intentLabel(meta?.intent ?? 'deep-diagnosis')})`,
|
|
264
277
|
`状态=${status}`,
|
|
265
278
|
`来源=${meta?.source ?? '?'}`,
|
|
266
279
|
]
|
|
@@ -270,10 +283,11 @@ export default {
|
|
|
270
283
|
const reportPath = st?.report_path ?? meta?.reportPath ?? '-'
|
|
271
284
|
parts.push(`评分=${st?.score ?? meta?.score ?? '-'}`)
|
|
272
285
|
parts.push(`结论=${st?.judge_verdict ?? meta?.verdict ?? '-'}`)
|
|
286
|
+
if (st?.summary) parts.push(`总结=${String(st.summary).slice(0, 600)}`)
|
|
273
287
|
parts.push(`report_md_path=${reportPath}`)
|
|
274
288
|
parts.push('')
|
|
275
|
-
parts.push('✅
|
|
276
|
-
parts.push(` mode=async, prompt
|
|
289
|
+
parts.push('✅ 分析完成,报告已就绪。入库知识库请调用 rag-bridge 的 kb_agent 工具:')
|
|
290
|
+
parts.push(` mode=async, prompt=「请把这份分析报告入库到 aw-industrial 知识库:读取文件 ${reportPath} 的全文内容并入库(写盘+索引),完成后报告 doc_path 与分块数。标签:分析、${intentLabel(meta?.intent ?? 'deep-diagnosis')}。」`)
|
|
277
291
|
parts.push('提交后频道无需等待,空闲时用 kb_agent_status(task_id) 查询入库结果。')
|
|
278
292
|
}
|
|
279
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
|
-
|
|
29
|
-
|
|
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:
|
|
37
|
-
verdict:
|
|
38
|
-
|
|
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(
|
|
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 =
|
|
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:
|
|
59
|
+
title: `${intentLabel(intent)}完成(产线 ${meta.line})`,
|
|
53
60
|
summary: [
|
|
54
|
-
|
|
55
|
-
|
|
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)读取该报告文件全文入库(
|
|
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.
|
|
78
|
+
error: st.result?.error ?? null,
|
|
71
79
|
})
|
|
72
|
-
ctx.logger.warn(
|
|
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:
|
|
82
|
-
summary: st.
|
|
83
|
-
? `原因:${st.
|
|
84
|
-
:
|
|
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(
|
|
101
|
+
ctx.logger.warn(`轮询分析任务 ${id} 失败(下轮继续): ${err?.message ?? err}`)
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
}
|