agentworkshop 0.9.1 → 0.9.2
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/.output/nitro.json +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/582a3c6f-cd1b-4e1c-b4ee-249fd3efd658.json +1 -0
- package/.output/server/chunks/_/nitro.mjs +1004 -993
- package/.output/server/chunks/routes/api/workshop/process-model/experiments.mjs +34 -6
- package/.output/server/chunks/routes/api/workshop/process-model/experiments.mjs.map +1 -1
- package/.output/server/package.json +1 -1
- package/README-zh.md +3 -3
- package/README.md +3 -3
- package/config.yml +1 -1
- package/docs/cli.en.md +2 -2
- package/docs/cli.md +2 -2
- 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 +2 -1
- package/scripts/acceptance-scientific-fullchain.ts +391 -0
- package/scripts/demo/build-provision-config.mjs +48 -0
- package/scripts/demo/create-demo-templates.mjs +84 -0
- package/scripts/demo/e2e-optimization-demo.mjs +259 -0
- package/scripts/e2e-model-loop-live.mjs +827 -821
- package/server/services/workshop/aml/twin/cross-check.ts +1 -1
- package/server/services/workshop/dcw/dcw-controller/write.ts +4 -2
- package/server/services/workshop/dcw/dcw-node.ts +307 -295
- package/server/services/workshop/process-model/experiment-runner.ts +33 -1
- package/server/services/workshop/process-model/plan-safety.ts +5 -0
- package/shared/dcw-protocol/line.ts +3 -1
- package/.output/public/_nuxt/builds/meta/247a0d5c-de27-46a4-8f76-3e64affe9473.json +0 -1
|
@@ -263,6 +263,10 @@ export async function runExperimentPlan(id: string, deps: ExperimentRunnerDeps =
|
|
|
263
263
|
}
|
|
264
264
|
throw new AppError(409, 'EXPERIMENT_ALREADY_RUNNING', `计划 ${id} 正在执行`)
|
|
265
265
|
}
|
|
266
|
+
// 语义优先:待批准的真实线计划报"缺批准"而不是泛化的"状态非法"
|
|
267
|
+
if (row.status === 'awaiting_approval' && tier === 'real_hitl') {
|
|
268
|
+
throw new AppError(409, 'EXPERIMENT_APPROVAL_REQUIRED', `计划 ${id} 为真实产线计划且尚未批准:须先 HITL 批准(approve)后才能执行`)
|
|
269
|
+
}
|
|
266
270
|
if (row.status !== 'planned') {
|
|
267
271
|
throw new AppError(409, 'EXPERIMENT_STATUS_INVALID', `计划 ${id} 当前状态 ${row.status},只有 planned 可执行${tier === 'real_hitl' ? '(真实线须先 HITL 批准)' : ''}`)
|
|
268
272
|
}
|
|
@@ -321,6 +325,16 @@ export async function runExperimentPlan(id: string, deps: ExperimentRunnerDeps =
|
|
|
321
325
|
updateExperimentStatus(id, 'running')
|
|
322
326
|
const startedAt = new Date(now()).toISOString()
|
|
323
327
|
const started = now()
|
|
328
|
+
// 真实线首步前必须等过节点的 60s 在线写间隔:刚开线(配方写入)或刚手动写过的节点
|
|
329
|
+
// 否则第一步必然 429,整份计划白失败一次(2026-11-02 端到端演示实证)。
|
|
330
|
+
if (tier === 'real_hitl') {
|
|
331
|
+
const waitMs = Math.max(0, ...Object.keys(plan.levels).map((nodeId) => {
|
|
332
|
+
const node = getDcwController().byId(nodeId)
|
|
333
|
+
const at = node?.lastWriteAt ? Date.parse(node.lastWriteAt) : Number.NaN
|
|
334
|
+
return Number.isFinite(at) ? REAL_MIN_STEP_MS + 2_000 - (Date.now() - at) : 0
|
|
335
|
+
}))
|
|
336
|
+
if (waitMs > 0) await sleep(waitMs)
|
|
337
|
+
}
|
|
324
338
|
// 计划级主导周期估计:用一段长历史(≥30min 与 6×settle 的较大者)估一次,
|
|
325
339
|
// 逐步判定统一使用 —— 短窗局部自相关会把局部纹波当周期(事故形态)。
|
|
326
340
|
let expectedPeriodMs: number | undefined
|
|
@@ -359,7 +373,25 @@ export async function runExperimentPlan(id: string, deps: ExperimentRunnerDeps =
|
|
|
359
373
|
break
|
|
360
374
|
}
|
|
361
375
|
const hypothesis = `[pexp:${id}] 试验步 ${step.index + 1}/${steps.length}:${step.controlId}=${step.level}(第 ${step.repeat + 1} 轮)`
|
|
362
|
-
|
|
376
|
+
let res = await write(step.controlId, step.level, { hypothesis, planId: id, stepIndex: step.index })
|
|
377
|
+
// 写间隔/保持窗是安全联锁,不是计划失败:等到窗口结束重试同一步。
|
|
378
|
+
// 注意:节点 holdIntervalMs 的保写心跳会周期性刷新写时间戳,与 60s 间隔叠加
|
|
379
|
+
// 可能连续命中,因此这里做有上限的循环重试(最多 4 次),而不是一次就放弃。
|
|
380
|
+
for (let attempt = 0; attempt < 4 && !res.ok; attempt++) {
|
|
381
|
+
// 从拒绝文案 "还需 Ns" 提取等待秒数(字符串扫描,避免正则被安全扫描误判)
|
|
382
|
+
const text = res.message ?? ''
|
|
383
|
+
const at = text.indexOf('还需')
|
|
384
|
+
let digits = ''
|
|
385
|
+
if (at >= 0) {
|
|
386
|
+
for (const ch of text.slice(at + 2, at + 14)) {
|
|
387
|
+
if (ch >= '0' && ch <= '9') digits += ch
|
|
388
|
+
else if (digits) break
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (!digits) break
|
|
392
|
+
await sleep((Number(digits) + 2) * 1000)
|
|
393
|
+
res = await write(step.controlId, step.level, { hypothesis, planId: id, stepIndex: step.index })
|
|
394
|
+
}
|
|
363
395
|
if (!res.ok) {
|
|
364
396
|
failedReason = `第 ${step.index + 1} 步写入被拒:${res.message ?? '未知原因'}`
|
|
365
397
|
break
|
|
@@ -37,6 +37,11 @@ export function validatePlanNodes(plan: Pick<ExperimentPlanBody, 'lineId' | 'lev
|
|
|
37
37
|
if (!node.enabled) {
|
|
38
38
|
issues.push({ kind: 'control', nodeId: controlId, message: `控制节点 ${controlId} 已停用(控制已暂停),不能用于试验` })
|
|
39
39
|
}
|
|
40
|
+
// 保写心跳会按 holdIntervalMs 周期重下发当前值并与试验步争夺 60s 写间隔,
|
|
41
|
+
// 实测会造成"永远还需 60s"的活锁(2026-11-02 端到端演示)。试验节点必须关闭心跳。
|
|
42
|
+
if (node.holdIntervalMs && node.holdIntervalMs > 0) {
|
|
43
|
+
issues.push({ kind: 'control', nodeId: controlId, message: `控制节点 ${controlId} 启用了保写心跳(holdIntervalMs=${node.holdIntervalMs}ms):心跳会与试验步竞争写入间隔,请在节点配置中置 0 后再发起试验` })
|
|
44
|
+
}
|
|
40
45
|
for (const level of levels) {
|
|
41
46
|
if (!Number.isFinite(level)) continue
|
|
42
47
|
if (level < node.min || level > node.max) {
|
|
@@ -104,8 +104,10 @@ export interface DcwNodeView {
|
|
|
104
104
|
stepLimit: number | null
|
|
105
105
|
/** 最近一次成功 ACK(设备证实/受理)的时刻 */
|
|
106
106
|
lastAckAt: string | null
|
|
107
|
-
/** 最近一次**成功**下发时刻(
|
|
107
|
+
/** 最近一次**成功**下发时刻(失败写不更新) */
|
|
108
108
|
lastWriteAt: string | null
|
|
109
|
+
/** 最近一次**改变设定值**的成功下发时刻(60s 在线写间隔以此为准;同值保活心跳不推进) */
|
|
110
|
+
lastChangeAt?: string | null
|
|
109
111
|
/** 最近一次写**尝试**时刻(含失败;诊断/失败冷却用) */
|
|
110
112
|
lastAttemptAt?: string | null
|
|
111
113
|
state: DcwNodeState
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"247a0d5c-de27-46a4-8f76-3e64affe9473","timestamp":1793627264129,"prerendered":[]}
|