1.18更新

This commit is contained in:
RT15548
2026-01-18 20:04:43 +08:00
committed by GitHub
parent be142640c0
commit 03ba508a31
62 changed files with 18838 additions and 7264 deletions

View File

@@ -1,75 +1,75 @@
<div class="scheduled-tasks-embedded-warning">
<h3>检测到嵌入的循环任务及可能的统计好感度设定</h3>
<p>此角色包含循环任务,这些任务可能会自动执行斜杠命令。</p>
<p>您是否允许此角色使用这些任务?</p>
<div class="warning-note">
<i class="fa-solid fa-exclamation-triangle"></i>
<span>注意:这些任务将在对话过程中自动执行,请确认您信任此角色的创建者。</span>
</div>
</div>
<style>
.scheduled-tasks-embedded-warning {
max-width: 500px;
padding: 20px;
}
.scheduled-tasks-embedded-warning h3 {
color: #ff6b6b;
margin-bottom: 15px;
}
.task-preview-container {
margin: 15px 0;
padding: 10px;
background: rgba(255, 255, 255, 0.05);
border-radius: 5px;
}
.task-list {
max-height: 200px;
overflow-y: auto;
margin-top: 10px;
}
.task-preview {
margin: 8px 0;
padding: 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 3px;
border-left: 3px solid #4CAF50;
}
.task-preview strong {
color: #4CAF50;
display: block;
margin-bottom: 5px;
}
.task-commands {
font-family: monospace;
font-size: 0.9em;
color: #ccc;
background: rgba(0, 0, 0, 0.3);
padding: 5px;
border-radius: 3px;
margin-top: 5px;
white-space: pre-wrap;
}
.warning-note {
display: flex;
align-items: center;
gap: 10px;
margin-top: 15px;
padding: 10px;
background: rgba(255, 193, 7, 0.1);
border: 1px solid rgba(255, 193, 7, 0.3);
border-radius: 5px;
color: #ffc107;
}
.warning-note i {
font-size: 1.2em;
}
</style>
<div class="scheduled-tasks-embedded-warning">
<h3>检测到嵌入的循环任务及可能的统计好感度设定</h3>
<p>此角色包含循环任务,这些任务可能会自动执行斜杠命令。</p>
<p>您是否允许此角色使用这些任务?</p>
<div class="warning-note">
<i class="fa-solid fa-exclamation-triangle"></i>
<span>注意:这些任务将在对话过程中自动执行,请确认您信任此角色的创建者。</span>
</div>
</div>
<style>
.scheduled-tasks-embedded-warning {
max-width: 500px;
padding: 20px;
}
.scheduled-tasks-embedded-warning h3 {
color: #ff6b6b;
margin-bottom: 15px;
}
.task-preview-container {
margin: 15px 0;
padding: 10px;
background: rgba(255, 255, 255, 0.05);
border-radius: 5px;
}
.task-list {
max-height: 200px;
overflow-y: auto;
margin-top: 10px;
}
.task-preview {
margin: 8px 0;
padding: 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 3px;
border-left: 3px solid #4CAF50;
}
.task-preview strong {
color: #4CAF50;
display: block;
margin-bottom: 5px;
}
.task-commands {
font-family: monospace;
font-size: 0.9em;
color: #ccc;
background: rgba(0, 0, 0, 0.3);
padding: 5px;
border-radius: 3px;
margin-top: 5px;
white-space: pre-wrap;
}
.warning-note {
display: flex;
align-items: center;
gap: 10px;
margin-top: 15px;
padding: 10px;
background: rgba(255, 193, 7, 0.1);
border: 1px solid rgba(255, 193, 7, 0.3);
border-radius: 5px;
color: #ffc107;
}
.warning-note i {
font-size: 1.2em;
}
</style>

View File

