fix: repair generated JavaScript session package errors

This commit is contained in:
shiyue
2026-08-29 22:47:08 +08:00
parent 97b4a32dda
commit 6fff9023b2
3 changed files with 31 additions and 1 deletions

View File

@@ -124,6 +124,16 @@ const CONVERSATION_STATUSES = new Set(['running', 'waiting_for_children', 'idle'
const EVENT_POLL_INTERVAL_MS = 100;
const IDLE_EVENT_STABILITY_MS = 250;
function errorFromPayload(payload) {
const error = new Error(String(payload?.message || payload?.code || 'ccweb 脚本调用失败'));
error.code = String(payload?.code || 'script_call_failed');
error.details = payload && typeof payload === 'object' ? { ...payload } : {};
delete error.details.ok;
delete error.details.code;
delete error.details.message;
return error;
}
function localError(code, message, details = {}) {
const error = new Error(message);
error.code = code;