feat(tuning): release V0.8.2 Agent 界面重构
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled

This commit is contained in:
2026-09-03 16:25:53 +08:00
parent a9b07e0abf
commit 63d67a645b
35 changed files with 4847 additions and 811 deletions
@@ -129,18 +129,44 @@ export function LocalTrainingPanel({ onPolicyReady }: { onPolicyReady(file: File
typeof event.data !== 'object'
)
return;
const data = event.data as { type?: string; sessionId?: string };
const data = event.data as { type?: string; sessionId?: string; policy?: unknown };
const source = event.source as Window;
if (data.type === 'mujoco-tuning-ready') {
(event.source as Window).postMessage(
{ type: 'mujoco-tuning-credentials', endpoint, token },
event.origin,
);
source.postMessage({ type: 'mujoco-tuning-credentials', endpoint, token }, event.origin);
}
if (data.type === 'mujoco-tuning-import-policy' && data.sessionId) {
void new LocalTrainingClient(endpoint, token)
.downloadBestPolicy(data.sessionId)
.then(onPolicyReady)
.catch((value: unknown) => setError(errorText(value)));
const reply = (ok: boolean, message?: string) => {
try {
source.postMessage(
{
type: 'mujoco-tuning-import-policy-result',
sessionId: data.sessionId,
ok,
error: message,
},
event.origin,
);
} catch {
/* 调参窗口可能已关闭;不影响主工作台继续导入 */
}
};
void (async () => {
try {
const policy =
data.policy === undefined
? await new LocalTrainingClient(endpoint, token).downloadBestPolicy(data.sessionId!)
: data.policy;
if (!(policy instanceof File) || !/\.onnx$/i.test(policy.name))
throw new Error('调参工作台返回的 ONNX 策略无效');
if (policy.size > 64 * 1024 * 1024) throw new Error('ONNX 策略不能超过 64 MiB');
onPolicyReady(policy);
reply(true);
} catch (value) {
const message = errorText(value);
setError(message);
reply(false, message);
}
})();
}
};
window.addEventListener('message', receive);