feat: optimize web driver, update memory SOP and root welcome guide
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
[CONSTITUTION]
|
||||
1. 修改自身源码前必请示;./ 目录内实验可自主执行。
|
||||
2. 决策前必先枚举 STORES 索引并读取条目;未经验证不硬断言。
|
||||
3. 复杂任务单步执行:严禁盲目一气呵成,每步必有物理验证反馈。
|
||||
1. 修改自身源码前必请示;./ 目录内实验可自主执行,允许安装py包和命令行工具。
|
||||
2. 做决策前必先查记忆库;未查证的事实不得断言。
|
||||
3. 复杂任务需分步执行并每步验证:严禁盲目一气呵成。三次重试失败必须请求干预。
|
||||
4. 严禁未经授权读取/移动密钥或密码文件;仅限引用或申请许可。
|
||||
5. 修改/写入任何记忆前必先读取META-SOP核验。
|
||||
|
||||
[META-SOP]
|
||||
- memory_management_sop.md (L0 准则;修改/写入记忆前必先 read 核验)
|
||||
[META-SOP (L0)]
|
||||
- ../memory/memory_management_sop.md
|
||||
|
||||
[DIRECTORY]
|
||||
- L2_Facts: ../memory/global_mem.txt (Method: 按 TOPIC 检索索引 -> file_read 对应条目)
|
||||
|
||||
@@ -294,14 +294,16 @@
|
||||
return { error: '没有可执行的代码' };
|
||||
}
|
||||
updateStatus('exec');
|
||||
|
||||
const _open = window.open;
|
||||
window.open = (url, target, features) => {
|
||||
GM_openInTab(url, { active: true });
|
||||
return { success: true, url: url };
|
||||
};
|
||||
try {
|
||||
const jsCode = data.code.trim();
|
||||
const lines = jsCode.split(/\r?\n/).filter(l => l.trim());
|
||||
const lastLine = lines.length > 0 ? lines[lines.length - 1].trim() : '';
|
||||
|
||||
if (lastLine.startsWith('return')) {
|
||||
// 最后一行包含 return 语句,使用 Function 构造器
|
||||
result = (new Function(jsCode))();
|
||||
} else {
|
||||
try {
|
||||
@@ -309,16 +311,21 @@
|
||||
} catch (e) {
|
||||
if (isIllegalReturnError(e)) {
|
||||
result = (new Function(jsCode))();
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
} else throw e;
|
||||
}
|
||||
}
|
||||
const processedResult = smartProcessResult(result);
|
||||
if (result instanceof Promise) {
|
||||
result.finally(() => window.open = _open);
|
||||
return { result: processedResult };
|
||||
}
|
||||
return { result: processedResult };
|
||||
|
||||
} catch (execError) {
|
||||
return { error: execError }; // 返回错误信息
|
||||
return { error: execError };
|
||||
} finally {
|
||||
if (!(result instanceof Promise)) {
|
||||
setTimeout(() => window.open = _open, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user