@@ -1,75 +1,75 @@
<div class="scheduled-tasks-embedded-warning">
<h3>检测到嵌入的循环任务及可能的统计好感度设定</h3>
<p>此角色包含循环任务,这些任务可能会自动执行斜杠命令。</p>
<p>您是否允许此角色使用这些任务?</p>
<div class="warning-note">
<i class="fa-solid fa-exclamation-triangle"></i>
<span>注意:这些任务将在对话过程中自动执行,请确认您信任此角色的创建者。</span>
</div>
</div>
<style>
.scheduled-tasks-embedded-warning {
max-width: 500px;
padding: 20px;
}
.scheduled-tasks-embedded-warning h3 {
color: #ff6b6b;
margin-bottom: 15px;
}
.task-preview-container {
margin: 15px 0;
padding: 10px;
background: rgba(255, 255, 255, 0.05);
border-radius: 5px;
}
.task-list {
max-height: 200px;
overflow-y: auto;
margin-top: 10px;
}
.task-preview {
margin: 8px 0;
padding: 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 3px;
border-left: 3px solid #4CAF50;
}
.task-preview strong {
color: #4CAF50;
display: block;
margin-bottom: 5px;
}
.task-commands {
font-family: monospace;
font-size: 0.9em;
color: #ccc;
background: rgba(0, 0, 0, 0.3);
padding: 5px;
border-radius: 3px;
margin-top: 5px;
white-space: pre-wrap;
}
.warning-note {
display: flex;
align-items: center;
gap: 10px;
margin-top: 15px;
padding: 10px;
background: rgba(255, 193, 7, 0.1);
border: 1px solid rgba(255, 193, 7, 0.3);
border-radius: 5px;
color: #ffc107;
}
.warning-note i {
font-size: 1.2em;
}
</style>
<div class="scheduled-tasks-embedded-warning">
<h3>检测到嵌入的循环任务及可能的统计好感度设定</h3>
<p>此角色包含循环任务,这些任务可能会自动执行斜杠命令。</p>
<p>您是否允许此角色使用这些任务?</p>
<div class="warning-note">
<i class="fa-solid fa-exclamation-triangle"></i>
<span>注意:这些任务将在对话过程中自动执行,请确认您信任此角色的创建者。</span>
</div>
</div>
<style>
.scheduled-tasks-embedded-warning {
max-width: 500px;
padding: 20px;
}
.scheduled-tasks-embedded-warning h3 {
color: #ff6b6b;
margin-bottom: 15px;
}
.task-preview-container {
margin: 15px 0;
padding: 10px;
background: rgba(255, 255, 255, 0.05);
border-radius: 5px;
}
.task-list {
max-height: 200px;
overflow-y: auto;
margin-top: 10px;
}
.task-preview {
margin: 8px 0;
padding: 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 3px;
border-left: 3px solid #4CAF50;
}
.task-preview strong {
color: #4CAF50;
display: block;
margin-bottom: 5px;
}
.task-commands {
font-family: monospace;
font-size: 0.9em;
color: #ccc;
background: rgba(0, 0, 0, 0.3);
padding: 5px;
border-radius: 3px;
margin-top: 5px;
white-space: pre-wrap;
}
.warning-note {
display: flex;
align-items: center;
gap: 10px;
margin-top: 15px;
padding: 10px;
background: rgba(255, 193, 7, 0.1);
border: 1px solid rgba(255, 193, 7, 0.3);
border-radius: 5px;
color: #ffc107;
}
.warning-note i {
font-size: 1.2em;
}
</style>

View File

