ci: auto build & obfuscate [2026-04-06 00:50:28] (Jenkins #7)

This commit is contained in:
Jenkins CI
2026-04-06 00:50:28 +08:00
parent ed3f52a568
commit 49c1fa6f60
142 changed files with 38769 additions and 29661 deletions

View File

@@ -0,0 +1,55 @@
/**
* MessagePipeline — 消息接收后的顺序处理流水线
*
* 用 ChainKoa 风格中间件)替代 events.js 中的手动 if/await 拼接,
* 并消除 AMILY2_TABLE_UPDATED fire-and-forget 反模式。
*
* 执行顺序:
* Stage 1: AutoHide — 自动隐藏旧消息
* Stage 2: TextOptimize — 正文优化AI 改写)
* Stage 3: TableUpdate — 表格解析与填写
* Stage 4: SuperMemorySync — 等待超级记忆世界书写入完成
* Stage 5: AutoSummary — 大史官自动总结(在 next() 之后运行,作为收尾)
*
* ctx 结构:
* messageId {number} 当前消息在 chat 中的索引
* latestMessage {Object} chat[messageId]
* chat {Array} context.chat 引用
* settings {Object} extension_settings[extensionName]
* optimizationResult {Object|null} 由 TextOptimize 阶段写入
*/
import { Chain } from '../../SL/bus/chain/Chain.js';
import { autoHideStage } from './stages/auto-hide.js';
import { textOptimizeStage } from './stages/text-optimize.js';
import { tableUpdateStage } from './stages/table-update.js';
import { superMemorySyncStage } from './stages/super-memory-sync.js';
import { autoSummaryStage } from './stages/auto-summary.js';
const pipeline = new Chain();
pipeline
.use(autoHideStage)
.use(textOptimizeStage)
.use(tableUpdateStage)
.use(superMemorySyncStage)
.use(autoSummaryStage);
export { pipeline as messagePipeline };
// ── Bus 注册 ──────────────────────────────────────────────────────────────
setTimeout(() => {
try {
const _ctx = window.Amily2Bus?.register('MessagePipeline');
if (!_ctx) {
console.warn('[MessagePipeline] Amily2Bus 尚未就绪,服务注册跳过。');
return;
}
_ctx.expose({
execute: (pipelineCtx) => pipeline.execute(pipelineCtx),
});
_ctx.log('MessagePipeline', 'info', 'MessagePipeline 服务已注册到 Bus。');
} catch (e) {
console.error('[MessagePipeline] Bus 注册失败:', e);
}
}, 0);

View File

@@ -0,0 +1,14 @@
/**
* Pipeline Stage 1 — AutoHide
* 自动隐藏超出阈值的旧消息。
*/
import { executeAutoHide } from '../../autoHideManager.js';
export async function autoHideStage(ctx, next) {
try {
await executeAutoHide();
} catch (e) {
console.error('[Pipeline:AutoHide] 阶段异常:', e);
}
await next();
}

View File

@@ -0,0 +1,13 @@
/**
* Pipeline Stage 5 — AutoSummary
* 触发大史官自动总结。属于非阻塞收尾任务,不等待完成即释放管道。
*/
import { checkAndTriggerAutoSummary } from '../../historiographer.js';
export async function autoSummaryStage(ctx, next) {
await next();
// 非阻塞:总结任务在后台执行,不阻断响应流
checkAndTriggerAutoSummary().catch(e => {
console.error('[Pipeline:AutoSummary] 后台总结任务异常:', e);
});
}

View File

@@ -0,0 +1,16 @@
/**
* Pipeline Stage 4 — SuperMemorySync
* 等待本轮所有世界书写入完成确保后续阶段AutoSummary读到最新状态。
* 通过 Bus 调用Bus 未就绪时静默跳过(不阻断管道)。
*/
export async function superMemorySyncStage(ctx, next) {
try {
const sm = window.Amily2Bus?.query('SuperMemory');
if (sm?.awaitSync) {
await sm.awaitSync();
}
} catch (e) {
console.error('[Pipeline:SuperMemorySync] 阶段异常:', e);
}
await next();
}

View File

@@ -0,0 +1,18 @@
/**
* Pipeline Stage 3 — TableUpdate
* 主 API 填表 + 分步 API 填表(各自内部自带模式判断,互不干扰)。
*/
import { processMessageUpdate, fillWithSecondaryApi } from '../../table-system/TableSystemService.js';
export async function tableUpdateStage(ctx, next) {
const { messageId, latestMessage } = ctx;
try {
// 主 API 模式secondary-api / optimized 模式下函数内部自行跳过)
await processMessageUpdate(messageId);
// 分步 / 优化中填表main-api 模式下函数内部自行跳过)
await fillWithSecondaryApi(latestMessage);
} catch (e) {
console.error('[Pipeline:TableUpdate] 阶段异常:', e);
}
await next();
}

View File

@@ -0,0 +1,18 @@
/**
* Pipeline Stage 2 — TextOptimize
* 调用 AI 对正文进行文学优化,结果写入 ctx.optimizationResult。
* 若优化未开启或 AI 调用失败,不阻断后续阶段。
*/
import { processOptimization } from '../../summarizer.js';
export async function textOptimizeStage(ctx, next) {
const { latestMessage, chat, messageId } = ctx;
const previousMessages = chat.slice(0, messageId);
try {
ctx.optimizationResult = await processOptimization(latestMessage, previousMessages);
} catch (e) {
console.error('[Pipeline:TextOptimize] 阶段异常:', e);
ctx.optimizationResult = null;
}
await next();
}