Files
ST-Amily2-Chat-Optimisation…/core/summarizer.js
2025-12-11 23:53:15 +08:00

2 lines
21 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(_0x28a1f1,_0x5d134c){const _0x297105=_0x1ceb,_0x381844=_0x28a1f1();while(!![]){try{const _0xf6c17e=parseInt(_0x297105(0xcb))/0x1*(-parseInt(_0x297105(0x76))/0x2)+-parseInt(_0x297105(0xc9))/0x3*(parseInt(_0x297105(0x74))/0x4)+parseInt(_0x297105(0xcd))/0x5*(parseInt(_0x297105(0xb6))/0x6)+parseInt(_0x297105(0xaf))/0x7*(-parseInt(_0x297105(0x84))/0x8)+-parseInt(_0x297105(0x7f))/0x9+parseInt(_0x297105(0xbe))/0xa+parseInt(_0x297105(0xbb))/0xb;if(_0xf6c17e===_0x5d134c)break;else _0x381844['push'](_0x381844['shift']());}catch(_0x1bbc5e){_0x381844['push'](_0x381844['shift']());}}}(_0x4ff1,0x1db26));import{extension_settings,getContext}from'/scripts/extensions.js';import{characters}from'/script.js';import{world_info}from'/scripts/world-info.js';import{extensionName}from'../utils/settings.js';import{extractContentByTag,replaceContentByTag,extractFullTagBlock}from'../utils/tagProcessor.js';function _0x1ceb(_0x3df836,_0x34991f){const _0x4ff1bd=_0x4ff1();return _0x1ceb=function(_0x1ceb03,_0x5eedaf){_0x1ceb03=_0x1ceb03-0x6e;let _0x5b5bab=_0x4ff1bd[_0x1ceb03];return _0x5b5bab;},_0x1ceb(_0x3df836,_0x34991f);}import{isGoogleEndpoint,convertToGoogleRequest,parseGoogleResponse,buildGoogleApiUrl,buildPlotOptimizationGoogleRequest,parsePlotOptimizationGoogleResponse}from'./utils/googleAdapter.js';import{applyExclusionRules,extractBlocksByTags}from'./utils/rag-tag-extractor.js';function _0x4ff1(){const _0x4d237b=['{{{Amily2TableData}}}','[Amily2-内容排除]\x20正文优化内容排除规则已生效文本长度从\x20','worldSnippet','[Amily2-外交部]\x20AI的回复中未找到有效的目标标签\x20<','replace','plot','plotOpt_mainPrompt','[Amily2-外交部]\x20发生严重错误:','[目标内容]:\x0a','EjsTemplate','optimizationExclusionEnabled','[Amily2号-正文优化任务]\x20','plot_optimization','plotOpt_rateMain','mainPrompt','optimizationEnabled','plotOpt_tableEnabled','剧情优化在\x20','优化任务总耗时','join','plotOpt_ratePersonal','EJS\x20预处理用户输入失败已中止。','history','\x20次尝试失败回复内容长度为\x20','##以下内容是故事发生的剧情中提取出的内容,已经转化为表格形式呈现给你,请将以下内容作为后续剧情的一部分参考:<表格内容>\x0a{{{Amily2TableDataContent}}}</表格内容>','message','[Amily2-优化中填表]\x20流程已全部完成并已强制保存和刷新UI。',']\x20优化任务在尝试前被中止。','name2','优化失败','getSyntaxErrorInfo','\x20次尝试后失败。','original','\x20次尝试...','[Amily2号-最终国书内容\x20(发往AI)]','map','contextLimit','plotOpt_systemPrompt','is_user','worldErrorMessage','AI最新消息[核心处理内容]','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20记录语法位置信息失败',']\x20从AI收到的原始回复','<Additional\x20instructionsv>Start\x20and\x20end\x20labels\x20correctly.<Additional\x20instructions>','push','plotOpt_enabled','groupEnd',']\x20优化任务在API调用后被中止。','plotOpt_contextLimit','4hKAkHD','time','30FOsJQQ','systemPrompt','plotOpt_ejsEnabled','optimization','chat','{{{Amily2TableDataContent}}}','filling_mode','prepareContext','[Amily2-表格系统]\x20注入表格内容时出错:','1629027huBLCY','<前文内容>\x0a','error','[Amily2号-原始回复]','AMILY2_SYSTEM_PARALYZED','16MAIwcR','historiographyTags','[Amily2-外交部]\x20目标标签\x20<','严重错误','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20失败世界书片段\x20(截断=','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20打印失败世界书片段时出错','toLocaleTimeString','plotOpt_rateCuckold','[核心处理内容]:\x0a','worldSnippetTruncated','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20EJS\x20預處理-用户输入失败:','剧情优化任务总耗时','showOptimizationToast','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20EJS\x20預處理-世界书失败:','slice','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20EJS\x20預處理初始化失败可能是上下文环境','user','name1','warn',')\x20且未获得符合要求的回复优化任务中止。','coreContent','conditional',']\x20第\x20','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20以上即失败世界书片段。','(用户)最新消息:','Amily2PlotOptDebug','filter','historiographyExclusionRules','worldbook','>\x20未找到或为空或内容已被完全排除优化任务已跳过。','historiographyTagExtractionEnabled','split','optimized','optimizationExclusionRules','system','test','toString','jqyhEnabled','请你在优化完成后,在正文标签外结合最新消息中的剧情、当前的表格内容进行填表任务:\x0a\x0a','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20EJS\x20預處理-世界书失败(含定位)','trim','>,将保留原始消息。','dir','449512LwwvXZ','match','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20worldOpenClose:','[Amily2-外交部]\x20未能获取AI响应内容','\x20次尝试成功内容长度\x20(',']\x20剧情优化第\x20','mes','59628miyqAz','EJS\x20预处理初始化失败已中止。','log','Amily2号任务失败:\x20','timeEnd','5159759GEAMDa','剧情优化任务失败:\x20','length','360760bCbnwV','prompt','<plot>','Amily2号','string','Amily2PreOptimizationSnapshot',']\x20已达到最大重试次数\x20(','groupCollapsed','[ST-Amily2-Chat-Optimisation][PlotOpt]\x20检测到未闭合的\x20EJS\x20标签世界书已跳过预处理。','evalTemplate','./table-system/manager.js','285921RzsBMU','<世界书内容>\x0a','1897BhceTR','preOptimizationStateUpdated','25qsozQw','type','dispatchEvent'];_0x4ff1=function(){return _0x4d237b;};return _0x4ff1();}import{getCombinedWorldbookContent,getPlotOptimizedWorldbookContent,getOptimizationWorldbookContent}from'./lore.js';import{getBatchFillerFlowTemplate,convertTablesToCsvString,updateTableFromText,saveStateToMessage,getMemoryState}from'./table-system/manager.js';import{saveChat}from'/script.js';import{renderTables}from'../ui/table-bindings.js';import{getPresetPrompts,getMixedOrder}from'../PresetSettings/index.js';import{callAI,generateRandomSeed}from'./api.js';import{callJqyhAI}from'./api/JqyhApi.js';export async function processOptimization(_0x1d7912,_0x2fc44b){const _0x5c5032=_0x1ceb;if(window[_0x5c5032(0x83)]===!![])return console['error']('[Amily2-制裁]\x20系统完整性已受损所有外交活动被无限期中止。'),null;const _0x5e5198=extension_settings[extensionName],_0x337470=_0x5e5198[_0x5c5032(0xdf)];if(!_0x337470)return null;console[_0x5c5032(0xc5)](_0x5c5032(0xdb)+new Date()[_0x5c5032(0x8a)]()),console[_0x5c5032(0x75)](_0x5c5032(0xe2));try{window[_0x5c5032(0xc3)]={'original':null,'optimized':null,'raw':_0x1d7912[_0x5c5032(0xb5)]};const _0x58ce07=_0x1d7912[_0x5c5032(0xb5)];let _0x1c7267=_0x58ce07;if(_0x5e5198[_0x5c5032(0xda)]&&_0x5e5198[_0x5c5032(0xa5)]?.[_0x5c5032(0xbd)]>0x0){const _0x45b537=_0x1c7267[_0x5c5032(0xbd)];_0x1c7267=applyExclusionRules(_0x1c7267,_0x5e5198[_0x5c5032(0xa5)]);const _0x30b121=_0x1c7267[_0x5c5032(0xbd)];_0x45b537!==_0x30b121&&console[_0x5c5032(0xb8)](_0x5c5032(0xd1)+_0x45b537+'\x20变为\x20'+_0x30b121+'。');}const _0xcdeb8b=_0x5e5198['optimizationTargetTag']||'content',_0x5e012a=extractFullTagBlock(_0x1c7267,_0xcdeb8b);if(!_0x5e012a||extractContentByTag(_0x5e012a,_0xcdeb8b)?.[_0x5c5032(0xac)]()==='')return console['log'](_0x5c5032(0x86)+_0xcdeb8b+_0x5c5032(0xa1)),window[_0x5c5032(0xc3)]=null,document[_0x5c5032(0xcf)](new CustomEvent(_0x5c5032(0xcc))),console[_0x5c5032(0xba)](_0x5c5032(0xe2)),console[_0x5c5032(0x71)](),null;window[_0x5c5032(0xc3)][_0x5c5032(0xf0)]=extractContentByTag(_0x5e012a,_0xcdeb8b),document[_0x5c5032(0xcf)](new CustomEvent(_0x5c5032(0xcc))),_0x1c7267=_0x5e012a;const _0x2fe0cc=getContext(),_0x3a6c70=_0x2fe0cc[_0x5c5032(0x95)]||'用户',_0x2f0bfb=_0x2fe0cc[_0x5c5032(0xec)]||'角色',_0xbdae81=_0x2fc44b[_0x5c5032(0xbd)]>0x0&&_0x2fc44b[_0x2fc44b[_0x5c5032(0xbd)]-0x1][_0x5c5032(0xf6)]?_0x2fc44b[_0x2fc44b[_0x5c5032(0xbd)]-0x1]:null,_0x428e08=_0xbdae81?_0x2fc44b[_0x5c5032(0x92)](0x0,-0x1):_0x2fc44b,_0x1a1038=_0x428e08[_0x5c5032(0xf3)](_0x107419=>_0x107419[_0x5c5032(0xb5)]&&_0x107419[_0x5c5032(0xb5)]['trim']()?(_0x107419['is_user']?_0x3a6c70:_0x2f0bfb)+':\x20'+_0x107419['mes']['trim']():null)['filter'](Boolean)[_0x5c5032(0xe3)]('\x0a'),_0x174111=await getOptimizationWorldbookContent(),_0x48bc12=await getPresetPrompts('optimization'),_0x5cdc23=[{'role':_0x5c5032(0xa6),'content':generateRandomSeed()}];let _0x48076d=_0xbdae81?_0x3a6c70+_0x5c5032(0x9c)+_0xbdae81[_0x5c5032(0xb5)]+'\x0a'+_0x2f0bfb+'AI最新消息[核心处理内容]'+_0x1c7267:_0x2f0bfb+_0x5c5032(0xf8)+_0x1c7267;const _0x474f6d=_0x5e5198[_0x5c5032(0x7c)]||'main-api',_0x3816c1=getMixedOrder(_0x5c5032(0x79))||[];let _0x1c6cf6=0x0;for(const _0x503243 of _0x3816c1){if(_0x503243[_0x5c5032(0xce)]===_0x5c5032(0xbf))_0x48bc12&&_0x48bc12[_0x1c6cf6]&&(_0x5cdc23['push'](_0x48bc12[_0x1c6cf6]),_0x1c6cf6++);else{if(_0x503243['type']===_0x5c5032(0x99))switch(_0x503243['id']){case _0x5c5032(0xde):_0x5e5198[_0x5c5032(0xde)]?.[_0x5c5032(0xac)]()&&_0x5cdc23[_0x5c5032(0x6f)]({'role':_0x5c5032(0xa6),'content':_0x5e5198[_0x5c5032(0xde)]['trim']()});break;case _0x5c5032(0x77):_0x5e5198[_0x5c5032(0x77)]?.[_0x5c5032(0xac)]()&&_0x5cdc23[_0x5c5032(0x6f)]({'role':_0x5c5032(0xa6),'content':_0x5e5198[_0x5c5032(0x77)]['trim']()});break;case _0x5c5032(0xa0):_0x174111&&_0x5cdc23[_0x5c5032(0x6f)]({'role':_0x5c5032(0x94),'content':'[世界书档案]:\x0a'+_0x174111});break;case _0x5c5032(0xe6):_0x1a1038&&_0x5cdc23[_0x5c5032(0x6f)]({'role':'user','content':'[上下文参考]:\x0a'+_0x1a1038});break;case'fillingMode':if(_0x337470&&_0x474f6d===_0x5c5032(0xa4)){const _0x3e9077=getBatchFillerFlowTemplate(),_0x3569a8=convertTablesToCsvString(),_0x1368e1=_0x3e9077['replace'](_0x5c5032(0xd0),_0x3569a8);_0x5cdc23[_0x5c5032(0x6f)]({'role':_0x5c5032(0x94),'content':_0x48076d}),_0x5cdc23[_0x5c5032(0x6f)]({'role':_0x5c5032(0xa6),'content':_0x5c5032(0xaa)+_0x1368e1+'\x0a\x0a<Amily2Edit>\x0a<!--\x0a这里是你的填表内容\x0a-->\x0a</Amily2Edit><Additional\x20instructionsv>Optimisation\x20and\x20form\x20filling\x20have\x20been\x20completed.<Additional\x20instructions>'});}else _0x5cdc23[_0x5c5032(0x6f)]({'role':'user','content':_0x5c5032(0xd8)+_0x48076d+_0x5c5032(0x6e)});break;}}}console[_0x5c5032(0xc5)](_0x5c5032(0xf2)),console[_0x5c5032(0xae)](_0x5cdc23),console[_0x5c5032(0x71)]();const _0x475a90=await callAI(_0x5cdc23);if(!_0x475a90)return console[_0x5c5032(0x81)](_0x5c5032(0xb2)),null;console['groupCollapsed'](_0x5c5032(0x82)),console[_0x5c5032(0xb8)](_0x475a90),console['groupEnd']();let _0x6f39e8=_0x58ce07;const _0x50f7ac=extractContentByTag(_0x475a90,_0xcdeb8b);_0x50f7ac?.['trim']()?(_0x6f39e8=replaceContentByTag(_0x58ce07,_0xcdeb8b,_0x50f7ac),window[_0x5c5032(0xc3)][_0x5c5032(0xa4)]=_0x50f7ac):(console[_0x5c5032(0x96)](_0x5c5032(0xd3)+_0xcdeb8b+_0x5c5032(0xad)),window['Amily2PreOptimizationSnapshot'][_0x5c5032(0xa4)]=window[_0x5c5032(0xc3)][_0x5c5032(0xf0)]);document[_0x5c5032(0xcf)](new CustomEvent(_0x5c5032(0xcc)));if(_0x337470&&_0x474f6d===_0x5c5032(0xa4)){await updateTableFromText(_0x475a90);const _0x2a7e54=getContext();if(_0x2a7e54[_0x5c5032(0x7a)]&&_0x2a7e54[_0x5c5032(0x7a)][_0x5c5032(0xbd)]>0x0){const _0x324178=_0x2a7e54['chat'][_0x2a7e54[_0x5c5032(0x7a)]['length']-0x1];saveStateToMessage(getMemoryState(),_0x324178)&&(await saveChat(),renderTables(),console[_0x5c5032(0xb8)](_0x5c5032(0xea)));}}const _0x1358d0={'originalContent':_0x58ce07,'optimizedContent':_0x6f39e8};return _0x5e5198[_0x5c5032(0x90)]&&toastr['success']('正文优化成功!',_0x5c5032(0xc1)),console[_0x5c5032(0xba)]('优化任务总耗时'),console[_0x5c5032(0x71)](),_0x1358d0;}catch(_0xd06180){return console[_0x5c5032(0x81)](_0x5c5032(0xd7),_0xd06180),toastr[_0x5c5032(0x81)](_0x5c5032(0xb9)+_0xd06180['message'],_0x5c5032(0x87)),console[_0x5c5032(0xba)](_0x5c5032(0xe2)),console['groupEnd'](),null;}}export async function processPlotOptimization(_0xfe6926,_0x5c6909,_0x538852={'isCancelled':![]}){const _0x3d1e3e=_0x1ceb,_0x339ebe=extension_settings[extensionName];if(_0x339ebe[_0x3d1e3e(0x70)]===![])return null;console[_0x3d1e3e(0xc5)]('['+extensionName+']\x20剧情优化任务启动...\x20'+new Date()[_0x3d1e3e(0x8a)]()),console[_0x3d1e3e(0x75)](_0x3d1e3e(0x8f));try{const _0x3d7e5d=_0xfe6926[_0x3d1e3e(0xb5)];if(!_0x3d7e5d||_0x3d7e5d[_0x3d1e3e(0xac)]()==='')return console['log']('['+extensionName+']\x20用户输入为空跳过优化。'),null;const _0xd3261f=getContext(),_0x5a236b=_0xd3261f['name1']||'用户',_0x3e5336=_0xd3261f[_0x3d1e3e(0xec)]||'角色',_0x4eb58f=await getPresetPrompts(_0x3d1e3e(0xdc)),_0x2d8b9c=[{'role':_0x3d1e3e(0xa6),'content':generateRandomSeed()}],_0x4da4ab={'sulv1':_0x339ebe[_0x3d1e3e(0xdd)]??0x1,'sulv2':_0x339ebe[_0x3d1e3e(0xe4)]??0x1,'sulv3':_0x339ebe['plotOpt_rateErotic']??0x1,'sulv4':_0x339ebe[_0x3d1e3e(0x8b)]??0x1};let _0x4b36c7=_0x339ebe[_0x3d1e3e(0xd6)]||'',_0x4a27c9=_0x339ebe[_0x3d1e3e(0xf5)]||'';for(const _0x2d19fa in _0x4da4ab){const _0x3066ed=_0x4da4ab[_0x2d19fa],_0x57eb6f=new RegExp(_0x2d19fa[_0x3d1e3e(0xd4)](/[-\/\\^$*+?.()|[\]{}]/g,'\x5c$&'),'g');_0x4b36c7=_0x4b36c7['replace'](_0x57eb6f,_0x3066ed),_0x4a27c9=_0x4a27c9[_0x3d1e3e(0xd4)](_0x57eb6f,_0x3066ed);}let _0x478a4a=await getPlotOptimizedWorldbookContent(_0xd3261f,_0x339ebe);try{if(_0x339ebe[_0x3d1e3e(0x78)]!==![]&&globalThis[_0x3d1e3e(0xd9)]?.[_0x3d1e3e(0xc7)]&&globalThis[_0x3d1e3e(0xd9)]?.[_0x3d1e3e(0x7d)]){const _0x1c912f=(_0x3d7e5d??'')['toString'](),_0x25ced3=(_0x478a4a??'')[_0x3d1e3e(0xa8)](),_0x46fa7b=/<%[=_\-]?/[_0x3d1e3e(0xa7)](_0x1c912f),_0x2c2081=/<%[=_\-]?/[_0x3d1e3e(0xa7)](_0x25ced3),_0x3935cd=/<%[=_\-]?/g,_0x56436f=/[-_]?%>/g,_0x1329e6=(_0x1c912f[_0x3d1e3e(0xb0)](_0x3935cd)||[])['length'],_0x284b22=(_0x1c912f[_0x3d1e3e(0xb0)](_0x56436f)||[])['length'],_0x2a4a38=(_0x25ced3[_0x3d1e3e(0xb0)](_0x3935cd)||[])[_0x3d1e3e(0xbd)],_0x55ca35=(_0x25ced3['match'](_0x56436f)||[])['length'],_0x4cc1fb=_0x46fa7b&&_0x1329e6===_0x284b22&&_0x1329e6>0x0,_0x5b4db6=_0x2c2081&&_0x2a4a38===_0x55ca35&&_0x2a4a38>0x0;if(_0x46fa7b||_0x2c2081){const _0x6c83b5=await globalThis[_0x3d1e3e(0xd9)][_0x3d1e3e(0x7d)]({'runType':_0x3d1e3e(0xdc),'isDryRun':![]});try{if(_0x4cc1fb){const _0x5cd6ce=await globalThis[_0x3d1e3e(0xd9)][_0x3d1e3e(0xc7)](_0x1c912f,_0x6c83b5,{'_with':!![]});typeof _0x5cd6ce==='string'&&_0x5cd6ce[_0x3d1e3e(0xbd)]>0x0&&(_0xfe6926[_0x3d1e3e(0xb5)]=_0x5cd6ce);}else _0x46fa7b&&console['warn']('[ST-Amily2-Chat-Optimisation][PlotOpt]\x20检测到未闭合的\x20EJS\x20标签用户输入已跳过预处理。');}catch(_0x5f1796){return console[_0x3d1e3e(0x81)](_0x3d1e3e(0x8e),_0x5f1796),toastr[_0x3d1e3e(0x81)](_0x3d1e3e(0xe5),_0x3d1e3e(0xc1)),null;}try{if(_0x5b4db6){const _0x3db642=await globalThis[_0x3d1e3e(0xd9)][_0x3d1e3e(0xc7)](_0x25ced3,_0x6c83b5,{'_with':!![]});typeof _0x3db642==='string'&&_0x3db642[_0x3d1e3e(0xbd)]>0x0&&(_0x478a4a=_0x3db642);}else _0x2c2081&&console['warn'](_0x3d1e3e(0xc6));}catch(_0x166b70){try{if(globalThis['EjsTemplate']?.['getSyntaxErrorInfo']&&typeof _0x166b70?.['message']===_0x3d1e3e(0xc2)){const _0x1f53fd=globalThis[_0x3d1e3e(0xd9)][_0x3d1e3e(0xee)](_0x25ced3);console[_0x3d1e3e(0x81)](_0x3d1e3e(0xab),_0x166b70?.[_0x3d1e3e(0xe9)]+(_0x1f53fd||''));}else console[_0x3d1e3e(0x81)](_0x3d1e3e(0x91),_0x166b70);try{const _0x31d8cf=0x7d0,_0x52d864=typeof _0x25ced3==='string'?_0x25ced3[_0x3d1e3e(0x92)](0x0,_0x31d8cf):String(_0x25ced3)['slice'](0x0,_0x31d8cf),_0x3e8102=(_0x25ced3?.[_0x3d1e3e(0xbd)]||0x0)>_0x31d8cf;try{window[_0x3d1e3e(0x9d)]=window[_0x3d1e3e(0x9d)]||{},window[_0x3d1e3e(0x9d)][_0x3d1e3e(0xf7)]=(_0x166b70?.[_0x3d1e3e(0xe9)]||String(_0x166b70))+'',window['Amily2PlotOptDebug'][_0x3d1e3e(0xd2)]=_0x52d864,window[_0x3d1e3e(0x9d)][_0x3d1e3e(0x8d)]=_0x3e8102,window['Amily2PlotOptDebug']['worldOpenClose']={'open':_0x2a4a38,'close':_0x55ca35};}catch(_0xa341bc){}console[_0x3d1e3e(0xc5)](_0x3d1e3e(0x88)+_0x3e8102+')'),console[_0x3d1e3e(0xb8)](_0x52d864),console[_0x3d1e3e(0x71)](),console[_0x3d1e3e(0x96)](_0x3d1e3e(0xb1),{'open':_0x2a4a38,'close':_0x55ca35}),console[_0x3d1e3e(0x81)](_0x3d1e3e(0x9b));}catch(_0x53ea81){console[_0x3d1e3e(0x81)](_0x3d1e3e(0x89),_0x53ea81);}}catch(_0x32c747){console[_0x3d1e3e(0x81)](_0x3d1e3e(0xf9),_0x32c747);}return toastr[_0x3d1e3e(0x81)]('EJS\x20预处理世界书失败已中止。',_0x3d1e3e(0xc1)),null;}}}}catch(_0x430e25){return console['error'](_0x3d1e3e(0x93),_0x430e25),toastr[_0x3d1e3e(0x81)](_0x3d1e3e(0xb7),'Amily2号'),null;}let _0x286b52='';if(_0x339ebe[_0x3d1e3e(0xe0)])try{const {convertTablesToCsvStringForContentOnly:_0x38d247}=await import(_0x3d1e3e(0xc8)),_0x2e5baf=_0x3d1e3e(0xe8),_0x441526=_0x38d247();_0x441526[_0x3d1e3e(0xac)]()&&(_0x286b52=_0x2e5baf['replace'](_0x3d1e3e(0x7b),_0x441526));}catch(_0x18c788){console[_0x3d1e3e(0x81)](_0x3d1e3e(0x7e),_0x18c788);}let _0x33f326='';const _0x55cf5d=_0x339ebe[_0x3d1e3e(0x73)]||0x0;if(_0x55cf5d>0x0&&_0x5c6909[_0x3d1e3e(0xbd)]>0x0){const _0x2e77c3=_0x5c6909[_0x3d1e3e(0x92)](-_0x55cf5d),_0x321d1c=_0x339ebe[_0x3d1e3e(0xa2)]??![],_0x5d4c61=_0x321d1c?(_0x339ebe[_0x3d1e3e(0x85)]||'')[_0x3d1e3e(0xa3)](',')[_0x3d1e3e(0xf3)](_0xa0cb49=>_0xa0cb49[_0x3d1e3e(0xac)]())[_0x3d1e3e(0x9e)](Boolean):[],_0x792d85=_0x339ebe[_0x3d1e3e(0x9f)]||[];_0x33f326=_0x2e77c3[_0x3d1e3e(0xf3)](_0x9ad018=>{const _0x11184d=_0x3d1e3e;if(_0x9ad018['mes']&&_0x9ad018['mes']['trim']()){let _0x106b1e=_0x9ad018['mes'][_0x11184d(0xac)]();if(_0x321d1c&&_0x5d4c61['length']>0x0){const _0x3235e1=extractBlocksByTags(_0x106b1e,_0x5d4c61);_0x3235e1[_0x11184d(0xbd)]>0x0&&(_0x106b1e=_0x3235e1[_0x11184d(0xe3)]('\x0a\x0a'));}return _0x106b1e=applyExclusionRules(_0x106b1e,_0x792d85),_0x106b1e?(_0x9ad018[_0x11184d(0xf6)]?_0x5a236b:_0x3e5336)+':\x20'+_0x106b1e:null;}return null;})[_0x3d1e3e(0x9e)](Boolean)[_0x3d1e3e(0xe3)]('\x0a');}const _0x121e17=getMixedOrder(_0x3d1e3e(0xdc))||[];let _0x2d983f=0x0;for(const _0x1f5263 of _0x121e17){if(_0x1f5263[_0x3d1e3e(0xce)]==='prompt')_0x4eb58f&&_0x4eb58f[_0x2d983f]&&(_0x2d8b9c[_0x3d1e3e(0x6f)](_0x4eb58f[_0x2d983f]),_0x2d983f++);else{if(_0x1f5263[_0x3d1e3e(0xce)]===_0x3d1e3e(0x99))switch(_0x1f5263['id']){case _0x3d1e3e(0xde):_0x4b36c7[_0x3d1e3e(0xac)]()&&_0x2d8b9c['push']({'role':'system','content':_0x4b36c7[_0x3d1e3e(0xac)]()});break;case _0x3d1e3e(0x77):_0x4a27c9['trim']()&&_0x2d8b9c['push']({'role':'system','content':_0x4a27c9[_0x3d1e3e(0xac)]()});break;case _0x3d1e3e(0xa0):_0x478a4a[_0x3d1e3e(0xac)]()&&_0x2d8b9c[_0x3d1e3e(0x6f)]({'role':_0x3d1e3e(0x94),'content':_0x3d1e3e(0xca)+_0x478a4a[_0x3d1e3e(0xac)]()+'</世界书内容>'});break;case'tableEnabled':_0x286b52&&_0x2d8b9c[_0x3d1e3e(0x6f)]({'role':_0x3d1e3e(0x94),'content':_0x286b52});break;case _0x3d1e3e(0xf4):_0x33f326&&_0x2d8b9c[_0x3d1e3e(0x6f)]({'role':_0x3d1e3e(0x94),'content':_0x3d1e3e(0x80)+_0x33f326+'\x0a</前文内容>'});break;case _0x3d1e3e(0x98):_0x2d8b9c[_0x3d1e3e(0x6f)]({'role':'user','content':_0x3d1e3e(0x8c)+_0xfe6926[_0x3d1e3e(0xb5)]});break;}}}console['groupCollapsed']('['+extensionName+']\x20发送给AI的最终请求内容'),console[_0x3d1e3e(0xae)](_0x2d8b9c),console[_0x3d1e3e(0x71)]();let _0x250a23='',_0x4452de=0x0;const _0x1e48b9=0x3;let _0x2c9a55=![];while(_0x4452de<_0x1e48b9&&!_0x2c9a55){if(_0x538852['isCancelled'])return console['log']('['+extensionName+_0x3d1e3e(0xeb)),null;_0x4452de++,console[_0x3d1e3e(0xb8)]('['+extensionName+_0x3d1e3e(0xb4)+_0x4452de+_0x3d1e3e(0xf1));const _0x16259c=_0x339ebe[_0x3d1e3e(0xa9)]?await callJqyhAI(_0x2d8b9c):await callAI(_0x2d8b9c,_0x3d1e3e(0xdc));if(_0x538852['isCancelled'])return console[_0x3d1e3e(0xb8)]('['+extensionName+_0x3d1e3e(0x72)),null;if(!_0x16259c){console[_0x3d1e3e(0x96)]('['+extensionName+']\x20第\x20'+_0x4452de+'\x20次尝试获取响应失败AI返回为空。');continue;}const _0x3ac684=extractContentByTag(_0x16259c,'plot'),_0x2c29e9=_0x3ac684?.['trim']()?_0x3ac684[_0x3d1e3e(0xac)]():_0x16259c['trim']();_0x2c29e9[_0x3d1e3e(0xbd)]>=0x64?(_0x250a23=_0x16259c,_0x2c9a55=!![],console[_0x3d1e3e(0xb8)]('['+extensionName+']\x20第\x20'+_0x4452de+_0x3d1e3e(0xb3)+_0x2c29e9[_0x3d1e3e(0xbd)]+')\x20符合要求。')):console[_0x3d1e3e(0x96)]('['+extensionName+_0x3d1e3e(0x9a)+_0x4452de+_0x3d1e3e(0xe7)+_0x2c29e9[_0x3d1e3e(0xbd)]+'小于100字符。');}if(!_0x2c9a55)return console['error']('['+extensionName+_0x3d1e3e(0xc4)+_0x1e48b9+_0x3d1e3e(0x97)),toastr['error'](_0x3d1e3e(0xe1)+_0x1e48b9+_0x3d1e3e(0xef),_0x3d1e3e(0xed)),null;console[_0x3d1e3e(0xc5)]('['+extensionName+_0x3d1e3e(0xfa)),console[_0x3d1e3e(0xb8)](_0x250a23),console[_0x3d1e3e(0x71)]();const _0x428912=extractContentByTag(_0x250a23,_0x3d1e3e(0xd5)),_0x184da3=_0x428912?.[_0x3d1e3e(0xac)]()?_0x428912[_0x3d1e3e(0xac)]():_0x250a23[_0x3d1e3e(0xac)]();if(_0x184da3){let _0x38d361='',_0x5e09a5=_0x339ebe['plotOpt_finalSystemDirective']?.[_0x3d1e3e(0xac)]()||'';const _0x3b86f1={'sulv1':_0x339ebe[_0x3d1e3e(0xdd)]??0x1,'sulv2':_0x339ebe['plotOpt_ratePersonal']??0x1,'sulv3':_0x339ebe['plotOpt_rateErotic']??0x1,'sulv4':_0x339ebe[_0x3d1e3e(0x8b)]??0x1};for(const _0x182a45 in _0x3b86f1){const _0x33de63=_0x3b86f1[_0x182a45],_0x1b46ae=new RegExp(_0x182a45[_0x3d1e3e(0xd4)](/[-\/\\^$*+?.()|[\]{}]/g,'\x5c$&'),'g');_0x5e09a5=_0x5e09a5[_0x3d1e3e(0xd4)](_0x1b46ae,_0x33de63);}return _0x5e09a5?_0x38d361=_0x5e09a5['replace'](_0x3d1e3e(0xc0),_0x184da3):_0x38d361=_0x184da3,{'contentToAppend':_0x38d361};}else return null;}catch(_0x192cd3){return console[_0x3d1e3e(0x81)]('['+extensionName+']\x20剧情优化任务发生严重错误:',_0x192cd3),toastr[_0x3d1e3e(0x81)](_0x3d1e3e(0xbc)+_0x192cd3[_0x3d1e3e(0xe9)],'严重错误'),null;}finally{console[_0x3d1e3e(0xba)](_0x3d1e3e(0x8f)),console[_0x3d1e3e(0x71)]();}}