@@ -2,7 +2,7 @@
// 导入
// ═══════════════════════════════════════════════════════════════════════════
import { extension_settings, getContext, writeExtensionField, renderExtensionTemplateAsync } from "../../../../../extensions.js";
import { extension_settings, getContext, writeExtensionField } from "../../../../../extensions.js";
import { saveSettingsDebounced, characters, this_chid, chat, callPopup } from "../../../../../../script.js";
import { getPresetManager } from "../../../../../preset-manager.js";
import { oai_settings } from "../../../../../openai.js";
@@ -146,14 +146,6 @@ async function allTasksFull() {
];
}
async function getTaskWithCommands(task, scope) {
if (!task) return task;
if (scope === 'global' && task.id && task.commands === undefined) {
return { ...task, commands: await TasksStorage.get(task.id) };
}
return task;
}
// ═══════════════════════════════════════════════════════════════════════════
// 设置管理
// ═══════════════════════════════════════════════════════════════════════════
@@ -419,7 +411,8 @@ async function persistTaskListByScope(scope, tasks) {
await TasksStorage.set(task.id, String(task.commands ?? ''));
}
const { commands, ...meta } = task;
const meta = { ...task };
delete meta.commands;
metaOnly.push(meta);
}
@@ -630,7 +623,6 @@ async function executeTaskJS(jsCode, taskName = 'AnonymousTask') {
const codeSig = __hashStringForKey(String(jsCode || ''));
const stableKey = (String(taskName || '').trim()) || `js-${codeSig}`;
const isLightTask = stableKey.startsWith('[x]');
const startedAt = nowMs();
const taskContext = {
taskName: String(taskName || 'AnonymousTask'),
@@ -783,6 +775,7 @@ async function executeTaskJS(jsCode, taskName = 'AnonymousTask') {
};
const runInScope = async (code) => {
// eslint-disable-next-line no-new-func -- intentional: user-defined task expression
const fn = new Function(
'taskContext', 'ctx', 'STscript', 'addFloorListener',
'addListener', 'setTimeoutSafe', 'clearTimeoutSafe', 'setIntervalSafe', 'clearIntervalSafe', 'abortSignal',
@@ -1433,20 +1426,6 @@ async function saveTaskFromEditor(task, scope) {
refreshUI();
}
function saveTask(task, index, scope) {
const list = getTaskListByScope(scope);
if (index >= 0 && index < list.length) list[index] = task;
persistTaskListByScope(scope, [...list]);
refreshUI();
}
async function testTask(index, scope) {
const list = getTaskListByScope(scope);
let task = list[index];
if (!task) return;
task = await getTaskWithCommands(task, scope);
await executeCommands(task.commands, task.name);
}
async function editTask(index, scope) {
const list = getTaskListByScope(scope);
@@ -1568,7 +1547,7 @@ async function showCloudTasksModal() {
const contentEl = modalTemplate.find('.cloud-tasks-content');
const errorEl = modalTemplate.find('.cloud-tasks-error');
const popup = callGenericPopup(modalTemplate, POPUP_TYPE.TEXT, '', { okButton: '关闭' });
callGenericPopup(modalTemplate, POPUP_TYPE.TEXT, '', { okButton: '关闭' });
try {
const cloudTasks = await fetchCloudTasks();
@@ -1625,19 +1604,6 @@ function createCloudTaskItem(taskInfo) {
// 导入导出
// ═══════════════════════════════════════════════════════════════════════════
async function exportGlobalTasks() {
const metaList = getSettings().globalTasks;
if (metaList.length === 0) return;
const tasks = await Promise.all(metaList.map(async (meta) => ({
...meta,
commands: await TasksStorage.get(meta.id)
})));
const fileName = `global_tasks_${new Date().toISOString().split('T')[0]}.json`;
const fileData = JSON.stringify({ type: 'global', exportDate: new Date().toISOString(), tasks }, null, 4);
download(fileData, fileName, 'application/json');
}
async function exportSingleTask(index, scope) {
const list = getTaskListByScope(scope);
@@ -1796,7 +1762,7 @@ function cleanup() {
try {
if (state.dynamicCallbacks && state.dynamicCallbacks.size > 0) {
for (const [id, entry] of state.dynamicCallbacks.entries()) {
for (const entry of state.dynamicCallbacks.values()) {
try { entry?.abortController?.abort(); } catch {}
}
state.dynamicCallbacks.clear();
@@ -2105,6 +2071,7 @@ async function initTasks() {
window.registerModuleCleanup('scheduledTasks', cleanup);
}
// eslint-disable-next-line no-restricted-syntax -- legacy task bridge; keep behavior unchanged.
window.addEventListener('message', handleTaskMessage);
$('#scheduled_tasks_enabled').on('input', e => {