@wujie-shell/core 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/wujie-shell.mjs +65 -0
- package/dist/bin/wujie-shell.mjs +1 -1
- package/dist/src/agents/bundled-agent-skills.mjs +1 -1
- package/dist/src/agents/bundled-agents.mjs +1 -1
- package/dist/src/chat/media-archive.mjs +1 -1
- package/dist/src/chat/queue.mjs +1 -1
- package/dist/src/common/diagnostics.mjs +1 -1
- package/dist/src/common/logging.mjs +1 -1
- package/dist/src/common/runtime-logger.mjs +1 -1
- package/dist/src/common/user-events.mjs +1 -1
- package/dist/src/common/utils.mjs +1 -1
- package/dist/src/config/controller.mjs +1 -1
- package/dist/src/connectors/config-utils.mjs +1 -1
- package/dist/src/connectors/constants.mjs +1 -1
- package/dist/src/connectors/controller.mjs +1 -1
- package/dist/src/connectors/kdocs-cli.mjs +1 -1
- package/dist/src/electron/main.mjs +1 -1
- package/dist/src/electron/preload.mjs +1 -1
- package/dist/src/files/generated-files-store.mjs +1 -1
- package/dist/src/files/handlers.mjs +1 -1
- package/dist/src/gateway/chat-delta.mjs +1 -0
- package/dist/src/gateway/controller.mjs +1 -1
- package/dist/src/gateway/ws-client.mjs +1 -1
- package/dist/src/index.mjs +1 -1
- package/dist/src/log-reporting/handlers.mjs +1 -1
- package/dist/src/log-reporting/report-logs.mjs +1 -1
- package/dist/src/models/handlers.mjs +1 -1
- package/dist/src/preferences/store.mjs +1 -1
- package/dist/src/runtime/index.mjs +1 -1
- package/dist/src/runtime/patch-channel-plugin-runtime.mjs +1 -1
- package/dist/src/runtime/patch-chat-history-mixed-tool-content.mjs +1 -1
- package/dist/src/runtime/patch-session-store-sqlite.mjs +1 -0
- package/dist/src/runtime/plugin-sync.mjs +1 -1
- package/dist/src/sessions/agent-sessions-map-store.mjs +1 -1
- package/dist/src/sessions/runtime-bridge.mjs +1 -0
- package/dist/src/sessions/session-sqlite-store.mjs +1 -0
- package/dist/src/sessions/sql/001_init.sql +120 -0
- package/dist/src/sessions/sql/002_session_local_metadata.sql +15 -0
- package/dist/src/sessions/sql/schema.md +115 -0
- package/dist/src/skills/import.mjs +1 -1
- package/dist/src/skills/market.mjs +1 -1
- package/dist/src/terminal/manager.mjs +1 -1
- package/dist/src/updates/controller.mjs +1 -0
- package/package.json +10 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(_0x3c3dfb,_0xcc6831){const _0x584285=_0x1b51,_0x3ac844=_0x3c3dfb();while(!![]){try{const _0x40a551=-parseInt(_0x584285(0xfc))/0x1*(-parseInt(_0x584285(0xfe))/0x2)+parseInt(_0x584285(0xe1))/0x3+parseInt(_0x584285(0xd8))/0x4+parseInt(_0x584285(0xe8))/0x5*(parseInt(_0x584285(0xe6))/0x6)+parseInt(_0x584285(0x107))/0x7*(parseInt(_0x584285(0xd3))/0x8)+parseInt(_0x584285(0x105))/0x9+parseInt(_0x584285(0xfb))/0xa*(-parseInt(_0x584285(0xfa))/0xb);if(_0x40a551===_0xcc6831)break;else _0x3ac844['push'](_0x3ac844['shift']());}catch(_0x4ef32b){_0x3ac844['push'](_0x3ac844['shift']());}}}(_0x2417,0x4b2ac));function createBridgeImport(_0xb0f849){const _0x1fe3a4=_0x1b51;return _0x1fe3a4(0x100)+_0x1fe3a4(0xdb)+_0x1fe3a4(0x104)+_0x1fe3a4(0x109)+'rom\x20\x22'+_0xb0f849+'\x22;';}function ensureBridgeImport(_0x4603b7,_0x5b39c7){const _0x47bffd=_0x1b51,_0x1b6ed5=createBridgeImport(_0x5b39c7);if(_0x4603b7[_0x47bffd(0xe9)](_0x1b6ed5))return _0x4603b7;const _0x45bffc=_0x4603b7[_0x47bffd(0xe2)](/^import .*;$/m);if(!_0x45bffc)return _0x1b6ed5+'\x0a'+_0x4603b7;return _0x4603b7['replace'](_0x45bffc[0x0],_0x45bffc[0x0]+'\x0a'+_0x1b6ed5);}function _0x2417(){const _0x1a888b=['not-foun','riteSess','t-provid','already-','378954cdAQXf','match','nction\x20w','\x20loadSes','s\x20=\x20{})','17526jsGbEH','-found','85dHhdQI','includes','orePath,','\x20opts);\x0a','function','length','sionBrid','e(storeP','sionStor','ic(param','{\x0a\x09retur','bridgeIm','bridge-i','n\x20await\x20','patched','-not-fou','body-not','arams)','11cOltBM','11297230dasOTn','18819gawCcO','SessionS','34vAyJmG','toreAtom','import\x20*','mport-no','essionSt','wujieSes','eSession','2155959dwfJCE','ge.loadS','3099131ZUBJHi','indexOf','Bridge\x20f','8DLuSIG','ath,\x20opt','portPath','slice','s);\x0a}','1037700noNDSj','ge.write','body-end','\x20as\x20wuji','n\x20wujieS'];_0x2417=function(){return _0x1a888b;};return _0x2417();}function findFunctionBodyStart(_0x5ec4a6,_0x13eb50){const _0x5c89da=_0x1b51,_0x41410a=_0x5ec4a6[_0x5c89da(0x108)]('(',_0x13eb50);if(_0x41410a===-0x1)return-0x1;let _0x1765cd=0x0,_0x1fa143=null,_0x5ccb98=![];for(let _0x401a3e=_0x41410a;_0x401a3e<_0x5ec4a6[_0x5c89da(0xed)];_0x401a3e+=0x1){const _0x2ab2af=_0x5ec4a6[_0x401a3e];if(_0x1fa143){if(_0x5ccb98){_0x5ccb98=![];continue;}if(_0x2ab2af==='\x5c'){_0x5ccb98=!![];continue;}if(_0x2ab2af===_0x1fa143)_0x1fa143=null;continue;}if(_0x2ab2af==='\x22'||_0x2ab2af==='\x27'||_0x2ab2af==='`'){_0x1fa143=_0x2ab2af;continue;}if(_0x2ab2af==='('){_0x1765cd+=0x1;continue;}if(_0x2ab2af===')'){_0x1765cd-=0x1;continue;}if(_0x2ab2af==='{'&&_0x1765cd===0x0)return _0x401a3e;}return-0x1;}function findMatchingBlockEnd(_0x54c193,_0xcd1b73){let _0x5b37a4=0x0,_0x22746c=null,_0x2d16be=![];for(let _0x5bd7e1=_0xcd1b73;_0x5bd7e1<_0x54c193['length'];_0x5bd7e1+=0x1){const _0x3e7fcf=_0x54c193[_0x5bd7e1];if(_0x22746c){if(_0x2d16be){_0x2d16be=![];continue;}if(_0x3e7fcf==='\x5c'){_0x2d16be=!![];continue;}if(_0x3e7fcf===_0x22746c)_0x22746c=null;continue;}if(_0x3e7fcf==='\x22'||_0x3e7fcf==='\x27'||_0x3e7fcf==='`'){_0x22746c=_0x3e7fcf;continue;}if(_0x3e7fcf==='{')_0x5b37a4+=0x1;if(_0x3e7fcf==='}')_0x5b37a4-=0x1;if(_0x5b37a4===0x0)return _0x5bd7e1+0x1;}return-0x1;}function findNextNonWhitespace(_0x7a72aa,_0x2b60a8){for(let _0x5bfc9e=_0x2b60a8;_0x5bfc9e<_0x7a72aa['length'];_0x5bfc9e+=0x1){if(!/\s/['test'](_0x7a72aa[_0x5bfc9e]))return _0x5bfc9e;}return-0x1;}function repairMalformedAlreadyPatchedFunction(_0x40307a,_0x474d2c){const _0x5e938a=_0x1b51,_0x4f740d=_0x40307a[_0x5e938a(0x108)](_0x474d2c);if(_0x4f740d===-0x1)return{'patched':![],'reason':_0x5e938a(0xdd)+'d'};const _0x4fcf21=findFunctionBodyStart(_0x40307a,_0x4f740d);if(_0x4fcf21===-0x1)return{'patched':![],'reason':_0x5e938a(0xf8)+_0x5e938a(0xe7)};const _0x300acd=findMatchingBlockEnd(_0x40307a,_0x4fcf21);if(_0x300acd===-0x1)return{'patched':![],'reason':_0x5e938a(0xda)+_0x5e938a(0xf7)+'nd'};const _0x306efe=findNextNonWhitespace(_0x40307a,_0x300acd);if(_0x40307a[_0x306efe]!==')')return{'patched':![],'reason':_0x5e938a(0xe0)+'patched'};const _0x293325=findNextNonWhitespace(_0x40307a,_0x306efe+0x1);if(_0x40307a[_0x293325]!=='{')return{'patched':![],'reason':_0x5e938a(0xe0)+_0x5e938a(0xf6)};const _0x5badf4=findMatchingBlockEnd(_0x40307a,_0x293325);if(_0x5badf4===-0x1)return{'patched':![],'reason':'body-end'+_0x5e938a(0xf7)+'nd'};return{'patched':!![],'source':_0x40307a[_0x5e938a(0xd6)](0x0,_0x300acd)+_0x40307a[_0x5e938a(0xd6)](_0x5badf4)};}function _0x1b51(_0x980b04,_0xf10d60){_0x980b04=_0x980b04-0xd3;const _0x2417e5=_0x2417();let _0x1b513b=_0x2417e5[_0x980b04];return _0x1b513b;}function replaceFunctionBody(_0x1ca992,_0x5b0c7f,_0x35884e){const _0x457c12=_0x1b51,_0x422ef2=_0x1ca992[_0x457c12(0x108)](_0x5b0c7f);if(_0x422ef2===-0x1)return{'patched':![],'reason':'not-foun'+'d'};const _0x12a4c2=findFunctionBodyStart(_0x1ca992,_0x422ef2);if(_0x12a4c2===-0x1)return{'patched':![],'reason':_0x457c12(0xf8)+_0x457c12(0xe7)};const _0x51fd5a=findMatchingBlockEnd(_0x1ca992,_0x12a4c2);if(_0x51fd5a===-0x1)return{'patched':![],'reason':_0x457c12(0xda)+_0x457c12(0xf7)+'nd'};const _0x5ac601=_0x5b0c7f+'\x20'+_0x35884e;return{'patched':!![],'source':_0x1ca992[_0x457c12(0xd6)](0x0,_0x422ef2)+_0x5ac601+_0x1ca992[_0x457c12(0xd6)](_0x51fd5a)};}export function patchSessionStoreLoadFromSource(_0x361000,_0x4ea438={}){const _0x389219=_0x1b51,_0xa6d965=_0x4ea438[_0x389219(0xf3)+_0x389219(0xd5)];if(!_0xa6d965)return{'patched':![],'reason':_0x389219(0xf4)+_0x389219(0x101)+_0x389219(0xdf)+'ed'};if(_0x361000[_0x389219(0xe9)](_0x389219(0x103)+'sionBrid'+_0x389219(0x106)+_0x389219(0x102)+'ore'))return repairMalformedAlreadyPatchedFunction(_0x361000,'function'+_0x389219(0xe4)+_0x389219(0xf0)+_0x389219(0xef)+_0x389219(0xd4)+_0x389219(0xe5));const _0x530a61=replaceFunctionBody(ensureBridgeImport(_0x361000,_0xa6d965),_0x389219(0xec)+_0x389219(0xe4)+_0x389219(0xf0)+_0x389219(0xef)+'ath,\x20opt'+_0x389219(0xe5),'{\x0a\x09retur'+_0x389219(0xdc)+'essionBr'+'idge.loa'+'dSession'+'Store(st'+_0x389219(0xea)+_0x389219(0xeb)+'}');return _0x530a61;}export function patchSessionStoreWriteFromSource(_0x5b7a8b,_0x56b85f={}){const _0x57bf6b=_0x1b51,_0x29a9ea=_0x56b85f[_0x57bf6b(0xf3)+'portPath'];if(!_0x29a9ea)return{'patched':![],'reason':_0x57bf6b(0xf4)+'mport-no'+_0x57bf6b(0xdf)+'ed'};const _0x42c205=replaceFunctionBody(ensureBridgeImport(_0x5b7a8b,_0x29a9ea),'async\x20fu'+_0x57bf6b(0xe3)+_0x57bf6b(0xde)+'ionStore'+'Atomic(p'+_0x57bf6b(0xf9),_0x57bf6b(0xf2)+_0x57bf6b(0xf5)+'wujieSes'+_0x57bf6b(0xee)+_0x57bf6b(0xd9)+_0x57bf6b(0xfd)+_0x57bf6b(0xff)+_0x57bf6b(0xf1)+_0x57bf6b(0xd7));if(!_0x42c205[_0x57bf6b(0xf6)])return _0x42c205;return _0x42c205;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x30c49a,_0x5a71c2){const _0x21243c=_0x4997,_0x2bb473=_0x30c49a();while(!![]){try{const _0x5af561=-parseInt(_0x21243c(0x1ec))/0x1*(-parseInt(_0x21243c(0x1f0))/0x2)+parseInt(_0x21243c(0x1f5))/0x3*(parseInt(_0x21243c(0x200))/0x4)+parseInt(_0x21243c(0x1ed))/0x5+parseInt(_0x21243c(0x1f4))/0x6+-parseInt(_0x21243c(0x1f9))/0x7+-parseInt(_0x21243c(0x1fe))/0x8*(-parseInt(_0x21243c(0x1f8))/0x9)+-parseInt(_0x21243c(0x1f2))/0xa;if(_0x5af561===_0x5a71c2)break;else _0x2bb473['push'](_0x2bb473['shift']());}catch(_0x56304d){_0x2bb473['push'](_0x2bb473['shift']());}}}(_0x1854,0x5dd04));function _0x4997(_0x29bf57,_0x4d2113){_0x29bf57=_0x29bf57-0x1eb;const _0x1854be=_0x1854();let _0x4997b6=_0x1854be[_0x29bf57];return _0x4997b6;}function _0x1854(){const _0x35def8=['filter','26xXTyQh','entries','21170630Fjqkrg','ByDefaul','108636wvWQnd','39cjeqaC','uginIdsB','legacyPl','5237667GZylLQ','311507IQVZhp','local','yPluginI','pluginId','enabled','8ArNPTV','allow','222372VuFrrR','keys','length','54559VJGRUZ','2568895vmElWC','includes'];_0x1854=function(){return _0x35def8;};return _0x1854();}import{asRecord,asStringArray,dedupeStrings,getTrimmedString}from'../common/utils.mjs';export function syncRuntimeManifestPlugins(_0x22b617,_0x600356,_0x273745={}){const _0xef0ec6=_0x4997,_0x3d79d2=new Set(_0x273745['disabled'+_0xef0ec6(0x1f3)+'tPluginI'+'ds']??[]),_0x9043a=asRecord(_0x273745[_0xef0ec6(0x1f7)+_0xef0ec6(0x1f6)+_0xef0ec6(0x1fb)+'d']),_0x22a4b5={...asRecord(_0x22b617)},_0x26233e={...asRecord(_0x22a4b5[_0xef0ec6(0x1f1)])},_0x5e0174={...asRecord(_0x22a4b5['installs'])};let _0x4e5bc7=asStringArray(_0x22a4b5['allow']),_0x18e480=![];for(const _0x32950f of _0x600356??[]){const _0x2a1885=getTrimmedString(_0x32950f[_0xef0ec6(0x1fc)]);if(!_0x2a1885)continue;const _0x5556b5=asStringArray(_0x9043a[_0x2a1885]);for(const _0xe52ef4 of _0x5556b5){_0xe52ef4 in _0x26233e&&(_0x26233e[_0x2a1885]={...asRecord(_0x26233e[_0x2a1885]),...asRecord(_0x26233e[_0xe52ef4])},delete _0x26233e[_0xe52ef4],_0x18e480=!![]);}if(_0x5556b5[_0xef0ec6(0x1eb)]>0x0){const _0x4fa4a8=_0x4e5bc7[_0xef0ec6(0x1ef)](_0x3d6206=>!_0x5556b5[_0xef0ec6(0x1ee)](_0x3d6206));_0x4fa4a8[_0xef0ec6(0x1eb)]!==_0x4e5bc7[_0xef0ec6(0x1eb)]&&(_0x4e5bc7=_0x4fa4a8,_0x18e480=!![]);}!(_0x2a1885 in _0x26233e)&&(_0x26233e[_0x2a1885]={'enabled':!_0x3d79d2['has'](_0x2a1885)},_0x18e480=!![]);if(asRecord(_0x26233e[_0x2a1885])[_0xef0ec6(0x1fd)]!==![]){const _0x3623c8=dedupeStrings([..._0x4e5bc7,_0x2a1885]);_0x3623c8[_0xef0ec6(0x1eb)]!==_0x4e5bc7['length']&&(_0x4e5bc7=_0x3623c8,_0x18e480=!![]);}getTrimmedString(_0x32950f['source'])===_0xef0ec6(0x1fa)&&_0x2a1885 in _0x5e0174&&(delete _0x5e0174[_0x2a1885],_0x18e480=!![]);}_0x22a4b5[_0xef0ec6(0x1f1)]=_0x26233e,_0x22a4b5[_0xef0ec6(0x1ff)]=_0x4e5bc7;if(Object[_0xef0ec6(0x201)](_0x5e0174)[_0xef0ec6(0x1eb)]>0x0)_0x22a4b5['installs']=_0x5e0174;else delete _0x22a4b5['installs'];return{'plugins':_0x22a4b5,'changed':_0x18e480};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const _0x2ef730=_0x2213;(function(_0x37acc8,_0x1dfc46){const _0x4901e3=_0x2213,_0x738e47=_0x37acc8();while(!![]){try{const _0x4d0e0e=parseInt(_0x4901e3(0xa2))/0x1+-parseInt(_0x4901e3(0xc7))/0x2*(-parseInt(_0x4901e3(0xc9))/0x3)+parseInt(_0x4901e3(0xd1))/0x4*(parseInt(_0x4901e3(0x9d))/0x5)+parseInt(_0x4901e3(0xd7))/0x6*(-parseInt(_0x4901e3(0xad))/0x7)+-parseInt(_0x4901e3(0xba))/0x8+parseInt(_0x4901e3(0xae))/0x9*(-parseInt(_0x4901e3(0xc6))/0xa)+parseInt(_0x4901e3(0xbc))/0xb*(parseInt(_0x4901e3(0xa3))/0xc);if(_0x4d0e0e===_0x1dfc46)break;else _0x738e47['push'](_0x738e47['shift']());}catch(_0x5d8989){_0x738e47['push'](_0x738e47['shift']());}}}(_0x4d0f,0x62ef5));function _0x4d0f(){const _0x2856c4=['cutoffTe','role','readSess','3038488xoXGiP','assistan','9583871WFDKzP','agent','ey\x20is\x20re','onsMap','sessionK','content','isArray','agents','uired','ile','50MVlzoc','237898FPjiQg','sessionI','3ahrGYT','_INFINIT','number','lTs','join','includes','quired','sessionF','299516YIndLB','slice','.jsonl','pop','keepUnti','session','122826vtDvcr','d\x20is\x20req','string','message','cutoffRo','parse','agentId','push','isFinite','30CygibC','keys','length','main','type','120268UFzpZR','12xSAUkB','user','timestam','ionEntry','text','label','utf8','getSessi','has','map','203oBGYUM','325881maNzHe','upsertSe','entries','trim','ssionEnt','split','POSITIVE','filter','sessions'];_0x4d0f=function(){return _0x2856c4;};return _0x4d0f();}import{existsSync}from'node:fs';import{copyFile,mkdir,readFile,writeFile}from'node:fs/promises';import{dirname,extname,join}from'node:path';import{asRecord}from'../common/utils.mjs';import{createSessionSqliteStore}from'./session-sqlite-store.mjs';const CLONED_AGENT_SESSION_EXCLUDED_FIELDS=new Set([_0x2ef730(0xc0)+'ey','sessionI'+'d',_0x2ef730(0xa8),'sessionF'+_0x2ef730(0xc5)]);function extractAgentIdFromSessionKey(_0x35f02c){const _0x2324f6=_0x2ef730,_0x29b5e0=String(_0x35f02c||'')['split'](':'),_0x4f20ad=_0x29b5e0[0x1]?.[_0x2324f6(0xb1)]();return _0x4f20ad||_0x2324f6(0xa0);}function _0x2213(_0x56dc2e,_0xf43934){_0x56dc2e=_0x56dc2e-0x9a;const _0x4d0ff8=_0x4d0f();let _0x22139e=_0x4d0ff8[_0x56dc2e];return _0x22139e;}function resolveNewSessionFilePath(_0x50a77a,_0xe2fc51,_0xd2bc94,_0x54659c,_0x3e48aa){const _0x102f64=_0x2ef730,_0x4941d7=typeof _0xe2fc51[_0x102f64(0xd0)+_0x102f64(0xc5)]===_0x102f64(0xd9)?_0xe2fc51[_0x102f64(0xd0)+_0x102f64(0xc5)][_0x102f64(0xb1)]():'';if(_0x4941d7)return _0x4941d7;const _0x489f23=_0xd2bc94&&typeof _0xd2bc94['sessionF'+_0x102f64(0xc5)]==='string'?extname(_0xd2bc94[_0x102f64(0xd0)+'ile']['trim']()):'';return join(_0x50a77a,_0x102f64(0xc3),_0x3e48aa,_0x102f64(0xb6),''+_0x54659c+(_0x489f23||_0x102f64(0xd3)));}function cloneForkedSessionExtraFields(_0x4b06f6){const _0x39ebcc=_0x2ef730;if(!_0x4b06f6)return{};const _0x51ef2c={};for(const [_0x2ed64a,_0x2aba0a]of Object[_0x39ebcc(0xb0)](_0x4b06f6)){if(CLONED_AGENT_SESSION_EXCLUDED_FIELDS[_0x39ebcc(0xab)](_0x2ed64a))continue;_0x51ef2c[_0x2ed64a]=_0x2aba0a;}return _0x51ef2c;}async function copySessionFileIfNeeded(_0x2ddfb4,_0x15291d){const _0x10deb6=_0x2ef730;if(!_0x2ddfb4||!_0x15291d)return;const _0x225c5a=typeof _0x2ddfb4[_0x10deb6(0xd0)+_0x10deb6(0xc5)]==='string'?_0x2ddfb4[_0x10deb6(0xd0)+_0x10deb6(0xc5)][_0x10deb6(0xb1)]():'',_0x11d557=String(_0x15291d||'')[_0x10deb6(0xb1)]();if(!_0x225c5a||!_0x11d557||_0x225c5a===_0x11d557)return;if(!existsSync(_0x225c5a))return;await mkdir(dirname(_0x11d557),{'recursive':!![]}),await copyFile(_0x225c5a,_0x11d557);}function extractMessageEntryText(_0x3c3832){const _0x1f0446=_0x2ef730,_0x2778ef=asRecord(_0x3c3832[_0x1f0446(0xda)]),_0x4f1f4a=_0x2778ef[_0x1f0446(0xc1)];if(typeof _0x4f1f4a==='string')return _0x4f1f4a;if(!Array[_0x1f0446(0xc2)](_0x4f1f4a))return'';return _0x4f1f4a[_0x1f0446(0xac)](_0x25409a=>{const _0x30e490=_0x1f0446,_0x1f7df3=asRecord(_0x25409a);return _0x1f7df3['type']===_0x30e490(0xa7)&&typeof _0x1f7df3[_0x30e490(0xa7)]===_0x30e490(0xd9)?_0x1f7df3[_0x30e490(0xa7)]:'';})[_0x1f0446(0xb5)](Boolean)[_0x1f0446(0xcd)]('\x0a');}function extractMessageEntryRole(_0x1143b8){const _0x3e36e2=_0x2ef730,_0x4a073c=asRecord(_0x1143b8[_0x3e36e2(0xda)]);if(typeof _0x4a073c[_0x3e36e2(0xb8)]===_0x3e36e2(0xd9))return _0x4a073c['role'];if(typeof _0x1143b8[_0x3e36e2(0xb8)]===_0x3e36e2(0xd9))return _0x1143b8['role'];return'';}function parseJsonLine(_0xb72fe0){try{const _0x2adbb1=JSON['parse'](_0xb72fe0);return asRecord(_0x2adbb1);}catch{return null;}}function entryTimestampMs(_0x3f800e){const _0x2817f3=_0x2ef730,_0x17f7cf=_0x3f800e[_0x2817f3(0xa5)+'p'];if(typeof _0x17f7cf===_0x2817f3(0xd9)){const _0x3c8cd6=Date[_0x2817f3(0xdc)](_0x17f7cf);return Number['isFinite'](_0x3c8cd6)?_0x3c8cd6:null;}if(typeof _0x17f7cf==='number'&&Number[_0x2817f3(0x9c)](_0x17f7cf))return _0x17f7cf;return null;}async function trimSessionFileForFork(_0x48ac93,_0x52f367){const _0x500361=_0x2ef730;if(!_0x48ac93||!existsSync(_0x48ac93))return;const {keepUntilTs:_0x2b4364,cutoffRole:_0xcc263b,cutoffText:_0x2a3fa6}=_0x52f367,_0xe1bf5e=typeof _0x2b4364===_0x500361(0xcb)&&Number[_0x500361(0x9c)](_0x2b4364),_0xff70d3=typeof _0x2a3fa6===_0x500361(0xd9)?_0x2a3fa6[_0x500361(0xb1)]():'',_0xd9a9e6=_0xcc263b===_0x500361(0xbd)?_0x500361(0xbb)+'t':_0xcc263b===_0x500361(0xa4)?_0x500361(0xa4):'',_0x1c8013=Boolean(_0xd9a9e6&&_0xff70d3);if(!_0xe1bf5e&&!_0x1c8013)return;let _0x12d6a3='';try{_0x12d6a3=await readFile(_0x48ac93,_0x500361(0xa9));}catch{return;}const _0x385737=_0x12d6a3[_0x500361(0xb3)]('\x0a');let _0x72379=-0x1;const _0x4e88d6=_0xe1bf5e?_0x2b4364+0xa*0x3c*0x3e8:Number[_0x500361(0xb4)+_0x500361(0xca)+'Y'];if(_0x1c8013)for(let _0x5cb695=0x0;_0x5cb695<_0x385737[_0x500361(0x9f)];_0x5cb695+=0x1){const _0x34afcc=_0x385737[_0x5cb695][_0x500361(0xb1)]();if(!_0x34afcc)continue;const _0x24cfab=parseJsonLine(_0x34afcc);if(!_0x24cfab||_0x24cfab[_0x500361(0xa1)]!=='message')continue;if(extractMessageEntryRole(_0x24cfab)!==_0xd9a9e6)continue;const _0x28f77f=extractMessageEntryText(_0x24cfab)[_0x500361(0xb1)]();if(!_0x28f77f||!_0x28f77f[_0x500361(0xce)](_0xff70d3))continue;const _0x2c342c=entryTimestampMs(_0x24cfab);if(_0x2c342c!==null&&_0x2c342c>_0x4e88d6)continue;_0x72379=_0x5cb695;}let _0xb35a70=[];if(_0x72379>=0x0)_0xb35a70=_0x385737[_0x500361(0xd2)](0x0,_0x72379+0x1);else{if(_0xe1bf5e)for(const _0x5c07f3 of _0x385737){const _0x72d89a=_0x5c07f3[_0x500361(0xb1)]();if(!_0x72d89a)continue;const _0x4143c2=parseJsonLine(_0x72d89a);if(!_0x4143c2){_0xb35a70[_0x500361(0x9b)](_0x5c07f3);continue;}if(_0x4143c2['type']===_0x500361(0xd6)){_0xb35a70[_0x500361(0x9b)](_0x5c07f3);continue;}const _0x5d0a30=entryTimestampMs(_0x4143c2);if(_0x5d0a30===null||_0x5d0a30<=_0x2b4364)_0xb35a70[_0x500361(0x9b)](_0x5c07f3);}}while(_0xb35a70[_0x500361(0x9f)]>0x0&&_0xb35a70[_0xb35a70[_0x500361(0x9f)]-0x1]['trim']()==='')_0xb35a70[_0x500361(0xd4)]();await writeFile(_0x48ac93,_0xb35a70[_0x500361(0xcd)]('\x0a')+'\x0a',_0x500361(0xa9));}export function createAgentSessionsMapStore({stateDir:_0x18df20}){const _0xdac797=createSessionSqliteStore({'stateDir':_0x18df20});async function _0x2090f6(_0x4bd027={}){const _0x4344c9=_0x2213,_0x3b92c9=String(_0x4bd027[_0x4344c9(0x9a)]||_0x4344c9(0xa0));return await _0xdac797[_0x4344c9(0xaa)+_0x4344c9(0xbf)](_0x3b92c9);}async function _0x3d8c3b(_0x15e85c={}){const _0x11a8d6=_0x2213,_0x184d46=String(_0x15e85c['sessionK'+'ey']||'')[_0x11a8d6(0xb1)](),_0x3ab3dc=String(_0x15e85c[_0x11a8d6(0xc8)+'d']||'')[_0x11a8d6(0xb1)]();if(!_0x184d46)throw new Error('sessionK'+_0x11a8d6(0xbe)+_0x11a8d6(0xcf));if(!_0x3ab3dc)throw new Error(_0x11a8d6(0xc8)+_0x11a8d6(0xd8)+_0x11a8d6(0xc4));const _0x2effe1=extractAgentIdFromSessionKey(_0x184d46),_0x460058=asRecord(await _0xdac797['readSess'+'ionEntry'](_0x184d46)),_0x6d4ee1=String(_0x15e85c['sourceSe'+'ssionKey']||'')[_0x11a8d6(0xb1)](),_0x315221=_0x6d4ee1?extractAgentIdFromSessionKey(_0x6d4ee1):_0x2effe1,_0x4570cc=_0x6d4ee1?asRecord(await _0xdac797[_0x11a8d6(0xb9)+_0x11a8d6(0xa6)](_0x6d4ee1)):null,_0x54668d=_0x4570cc&&Object[_0x11a8d6(0x9e)](_0x4570cc)['length']>0x0,_0x1603bb=resolveNewSessionFilePath(_0x18df20,_0x460058,_0x54668d?_0x4570cc:null,_0x3ab3dc,_0x2effe1),_0x20fedb=typeof _0x15e85c[_0x11a8d6(0xd5)+_0x11a8d6(0xcc)]===_0x11a8d6(0xcb)&&Number['isFinite'](_0x15e85c[_0x11a8d6(0xd5)+_0x11a8d6(0xcc)])?_0x15e85c[_0x11a8d6(0xd5)+_0x11a8d6(0xcc)]:null,_0x3fa7ce=typeof _0x15e85c['cutoffRo'+'le']===_0x11a8d6(0xd9)?_0x15e85c[_0x11a8d6(0xdb)+'le']:null,_0x3486f9=typeof _0x15e85c['cutoffTe'+'xt']==='string'?_0x15e85c[_0x11a8d6(0xb7)+'xt']:null,_0x3ef207={..._0x460058,...cloneForkedSessionExtraFields(_0x54668d?_0x4570cc:null),'agentId':_0x2effe1,'sessionKey':_0x184d46,'sessionId':_0x3ab3dc,'sessionFile':_0x1603bb,..._0x54668d?{'forkedFromParent':!![]}:{}};return await copySessionFileIfNeeded(_0x54668d?_0x4570cc:null,_0x1603bb),_0x54668d&&(_0x20fedb!==null||_0x3fa7ce&&_0x3486f9)&&await trimSessionFileForFork(_0x1603bb,{'keepUntilTs':_0x20fedb,'cutoffRole':_0x3fa7ce,'cutoffText':_0x3486f9}),await _0xdac797[_0x11a8d6(0xaf)+_0x11a8d6(0xb2)+'ry']({'agentId':_0x2effe1,'sessionKey':_0x184d46,'entry':_0x3ef207}),await _0xdac797[_0x11a8d6(0xaa)+_0x11a8d6(0xbf)](_0x2effe1);}return{'get':_0x2090f6,'upsert':_0x3d8c3b};}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(_0x536621,_0x5c9a5b){const _0x131329=_0x459e,_0xf311ea=_0x536621();while(!![]){try{const _0x491a14=-parseInt(_0x131329(0x1a9))/0x1+parseInt(_0x131329(0x1a3))/0x2+-parseInt(_0x131329(0x1b2))/0x3+parseInt(_0x131329(0x198))/0x4+parseInt(_0x131329(0x197))/0x5+parseInt(_0x131329(0x1a2))/0x6*(parseInt(_0x131329(0x1ab))/0x7)+-parseInt(_0x131329(0x1a4))/0x8;if(_0x491a14===_0x5c9a5b)break;else _0xf311ea['push'](_0xf311ea['shift']());}catch(_0x4d6ec5){_0xf311ea['push'](_0xf311ea['shift']());}}}(_0x50f8,0xf2f3b));import{join}from'node:path';function _0x459e(_0x2d0b91,_0x21169a){_0x2d0b91=_0x2d0b91-0x192;const _0x50f81d=_0x50f8();let _0x459e94=_0x50f81d[_0x2d0b91];return _0x459e94;}import{createSessionSqliteStore}from'./session-sqlite-store.mjs';function _0x50f8(){const _0x5a8e9c=['3957036uVdAwf','parse','/session','storePat','ync','indexOf','get','saveSess','index.sq','slice','3852174fmptyz','2978000gLqsuy','9653008qVjxGc','tch','stringif','ionStore','split','1700259MbjZgM','updateSe','7Mrehek','values','set','lite','reEntry','clear','close','385956xTanyQ','ssionSto','eEntryPa','eAtomic','/agents/','clone','writeSes','4551900GgIIdh'];_0x50f8=function(){return _0x5a8e9c;};return _0x50f8();}const BRIDGE_STORE_CACHE=new Map();function resolveStateDirFromStorePath(_0x395a6a){const _0x4bf059=_0x459e,_0x4d1dce=String(_0x395a6a||'')['replaceA'+'ll']('\x5c','/'),_0xadd824=_0x4bf059(0x194),_0x2c7c13=_0x4d1dce[_0x4bf059(0x19d)](_0xadd824);if(_0x2c7c13<0x0){const _0x1ccf75=_0x4d1dce[_0x4bf059(0x1a8)](_0x4bf059(0x19a)+'s/')[0x0];return _0x1ccf75||_0x4d1dce;}return _0x4d1dce[_0x4bf059(0x1a1)](0x0,_0x2c7c13);}function createBridgeStore(_0x13951e){const _0x14738b=_0x459e,_0x181b7f=resolveStateDirFromStorePath(_0x13951e),_0x477bc5=join(_0x181b7f,'sessions',_0x14738b(0x1a0)+_0x14738b(0x1ae)),_0x36f25b=_0x181b7f+'::'+_0x477bc5,_0x1a3e89=BRIDGE_STORE_CACHE[_0x14738b(0x19e)](_0x36f25b);if(_0x1a3e89)return _0x1a3e89;const _0x413ea2=createSessionSqliteStore({'stateDir':_0x181b7f,'dbPath':_0x477bc5});return BRIDGE_STORE_CACHE[_0x14738b(0x1ad)](_0x36f25b,_0x413ea2),_0x413ea2;}function cloneStoreObject(_0x359c98){const _0x6ccec8=_0x459e;return JSON[_0x6ccec8(0x199)](JSON[_0x6ccec8(0x1a6)+'y'](_0x359c98||{}));}export function loadSessionStore(_0x498afc,_0x154527={}){const _0x10c67c=_0x459e,_0x4236ec=createBridgeStore(_0x498afc),_0x3bc98c=_0x4236ec['readStor'+'eByPathS'+_0x10c67c(0x19c)](_0x498afc);return _0x154527[_0x10c67c(0x195)]===![]?_0x3bc98c:cloneStoreObject(_0x3bc98c);}export async function saveSessionStore(_0x335683,_0x4ee1fb){const _0x590563=_0x459e,_0x4f560e=createBridgeStore(_0x335683);return await _0x4f560e[_0x590563(0x19f)+_0x590563(0x1a7)](_0x335683,_0x4ee1fb);}export async function updateSessionStore(_0x116f46,_0x269e1c,_0x575dd1){const _0x336a08=_0x459e,_0x2301c0=createBridgeStore(_0x116f46);return await _0x2301c0[_0x336a08(0x1aa)+_0x336a08(0x1b3)+'re'](_0x116f46,_0x269e1c,_0x575dd1);}export async function updateSessionStoreEntry(_0x33a838){const _0x336e37=_0x459e,_0x4b8eca=createBridgeStore(_0x33a838[_0x336e37(0x19b)+'h']);return await _0x4b8eca['updateSe'+_0x336e37(0x1b3)+_0x336e37(0x1af)](_0x33a838);}export async function applySessionStoreEntryPatch(_0x459b66){const _0xe13b51=_0x459e,_0x33197b=createBridgeStore(_0x459b66[_0xe13b51(0x19b)+'h']);return await _0x33197b['applySes'+'sionStor'+_0xe13b51(0x192)+_0xe13b51(0x1a5)](_0x459b66);}export async function writeSessionStoreAtomic(_0x426b68){const _0x4e8162=_0x459e,_0x4f1ec2=createBridgeStore(_0x426b68['storePat'+'h']);return await _0x4f1ec2[_0x4e8162(0x196)+'sionStor'+_0x4e8162(0x193)](_0x426b68);}export async function closeBridgeStores(){const _0x5ed4fd=_0x459e,_0xe60091=[...BRIDGE_STORE_CACHE[_0x5ed4fd(0x1ac)]()];BRIDGE_STORE_CACHE[_0x5ed4fd(0x1b0)](),await Promise['all'](_0xe60091['map'](_0x260f0b=>_0x260f0b[_0x5ed4fd(0x1b1)]()));}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _0xe09ee2=_0x4ed3;(function(_0x335962,_0x5e4781){const _0x7e0812=_0x4ed3,_0x4f8197=_0x335962();while(!![]){try{const _0x1a9f34=-parseInt(_0x7e0812(0x302))/0x1*(parseInt(_0x7e0812(0x112))/0x2)+parseInt(_0x7e0812(0x24e))/0x3+-parseInt(_0x7e0812(0x387))/0x4*(-parseInt(_0x7e0812(0x183))/0x5)+-parseInt(_0x7e0812(0x18c))/0x6*(parseInt(_0x7e0812(0x339))/0x7)+parseInt(_0x7e0812(0x2c2))/0x8*(-parseInt(_0x7e0812(0x37b))/0x9)+-parseInt(_0x7e0812(0x1f9))/0xa+parseInt(_0x7e0812(0x1ef))/0xb;if(_0x1a9f34===_0x5e4781)break;else _0x4f8197['push'](_0x4f8197['shift']());}catch(_0x3eec3b){_0x4f8197['push'](_0x4f8197['shift']());}}}(_0x16b5,0x50f18));import{existsSync,mkdirSync,readFileSync,readdirSync,statSync,utimesSync,writeFileSync}from'node:fs';import{mkdir,stat,writeFile}from'node:fs/promises';import{basename,join,dirname}from'node:path';import{fileURLToPath}from'node:url';import{DatabaseSync}from'node:sqlite';import{createHash,randomUUID}from'node:crypto';import{asRecord}from'../common/utils.mjs';const SESSION_STORE_DIR=_0xe09ee2(0x179),SESSION_STORE_DB_FILE=_0xe09ee2(0x2cb)+'lite',MIGRATIONS_DIR=fileURLToPath(new URL(_0xe09ee2(0x1bb),import.meta.url)),CORE_FIELD_SPECS=[[_0xe09ee2(0x2ac)+'d','session_'+'id','text'],[_0xe09ee2(0x1f5),'label','text'],['sessionF'+_0xe09ee2(0x2d9),_0xe09ee2(0x188)+_0xe09ee2(0x162),'text'],[_0xe09ee2(0x223)+'t',_0xe09ee2(0x202)+'at','number'],[_0xe09ee2(0x174)+'tartedAt',_0xe09ee2(0x188)+_0xe09ee2(0x171)+'at','number'],[_0xe09ee2(0x257)+'ractionA'+'t',_0xe09ee2(0x2cc)+_0xe09ee2(0x264)+'_at','number'],[_0xe09ee2(0x392)+'nt','system_s'+'ent','boolean'],[_0xe09ee2(0x238)+_0xe09ee2(0x300),_0xe09ee2(0x1a1)+_0xe09ee2(0x31d),'boolean'],[_0xe09ee2(0x114),_0xe09ee2(0x2e0)+'e',_0xe09ee2(0x1e8)],[_0xe09ee2(0x1f0)+_0xe09ee2(0x3a9),'last_cha'+_0xe09ee2(0x11b),_0xe09ee2(0x1e8)],['status',_0xe09ee2(0x2aa),_0xe09ee2(0x1e8)],[_0xe09ee2(0x268)+'t',_0xe09ee2(0x171)+'at',_0xe09ee2(0x371)],[_0xe09ee2(0x37f),_0xe09ee2(0x125),'number'],[_0xe09ee2(0x20e)+'s',_0xe09ee2(0x2ba)+'ms',_0xe09ee2(0x371)],['modelPro'+_0xe09ee2(0x26a),_0xe09ee2(0x305)+_0xe09ee2(0x34d),'text'],[_0xe09ee2(0x25a),_0xe09ee2(0x25a),_0xe09ee2(0x1e8)],[_0xe09ee2(0x148)+_0xe09ee2(0x3d8),_0xe09ee2(0x1a2)+_0xe09ee2(0x27f),_0xe09ee2(0x371)],[_0xe09ee2(0x2d6)+_0xe09ee2(0x2fa),_0xe09ee2(0x329)+_0xe09ee2(0x16b),_0xe09ee2(0x371)],[_0xe09ee2(0x375)+_0xe09ee2(0x16b),_0xe09ee2(0x2c9)+'okens',_0xe09ee2(0x371)],[_0xe09ee2(0x330)+'d','cache_re'+'ad',_0xe09ee2(0x371)],[_0xe09ee2(0x2dc)+'te','cache_wr'+_0xe09ee2(0x2ca),_0xe09ee2(0x371)],[_0xe09ee2(0x3ab)+_0xe09ee2(0x34c),_0xe09ee2(0x3ab)+_0xe09ee2(0x3a6)+'sd','number'],[_0xe09ee2(0x364)+_0xe09ee2(0x2fa),_0xe09ee2(0x3a8)+_0xe09ee2(0x16b),_0xe09ee2(0x371)],[_0xe09ee2(0x364)+_0xe09ee2(0x3dc),'total_to'+_0xe09ee2(0x3af)+'sh','number']],CORE_FIELD_NAMES=new Set(CORE_FIELD_SPECS[_0xe09ee2(0x35c)](([_0x5d8614])=>_0x5d8614)),SQL_BOOLEAN_TRUE=0x1,SQL_BOOLEAN_FALSE=0x0,SESSION_STORE_TTL_MS=0xafc8,SESSION_STORE_PROMPT_BLOB_DIR=_0xe09ee2(0x18d)+'rompts',SESSION_STORE_PROMPT_BLOB_ALGORITHM=_0xe09ee2(0x170),SESSION_STORE_PROMPT_BLOB_VERSION=0x1,SESSION_STORE_PROMPT_REF_CACHE_MAX_ENTRIES=0x100,SESSION_STORE_VALID_PROMPT_BLOB_CACHE_MAX_ENTRIES=0x100,SESSION_STORE_MIN_PROMPT_BLOB_CHARS=0x200,SESSION_STORE_MAX_PROMPT_BLOB_BYTES=0x200*0x400,PROMPT_REF_CACHE=new Map(),VALID_PROMPT_BLOB_CACHE=new Map(),STORE_WRITE_QUEUES=new Map(),STORE_CACHE=new Map();function storeDbPath(_0x1c2ddf){return join(_0x1c2ddf,SESSION_STORE_DIR,SESSION_STORE_DB_FILE);}function normalizeNumber(_0x4c0c2f){const _0x3e95ae=_0xe09ee2;if(typeof _0x4c0c2f!==_0x3e95ae(0x371)||!Number[_0x3e95ae(0x3d9)](_0x4c0c2f))return null;return _0x4c0c2f;}function normalizeBoolean(_0xedc9c1){if(_0xedc9c1===!![])return!![];if(_0xedc9c1===![])return![];return null;}function toSqliteBoolean(_0x136243){return _0x136243===!![]?SQL_BOOLEAN_TRUE:SQL_BOOLEAN_FALSE;}function _0x16b5(){const _0x3438eb=['tal_toke','y\x20=\x20?','HERE\x20ses','\x20UNIQUE,','\x20\x20\x20\x20@cac','L\x20DEFAUL','\x20IN\x20(','ES\x20(?)\x0a\x20','\x20\x20\x20\x20\x20cus','@status,','ype\x20=\x20ex','l_tokens','ns,\x0a\x20\x20\x20\x20','re_legac','updatedA','record_i','S\x20(?,\x20?,','\x20\x20\x20\x20\x20\x20ca','exec','_metadat','?,\x20CURRE','isDirect','get','d.sessio','-topic-','ode_key,','\x20\x20status','id\x20=\x20exc','\x20\x20\x20\x20\x20\x20\x20s','(version','gent_id\x20','odes\x0a\x20\x20\x20','\x20\x20\x20)\x0a\x20\x20\x20','_path\x20=\x20','\x20\x20\x20\x20tota','abortedL','ted_last','\x20SELECT\x20','etadata\x20','BEGIN\x20IM','sion_rec','\x20\x20WHERE\x20','d_sessio','ections\x20','prompt','d\x20DESC\x0a\x20','\x20runtime','entries','?,\x20?,\x20?)','t_channe','update','y)\x20DO\x20UP','\x20\x20\x20\x20\x20\x20se','\x20\x20AND\x20se','oreign_k','tartedAt','\x20\x20\x20\x20\x20\x20@l','398718qgmeQd','ted_cost','sion_loc',')\x0a\x20\x20\x20\x20\x20\x20','not\x20foun','mpare','edKey','\x0a\x20\x20\x20\x20\x20\x20\x20','0,\x0a\x20\x20\x20\x20\x20','lastInte','\x20\x20\x20\x20\x20\x20\x20T','string','model','n_file,\x0a','ms,\x0a\x20\x20\x20\x20','rent_nod','(\x0a\x20\x20\x20\x20\x20\x20','ey\x20is\x20re','\x20\x20\x20\x20\x20)\x0a\x20','ion_key,','\x20estimat','n_store_','eraction','\x20ASC','skipSave','e,\x0a\x20\x20\x20\x20\x20','startedA','forEach','vider','hasOwn','\x20\x20contex','then','_order\x20A','_ms,\x0a\x20\x20\x20','\x20\x20update',',\x20node_k','\x0a\x20\x20\x20\x20INS','inned\x20=\x20','quired','key,\x20cus','MP)\x0a\x20\x20\x20\x20','\x20\x20\x20ON\x20CO','OM\x20sessi','tion_id\x20','_local_m','name','\x20CURRENT','ind\x0a\x20\x20\x20\x20','ection_i','tokens','ction_at','ay_index','E\x0a\x20\x20\x20\x20\x20\x20','\x20\x20\x20custo','on\x20TEXT\x20','order\x20=\x20','y\x20=\x20?\x0a\x20\x20','sessionK','S\x20sessio','ey\x20FROM\x20','\x20=\x20CASE\x0a','node_key','has','\x20\x20\x20\x20\x20\x20@e','d_at,\x0a\x20\x20','L,\x0a\x20\x20\x20\x20\x20','hash','t_node_i','section_','\x20\x20\x20UPDAT','\x20\x20\x20\x20\x20\x20\x20@','\x20\x20\x20versi','nt,\x0a\x20\x20\x20\x20','includes','trim','=\x20?\x0a\x20\x20\x20\x20','stom_nam','ession_f','R\x20BY\x20upd','ut_token','.jsonl','ession_r','UES\x20(?,\x20','sort','ynchrono','migratio','some',',\x20pinned','olean_va','tput_tok','\x0a\x20\x20\x20\x20','ion_reco','status','bytes','sessionI','d_at\x0a\x20\x20\x20','\x20@runtim','_sent,\x0a\x20','rds\x20WHER','records\x0a','xOf','t\x20=\x20CURR','min','\x20\x20VALUES','\x20\x20\x20\x20inpu','close','ey)\x20DO\x20U','tion_nod','runtime_','dex,\x0a\x20\x20\x20','usd,\x0a\x20\x20\x20','vider,\x0a\x20','TAMP)\x0a\x20\x20','es\x20(\x0a\x20\x20\x20','digest','?\x0a\x20\x20\x20\x20\x20\x20','2408mToqjo','tion_nam','system_s','key,\x0a\x20\x20\x20',':group:','KEY\x20AUTO','der','output_t','ite','index.sq','last_int','interact','_INTEGER','sh\x0a\x20\x20\x20\x20\x20','ersion\x20F','otal_tok','st_usd\x20=','ue,\x0a\x20\x20\x20\x20','ection_k','\x20\x20\x20\x20\x20@la','inputTok','\x20\x20\x20\x20\x20\x20nu','ON\x20CONFL','ile','e\x20=\x20\x27\x27\x0a\x20','\x20\x20\x20\x20\x20\x20WH','cacheWri','IMESTAMP','OT\x20EXIST','\x20\x20sessio','chat_typ','\x20(?,\x201,\x20','t_intera','threadId','ent_id\x20=','T_TIMEST','tokens_f','ded.cust','PRIMARY\x20','\x20\x20\x20\x20\x20\x20OR','ated_at\x0a','ICT(sess','_fresh\x20=','\x20\x20@abort','T\x20INTO\x20s','\x20ORDER\x20B','d:\x20','_write,\x0a','status\x20=','REATE\x20TA','node_id,','tion_at\x20',':thread:','\x20WHERE\x20a','ated_at\x20','parent_n','ens','sessionF','BLE\x20IF\x20N','boolean_','m_name\x0a\x20','E\x20sessio','astRun','HERE\x20age','14390ckQVxB','odel_pro','ider,\x0a\x20\x20','model_pr','excluded','d.status','adId','boolean','ted_at\x20D','RE\x20sessi','null','\x20\x20estima','RRENT_TI','metadata','ad,\x0a\x20\x20\x20\x20','er\x20=\x20exc','_at\x20=\x20CU','.pinned_','\x20INSERT\x20','ed_at,\x0a\x20','\x20\x20\x20conte','WHEN\x20ses','n_file\x20=','he_read,','every','LSE\x20sess','dated_at','last_run','run','now','\x20\x20\x20\x20\x20tot','\x20?,\x20?,\x20?','e_ms\x20=\x20e','length','\x0a\x20\x20\x20\x20\x20\x20s','an_value','ERT\x20INTO','tom_name','ion_node','input_to','om_name,','a\x0a\x20\x20\x20\x20\x20\x20','\x20\x20\x20\x20\x20\x20so','hat_type','le,\x0a\x20\x20\x20\x20','id\x20IN\x20(\x0a','cacheRea','\x20\x20\x20\x20\x20','ER\x20BY\x20id','\x20\x20\x20\x20\x20THE','\x20\x20\x20FROM\x20','ion_id,\x0a','agents','PDATE\x20SE','\x20\x20system','91IxNTkv','IS\x20NULL\x0a','\x20node_ki','\x20\x20\x20\x20\x20\x20\x20E','ame','names','byteLeng','ent\x20=\x20ex','set','_value\x0a\x20','order,\x0a\x20','patch','\x20\x20\x20VALUE','ion_at,\x0a',',\x0a\x20\x20\x20\x20\x20\x20','\x20\x20ON\x20CON','.json','ta\x0a\x20\x20\x20\x20\x20','\x0a\x20\x20\x20\x20\x20\x20C','dCostUsd','ovider','ROLLBACK','ocal_met','tem_sent','.sql','_interac','raction_','\x20\x20runtim','prepare','\x20\x20boolea','\x20IS\x20NOT\x20','WhenResu','apshot','localeCo','_tokens,','map','_run\x20=\x20e','t_usd,\x0a\x20','@input_t','mtime_ms','MP\x0a\x20\x20\x20\x20\x20','indexOf','resolve','totalTok','\x20\x20\x20)\x20VAL','NFLICT(s','key,\x20ses','kind,\x0a\x20\x20',',\x20?)\x0a\x20\x20\x20','\x20\x20\x20\x20\x20\x20\x20W','\x20\x20\x20\x20\x20upd','join','\x20chat_ty','\x20\x20agent_','FLICT(se','ns\x20=\x20exc','number','ssion_re','pdated_a','agentId','outputTo','storePat','MAL;','l,\x0a\x20\x20\x20\x20\x20','\x20\x20\x20\x20mode','_nodes\x20(','1467jbugkV','toLowerC','isFile','dated_ro','endedAt','store','\x20\x20\x20\x20\x20age','\x20\x20\x20','\x20\x20chat_t','y\x0a\x20\x20\x20\x20\x20\x20','ode_id','us\x20=\x20NOR','888872HDNDdl','clone','\x0a\x20\x20\x20\x20\x20\x20a','\x20\x20\x20\x20WHER','e_write,','del_prov','object','\x20\x20\x20WHERE','sion_id\x0a','HERE\x20sec','\x20\x20\x20\x20sess','systemSe','alue','t_tokens','1,\x0a\x20\x20\x20\x20\x20','\x20\x20\x20\x20\x20@ch','text_val','WHERE\x20ag','*)\x20AS\x20co','n_local_','n_starte','\x20\x20\x20pinne','\x20\x20\x20\x20\x20\x20id','\x20session','luded.mo','function','\x20\x20\x20text_','\x20label,\x0a','isArray','s,\x0a\x20\x20\x20\x20\x20','INTO\x20ses','d_cost_u','\x20\x20\x20\x20\x20\x20\x20\x20','total_to','nel','bytes,\x0a\x20','estimate','ions\x20ORD','key\x20=\x20?\x0a','tokens,\x0a','kens_fre','borted_l','DATE\x20SET','LUES\x20(?,','unt\x0a\x20\x20\x20\x20','T\x20COUNT(','okens,\x0a\x20','che_read','\x20\x20@estim','luded.se','modelPro','\x20\x20\x20\x20\x20\x20\x20m','NT_TIMES','\x20\x20\x20\x20\x20\x20\x20u','push','ion_key)','\x20DESC,\x20i','N\x20exclud','delete','PRAGMA\x20f','skillsSn','\x20\x20last_c','existing','promptRe','\x20?,\x20?)\x0a\x20','_section','ata.cust','@session','test','n_key\x0a\x20\x20','ection_n','\x20\x20\x20\x20\x20\x20co','fresh,\x0a\x20','ntext_to',':channel','\x20\x20\x20\x20\x20las','m_name,\x0a','agent_id','mtimeMs','st_inter','SE\x20sessi','okens','isFinite','kind','run,\x0a\x20\x20\x20','ensFresh','at_type,','_at,\x0a\x20\x20\x20','INTEGER\x20','kens,\x0a\x20\x20','bel,\x0a\x20\x20\x20','=\x20exclud','_TIMESTA','ournal_m','_order\x0a\x20','number_v','action_a','value,\x0a\x20','70odxXtK','adata.cu','chatType','pe,\x0a\x20\x20\x20\x20','ed.custo','session\x20','pinned_o','ession_k','ile,\x0a\x20\x20\x20','nnel','T\x0a\x20\x20\x20\x20\x20\x20','d_at\x20=\x20e','s\x0a\x20\x20\x20\x20\x20\x20','E\x20source','ssion_ke','at\x20=\x20CAS','lastTo','PRAGMA\x20j','cluded.c','ended_at','T,\x0a\x20\x20\x20\x20\x20','ESC,\x20id\x20','ey,\x0a\x20\x20\x20\x20','value','algorith','\x20\x20\x20\x20\x20\x20\x20a','lue\x0a\x20\x20\x20\x20','Context','TO\x20sessi','\x20\x20starte','array','\x20\x20\x20boole','storedAt','y_import','rations\x20','ed_cost_','ory','nd,\x0a\x20\x20\x20\x20','\x20DESC\x0a\x20\x20','\x20\x20\x20\x20\x20\x20\x20p','on_id,\x0a\x20','ed\x20=\x201\x0a\x20','\x20model,\x0a','cache_re','\x20\x20\x20\x20abor','h,\x0a\x20\x20\x20\x20\x20','\x20\x20\x20\x20','summary','\x20NOT\x20NUL','FROM\x20ses','\x20pinned_','at\x20=\x20exc','\x20\x20\x20\x20last',',\x20?)\x0a\x20\x20','contextT','d.estima','dex','\x20\x20\x20\x20sour','\x20\x20\x20\x20\x20cac','\x20\x20\x20CURRE','\x20\x20\x20\x20\x20sys','DESC,\x20id','\x20\x20\x20\x20FROM','\x20applied','sion_sto','d,\x20paren','AMP\x0a\x20\x20\x20\x20','resh,\x0a\x20\x20','NULL\x0a\x20\x20\x20','filter','er,\x0a\x20\x20\x20\x20','groupId','tore_leg','normaliz','nt_id,\x0a\x20',')\x20VALUES','lastThre','\x20\x20);\x0a\x20\x20\x20','ind,\x0a\x20\x20\x20','\x20\x20\x20\x20\x20\x20pa','file','\x20@sessio','\x20\x20\x20\x20)\x20VA','d,\x0a\x20\x20\x20\x20\x20','hannel,\x0a','\x20\x20\x20\x20\x20INS','DER\x20BY\x20i','count','SELECT\x20s','kens','legacyKe','te,\x0a\x20\x20\x20\x20','key,\x20arr','replaceA','sha256','started_','ENT_TIME','skipCach','sessionS','\x20\x20\x20INSER','at,\x0a\x20\x20\x20\x20','L\x0a\x20\x20\x20\x20\x20\x20','\x0a\x20\x20\x20\x20\x20\x20n','sessions','d\x20=\x20?\x0a\x20\x20','ion_sect','ssion_id','e_migrat','\x20\x20node_k','ssion_fi','ROM\x20sess','all','cluded.o','5wqbZGo','tus,\x0a\x20\x20\x20','WHERE\x20se','\x20\x20\x20\x20\x20sec','_run,\x0a\x20\x20','session_','version','rder','rts\x20WHER','269562unxpCW','skills-p','INCREMEN','T\x20sessio','slice','lastInde','_id,\x0a\x20\x20\x20','\x20\x20\x20\x20\x20\x20up','\x20\x20\x20\x20\x20\x20EL','l_provid','URRENT_T','\x20\x20id,\x0a\x20\x20','ded.cach','ast_inte','\x20=\x20exclu','catch','n_value\x0a','main','customNa','node_kin','ession_s','aborted_','context_','mated_co','ession_l','TE\x20SET\x0a\x20','eys\x20=\x20ON','\x20\x20\x20\x20)\x0a\x20\x20','COMMIT;','next','mber_val','add','/agents/','\x20\x20\x20\x20@upd','on_recor','ase','utf8','\x20source_','_key\x20IN\x20','\x20\x20\x20cache','\x20\x20\x20input','al_metad','ex,\x0a\x20\x20\x20\x20','kens\x20=\x20e','ded_at,\x0a','key','acy_impo','./sql/','lue,\x0a\x20\x20\x20','\x20text_va','=\x20CURREN','ystem_se','\x20\x20\x20\x20esti','d\x20ASC\x0a\x20\x20','\x20\x20\x20\x20\x20\x20@m','\x20\x20\x20\x20outp','_channel','origin','_tokens_','DELETE\x20F','\x20\x20\x20\x20\x20\x20mo','utput_to','MAX_SAFE','\x20\x20\x20\x20\x20\x20\x20','split','sion_key','l_metada','cord_id\x20','cluded.m','_usd,\x0a\x20\x20','\x20\x20WHEN\x20s','luded.to','{}\x0a','custom_n','om_name\x20','d.last_c','\x20\x20\x20\x20\x20end','d_id\x20=\x20?','e_read,\x0a','parse','.txt','alue,\x0a\x20\x20','hannel\x20=','\x20\x20\x20\x20\x20WHE','\x20DO\x20UPDA','\x20\x20\x20\x20\x20\x20','\x20exclude','n_count\x0a','label,\x0a\x20','t,\x0a\x20\x20\x20\x20\x20','match','ords\x0a\x20\x20\x20','text','\x20\x20\x20\x20ORDE','\x20\x20\x20SELEC','startsWi','endsWith','MEDIATE;','ode\x20=\x20WA','15262764YUKxkz','lastChan','size','ed_last_','\x20\x20\x20\x20\x20sta','stringif','label','\x20importe','\x20\x20\x20\x20\x20\x20FR','array_in','2743400kIAQZf','\x20\x20\x20\x20\x20\x20\x20F','?,\x20?,\x20?,','STAMP\x0a\x20\x20','d\x20FROM\x20s','key\x0a\x20\x20\x20\x20','\x20\x20\x20\x20OR\x20s','records\x20','d,\x20node_','updated_','NULL,\x0a\x20\x20','ite\x20=\x20ex','_at\x20TEXT','name,\x0a\x20\x20','SELECT\x20i','ent_id,\x0a','matrix:','ated_at,','del\x20=\x20ex','xcluded.','pinned','runtimeM','ion_loca','pinnedKe','keys','\x20\x20\x20sessi','ELECT\x20se','\x20SELECT\x0a'];_0x16b5=function(){return _0x3438eb;};return _0x16b5();}function fromSqliteBoolean(_0x38f4e7){if(_0x38f4e7===null||_0x38f4e7===undefined)return null;return Number(_0x38f4e7)===SQL_BOOLEAN_TRUE;}function normalizeScalarNode(_0x1ccfd0){const _0x555b3e=_0xe09ee2;if(_0x1ccfd0===null)return{'node_kind':_0x555b3e(0x30c)};if(typeof _0x1ccfd0===_0x555b3e(0x259))return{'node_kind':_0x555b3e(0x259),'text_value':_0x1ccfd0};if(typeof _0x1ccfd0==='number'&&Number[_0x555b3e(0x3d9)](_0x1ccfd0))return{'node_kind':'number','number_value':_0x1ccfd0};if(typeof _0x1ccfd0===_0x555b3e(0x309))return{'node_kind':_0x555b3e(0x309),'boolean_value':toSqliteBoolean(_0x1ccfd0)};return null;}function normalizeOptionalString(_0x4016ad){const _0x5067ab=_0xe09ee2;return typeof _0x4016ad===_0x5067ab(0x259)?_0x4016ad[_0x5067ab(0x298)]():'';}function normalizeLowercaseStringOrEmpty(_0xd1c58e){const _0x3e4a72=_0xe09ee2;return normalizeOptionalString(_0xd1c58e)[_0x3e4a72(0x37c)+_0x3e4a72(0x1af)]();}function parseThreadSessionSuffix(_0x3f7783){const _0x1c4f20=_0xe09ee2,_0x21fcce=normalizeOptionalString(_0x3f7783),_0x3607a9=_0x1c4f20(0x2f6),_0x357fcd=_0x21fcce[_0x1c4f20(0x191)+_0x1c4f20(0x2b2)](_0x3607a9);if(_0x357fcd<0x0)return{'baseSessionKey':null,'threadId':''};return{'baseSessionKey':_0x21fcce['slice'](0x0,_0x357fcd),'threadId':_0x21fcce[_0x1c4f20(0x190)](_0x357fcd+_0x3607a9[_0x1c4f20(0x323)])};}function requiresFoldedSessionKeyAliasProof(_0x7827f8){const _0x17be04=_0xe09ee2,_0x5cb0c2=normalizeLowercaseStringOrEmpty(_0x7827f8);return _0x5cb0c2[_0x17be04(0x297)](_0x17be04(0x209))||_0x5cb0c2['includes'](_0x17be04(0x2c6))||_0x5cb0c2[_0x17be04(0x297)](_0x17be04(0x3d1)+':')||_0x5cb0c2[_0x17be04(0x297)](_0x17be04(0x2f6));}function normalizeSessionKeyPreservingOpaquePeerIds(_0x57bc19){return normalizeOptionalString(_0x57bc19);}function normalizeStoreSessionKey(_0x385473){return normalizeSessionKeyPreservingOpaquePeerIds(_0x385473);}function foldedSessionKeyAliasCandidates(_0x58d6ba){const _0x1f2650=_0xe09ee2,_0x66a98b=new Set(),_0x54cc5c=normalizeLowercaseStringOrEmpty(_0x58d6ba);if(_0x54cc5c&&_0x54cc5c!==_0x58d6ba)_0x66a98b[_0x1f2650(0x1ab)](_0x54cc5c);if(requiresFoldedSessionKeyAliasProof(_0x58d6ba)){const {baseSessionKey:_0x2051ec,threadId:_0x515063}=parseThreadSessionSuffix(_0x58d6ba),_0x4cf1e1=normalizeLowercaseStringOrEmpty(_0x2051ec);_0x2051ec&&_0x515063&&_0x4cf1e1&&_0x4cf1e1!==_0x2051ec&&_0x66a98b[_0x1f2650(0x1ab)](_0x4cf1e1+_0x1f2650(0x2f6)+_0x515063);}return[..._0x66a98b];}function normalizeEntryTarget(_0x5d0281){const _0x689cff=_0xe09ee2,_0x2a1f38=normalizeOptionalString(_0x5d0281);if(!_0x2a1f38)return'';const _0x2e36d8=['!','#'][_0x689cff(0x35c)](_0x258dcb=>_0x2a1f38[_0x689cff(0x362)](_0x258dcb))[_0x689cff(0x157)](_0x333067=>_0x333067>=0x0);if(_0x2e36d8[_0x689cff(0x323)]===0x0)return _0x2a1f38;return _0x2a1f38[_0x689cff(0x190)](Math[_0x689cff(0x2b4)](..._0x2e36d8));}function entryDeliveryTargets(_0x161a30){const _0x31b3e0=_0xe09ee2;return[_0x161a30?.['delivery'+_0x31b3e0(0x12d)]?.['to'],_0x161a30?.[_0x31b3e0(0x122)],_0x161a30?.[_0x31b3e0(0x1c5)]?.['nativeCh'+'annelId'],_0x161a30?.['origin']?.['to'],_0x161a30?.[_0x31b3e0(0x159)]][_0x31b3e0(0x35c)](normalizeEntryTarget)[_0x31b3e0(0x157)](Boolean);}function normalizeEntryThreadId(_0x8d9663){const _0x56b27f=_0xe09ee2;if(_0x8d9663===null||_0x8d9663===undefined)return'';if(typeof _0x8d9663!==_0x56b27f(0x259)&&typeof _0x8d9663!==_0x56b27f(0x371))return'';return String(_0x8d9663)[_0x56b27f(0x298)]();}function entryThreadId(_0x5bf633){const _0x29ec34=_0xe09ee2;return normalizeEntryThreadId(_0x5bf633?.['delivery'+_0x29ec34(0x12d)]?.[_0x29ec34(0x2e3)]??_0x5bf633?.[_0x29ec34(0x15e)+_0x29ec34(0x308)]??_0x5bf633?.[_0x29ec34(0x1c5)]?.['threadId']);}function isConfirmedLowercasedLegacyAlias(_0x33afb3,_0x107b34){const _0x5be0b9=_0xe09ee2;if(!_0x33afb3)return![];if(!requiresFoldedSessionKeyAliasProof(_0x107b34))return!![];const {baseSessionKey:_0x2461ad,threadId:_0x48f827}=parseThreadSessionSuffix(_0x107b34),_0x37ad3a=_0x2461ad??_0x107b34;if(!entryDeliveryTargets(_0x33afb3)['some'](_0x43de4b=>_0x37ad3a[_0x5be0b9(0x297)](_0x43de4b)))return![];if(!_0x48f827)return!![];return entryThreadId(_0x33afb3)===_0x48f827;}function hasMismatchedCaseSensitiveDeliveryProof(_0x5f2e93,_0x178407){const _0x18e8a7=_0xe09ee2;if(!_0x5f2e93||!requiresFoldedSessionKeyAliasProof(_0x178407))return![];const {baseSessionKey:_0x168f8e,threadId:_0x1b9fbf}=parseThreadSessionSuffix(_0x178407),_0x2df3dd=_0x168f8e??_0x178407,_0x4cb9cc=entryDeliveryTargets(_0x5f2e93);if(_0x4cb9cc[_0x18e8a7(0x323)]>0x0&&!_0x4cb9cc[_0x18e8a7(0x2a4)](_0x392223=>_0x2df3dd[_0x18e8a7(0x297)](_0x392223)))return!![];const _0x47799d=entryThreadId(_0x5f2e93);return Boolean(_0x1b9fbf&&_0x47799d&&_0x47799d!==_0x1b9fbf);}function resolveSessionStoreEntry(_0x447fae){const _0x5e2598=_0xe09ee2,_0x472c4f=normalizeOptionalString(_0x447fae[_0x5e2598(0x287)+'ey']),_0x5a279f=normalizeStoreSessionKey(_0x472c4f),_0x52199e=foldedSessionKeyAliasCandidates(_0x5a279f),_0x41ee2f=new Set();_0x472c4f&&_0x472c4f!==_0x5a279f&&Object['hasOwn'](_0x447fae[_0x5e2598(0x380)],_0x472c4f)&&!hasMismatchedCaseSensitiveDeliveryProof(_0x447fae['store'][_0x472c4f],_0x5a279f)&&_0x41ee2f['add'](_0x472c4f);let _0x2434f1,_0x3da3bb=0x0;for(const _0x41901b of _0x52199e){if(!Object[_0x5e2598(0x26b)](_0x447fae[_0x5e2598(0x380)],_0x41901b)||!isConfirmedLowercasedLegacyAlias(_0x447fae['store'][_0x41901b],_0x5a279f))continue;_0x41ee2f[_0x5e2598(0x1ab)](_0x41901b);const _0x5ce33b=_0x447fae['store'][_0x41901b],_0x480307=typeof _0x5ce33b?.[_0x5e2598(0x223)+'t']===_0x5e2598(0x371)?_0x5ce33b[_0x5e2598(0x223)+'t']:0x0;(!_0x2434f1||_0x480307>_0x3da3bb)&&(_0x2434f1=_0x5ce33b,_0x3da3bb=_0x480307);}const _0x5840c3=Object[_0x5e2598(0x26b)](_0x447fae[_0x5e2598(0x380)],_0x5a279f)?_0x447fae['store'][_0x5a279f]:undefined,_0x5c6644=hasMismatchedCaseSensitiveDeliveryProof(_0x5840c3,_0x5a279f)?undefined:_0x5840c3,_0x6a1388=requiresFoldedSessionKeyAliasProof(_0x5a279f),_0x50de7=_0x41ee2f[_0x5e2598(0x1f1)]>0x0&&_0x472c4f&&!hasMismatchedCaseSensitiveDeliveryProof(_0x447fae[_0x5e2598(0x380)][_0x472c4f],_0x5a279f)?_0x447fae[_0x5e2598(0x380)][_0x472c4f]:undefined;let _0x1aad61=_0x6a1388?_0x5c6644??_0x2434f1??_0x50de7:undefined,_0x1cf997=typeof _0x1aad61?.[_0x5e2598(0x223)+'t']===_0x5e2598(0x371)?_0x1aad61['updatedA'+'t']:0x0;if(!_0x6a1388)for(const _0xbd9d6e of[_0x5c6644,_0x2434f1,_0x50de7]){const _0x3330b2=typeof _0xbd9d6e?.[_0x5e2598(0x223)+'t']===_0x5e2598(0x371)?_0xbd9d6e[_0x5e2598(0x223)+'t']:0x0;_0xbd9d6e&&(!_0x1aad61||_0x3330b2>_0x1cf997)&&(_0x1aad61=_0xbd9d6e,_0x1cf997=_0x3330b2);}for(const [_0x3cc532,_0x102e7b]of Object[_0x5e2598(0x244)](_0x447fae[_0x5e2598(0x380)])){if(_0x3cc532===_0x5a279f)continue;if(normalizeStoreSessionKey(_0x3cc532)!==_0x5a279f)continue;if(hasMismatchedCaseSensitiveDeliveryProof(_0x102e7b,_0x5a279f))continue;_0x41ee2f['add'](_0x3cc532);const _0x202d53=typeof _0x102e7b?.['updatedA'+'t']===_0x5e2598(0x371)?_0x102e7b[_0x5e2598(0x223)+'t']:0x0;(!_0x1aad61||_0x202d53>_0x1cf997)&&(_0x1aad61=_0x102e7b,_0x1cf997=_0x202d53);}return{'normalizedKey':_0x5a279f,'existing':_0x1aad61,'legacyKeys':[..._0x41ee2f]};}function hashPrompt(_0x3d2eef){const _0x8e1a64=_0xe09ee2;return createHash(_0x8e1a64(0x170))['update'](_0x3d2eef)[_0x8e1a64(0x2c0)]('hex');}function rememberPromptRef(_0x2f4865,_0x1d3ff9){const _0x4f847a=_0xe09ee2;PROMPT_REF_CACHE['set'](_0x2f4865,_0x1d3ff9);while(PROMPT_REF_CACHE[_0x4f847a(0x1f1)]>SESSION_STORE_PROMPT_REF_CACHE_MAX_ENTRIES){const _0x1c3bf4=PROMPT_REF_CACHE[_0x4f847a(0x211)]()[_0x4f847a(0x1a9)]()[_0x4f847a(0x129)];if(typeof _0x1c3bf4!==_0x4f847a(0x259))break;PROMPT_REF_CACHE[_0x4f847a(0x3c1)](_0x1c3bf4);}}function buildPromptRef(_0x52c12f){const _0x382831=_0xe09ee2,_0x4661eb=PROMPT_REF_CACHE[_0x382831(0x22b)](_0x52c12f);if(_0x4661eb)return _0x4661eb;const _0x5aa372={'version':SESSION_STORE_PROMPT_BLOB_VERSION,'algorithm':SESSION_STORE_PROMPT_BLOB_ALGORITHM,'hash':hashPrompt(_0x52c12f),'bytes':Buffer['byteLeng'+'th'](_0x52c12f,_0x382831(0x1b0))};return rememberPromptRef(_0x52c12f,_0x5aa372),_0x5aa372;}function isSha256Hex(_0x5be02f){const _0x18fb6d=_0xe09ee2;return/^[a-f0-9]{64}$/u[_0x18fb6d(0x3cb)](String(_0x5be02f||''));}function resolveSessionSkillPromptBlobPath(_0x4de458,_0x3f207c){const _0x4f2afc=_0xe09ee2;if(!isSha256Hex(_0x3f207c))return null;return join(dirname(_0x4de458),SESSION_STORE_PROMPT_BLOB_DIR,SESSION_STORE_PROMPT_BLOB_ALGORITHM,_0x3f207c[_0x4f2afc(0x190)](0x0,0x2),_0x3f207c+_0x4f2afc(0x1dc));}function shouldStorePromptAsBlob(_0x337ef7){const _0x2cc4a6=_0xe09ee2,_0x224d3a=Buffer[_0x2cc4a6(0x33f)+'th'](_0x337ef7,_0x2cc4a6(0x1b0));return _0x337ef7['length']>=SESSION_STORE_MIN_PROMPT_BLOB_CHARS&&_0x224d3a<=SESSION_STORE_MAX_PROMPT_BLOB_BYTES;}function rememberValidPromptBlob(_0xd7d455,_0xdbb18,_0x4425ba){const _0x12d558=_0xe09ee2;VALID_PROMPT_BLOB_CACHE[_0x12d558(0x341)](_0xd7d455,{'mtimeMs':_0xdbb18[_0x12d558(0x3d5)],'size':_0xdbb18['size'],'prompt':_0x4425ba});while(VALID_PROMPT_BLOB_CACHE[_0x12d558(0x1f1)]>SESSION_STORE_VALID_PROMPT_BLOB_CACHE_MAX_ENTRIES){const _0x1ccf53=VALID_PROMPT_BLOB_CACHE[_0x12d558(0x211)]()[_0x12d558(0x1a9)]()['value'];if(typeof _0x1ccf53!=='string')break;VALID_PROMPT_BLOB_CACHE[_0x12d558(0x3c1)](_0x1ccf53);}}function parsePromptRef(_0x4d5c20){const _0x5db76e=_0xe09ee2,_0x290fd6=asRecord(_0x4d5c20);if(_0x290fd6[_0x5db76e(0x189)]!==SESSION_STORE_PROMPT_BLOB_VERSION||_0x290fd6['algorith'+'m']!==SESSION_STORE_PROMPT_BLOB_ALGORITHM||typeof _0x290fd6[_0x5db76e(0x290)]!==_0x5db76e(0x259)||typeof _0x290fd6[_0x5db76e(0x2ab)]!==_0x5db76e(0x371))return null;return{'version':_0x290fd6['version'],'algorithm':_0x290fd6[_0x5db76e(0x12a)+'m'],'hash':_0x290fd6[_0x5db76e(0x290)],'bytes':_0x290fd6[_0x5db76e(0x2ab)]};}function readValidPromptBlobSync(_0x20ce60,_0xe34dfc){const _0x37e0a9=_0xe09ee2;if(!_0xe34dfc||_0xe34dfc[_0x37e0a9(0x189)]!==SESSION_STORE_PROMPT_BLOB_VERSION||_0xe34dfc[_0x37e0a9(0x12a)+'m']!==SESSION_STORE_PROMPT_BLOB_ALGORITHM||!isSha256Hex(_0xe34dfc[_0x37e0a9(0x290)])||typeof _0xe34dfc[_0x37e0a9(0x2ab)]!==_0x37e0a9(0x371)||!Number[_0x37e0a9(0x3d9)](_0xe34dfc[_0x37e0a9(0x2ab)])||_0xe34dfc['bytes']<0x0||_0xe34dfc['bytes']>SESSION_STORE_MAX_PROMPT_BLOB_BYTES)return null;const _0x71e67b=resolveSessionSkillPromptBlobPath(_0x20ce60,_0xe34dfc['hash']);if(!_0x71e67b)return null;try{const _0x3f9043=statSync(_0x71e67b);if(!_0x3f9043[_0x37e0a9(0x37d)]()||_0x3f9043['size']!==_0xe34dfc[_0x37e0a9(0x2ab)])return VALID_PROMPT_BLOB_CACHE[_0x37e0a9(0x3c1)](_0x71e67b),null;const _0x4103d3=VALID_PROMPT_BLOB_CACHE[_0x37e0a9(0x22b)](_0x71e67b);if(_0x4103d3&&_0x4103d3['mtimeMs']===_0x3f9043[_0x37e0a9(0x3d5)]&&_0x4103d3[_0x37e0a9(0x1f1)]===_0x3f9043[_0x37e0a9(0x1f1)])return _0x4103d3[_0x37e0a9(0x241)];const _0x336b64=readFileSync(_0x71e67b,_0x37e0a9(0x1b0));if(hashPrompt(_0x336b64)!==_0xe34dfc[_0x37e0a9(0x290)]||Buffer['byteLeng'+'th'](_0x336b64,_0x37e0a9(0x1b0))!==_0xe34dfc[_0x37e0a9(0x2ab)])return VALID_PROMPT_BLOB_CACHE[_0x37e0a9(0x3c1)](_0x71e67b),null;return rememberValidPromptBlob(_0x71e67b,_0x3f9043,_0x336b64),_0x336b64;}catch{return VALID_PROMPT_BLOB_CACHE['delete'](_0x71e67b),null;}}function _0x4ed3(_0x5207ab,_0x20b857){_0x5207ab=_0x5207ab-0x109;const _0x16b5f6=_0x16b5();let _0x4ed3f6=_0x16b5f6[_0x5207ab];return _0x4ed3f6;}function hydratePromptRefsInStore(_0x24fb96,_0x366e29){const _0x4ae3d0=_0xe09ee2;let _0x5ca8f4=![];for(const [_0xf7d93,_0x291c11]of Object['entries'](_0x366e29)){const _0x48c68e=asRecord(_0x291c11),_0x9ea073=asRecord(_0x48c68e[_0x4ae3d0(0x3c3)+_0x4ae3d0(0x359)]);if(!_0x9ea073||typeof _0x9ea073[_0x4ae3d0(0x241)]===_0x4ae3d0(0x259))continue;const _0x3aa924=parsePromptRef(_0x9ea073[_0x4ae3d0(0x3c6)+'f']),_0x3af9d3=_0x3aa924?readValidPromptBlobSync(_0x24fb96,_0x3aa924):null;if(!_0x3af9d3){const _0x4a9e3e={..._0x48c68e};delete _0x4a9e3e[_0x4ae3d0(0x3c3)+_0x4ae3d0(0x359)],_0x366e29[_0xf7d93]=_0x4a9e3e,_0x5ca8f4=!![];continue;}const {promptRef:_0x23640f,..._0x51391a}=_0x9ea073;_0x366e29[_0xf7d93]={..._0x48c68e,'skillsSnapshot':{..._0x51391a,'prompt':_0x3af9d3}},_0x5ca8f4=!![];}return _0x5ca8f4;}async function ensurePromptBlob(_0x42c336,_0x4415d1){const _0x34a761=_0xe09ee2,_0x28618d=buildPromptRef(_0x4415d1),_0x22de92=resolveSessionSkillPromptBlobPath(_0x42c336,_0x28618d[_0x34a761(0x290)]);if(!_0x22de92)return _0x28618d;if(readValidPromptBlobSync(_0x42c336,_0x28618d)===_0x4415d1)try{await stat(_0x22de92);const _0x1fadbf=await stat(_0x22de92);return rememberValidPromptBlob(_0x22de92,_0x1fadbf,_0x4415d1),_0x28618d;}catch{}await mkdir(dirname(_0x22de92),{'recursive':!![]}),await writeFile(_0x22de92,_0x4415d1,_0x34a761(0x1b0));const _0x1532f2=await stat(_0x22de92);return rememberValidPromptBlob(_0x22de92,_0x1532f2,_0x4415d1),_0x28618d;}async function ensureStorePromptBlobs(_0x4fca7a,_0x3dec08){const _0x253184=_0xe09ee2,_0x1ea5cb={};for(const [_0x466393,_0x1148a8]of Object[_0x253184(0x244)](asRecord(_0x3dec08))){const _0x5260d4=asRecord(_0x1148a8),_0x426b71=asRecord(_0x5260d4[_0x253184(0x3c3)+_0x253184(0x359)]),_0x2df12d=typeof _0x426b71[_0x253184(0x241)]===_0x253184(0x259)?_0x426b71[_0x253184(0x241)]:'';if(!_0x2df12d||!shouldStorePromptAsBlob(_0x2df12d)){_0x1ea5cb[_0x466393]=cloneJsonValue(_0x5260d4);continue;}const _0x72cb4f=await ensurePromptBlob(_0x4fca7a,_0x2df12d),{prompt:_0x3d70af,..._0x4bbbec}=_0x426b71;_0x1ea5cb[_0x466393]={...cloneJsonValue(_0x5260d4),'skillsSnapshot':{..._0x4bbbec,'promptRef':_0x72cb4f}};}return _0x1ea5cb;}function resolveMergedUpdatedAt(_0x2f67e1,_0x71f555,_0x3bae19=Date['now']()){const _0x112d06=_0xe09ee2,_0x2e1529=typeof _0x2f67e1?.['updatedA'+'t']===_0x112d06(0x371)&&Number[_0x112d06(0x3d9)](_0x2f67e1[_0x112d06(0x223)+'t'])?Math[_0x112d06(0x2b4)](_0x2f67e1[_0x112d06(0x223)+'t'],_0x3bae19):undefined,_0x3da5b3=typeof _0x71f555?.['updatedA'+'t']===_0x112d06(0x371)&&Number[_0x112d06(0x3d9)](_0x71f555[_0x112d06(0x223)+'t'])?Math[_0x112d06(0x2b4)](_0x71f555[_0x112d06(0x223)+'t'],_0x3bae19):undefined;return Math['max'](_0x2e1529??0x0,_0x3da5b3??0x0,_0x3bae19);}function rewriteSessionFileForNewSessionId({sessionFile:_0x23337a,previousSessionId:_0x128680,nextSessionId:_0x51c3c0}){const _0x377146=_0xe09ee2,_0x54401b=normalizeOptionalString(_0x23337a);if(!_0x54401b||!_0x54401b[_0x377146(0x1ec)](_0x377146(0x29e)))return undefined;const _0x5e93d1=basename(_0x54401b,_0x377146(0x29e));if(_0x5e93d1===_0x128680)return join(dirname(_0x54401b),_0x51c3c0+_0x377146(0x29e));if(_0x5e93d1[_0x377146(0x1eb)+'th'](_0x128680+_0x377146(0x22d)))return join(dirname(_0x54401b),''+_0x51c3c0+_0x5e93d1['slice'](_0x128680['length'])+'.jsonl');const _0x15d686=_0x5e93d1[_0x377146(0x1e6)](/^(\d{4}-\d{2}-\d{2}T[\w-]+(?:Z|[+-]\d{2}(?:-\d{2})?)?)_(.+)$/);if(_0x15d686?.[0x2]===_0x128680)return join(dirname(_0x54401b),_0x15d686[0x1]+'_'+_0x51c3c0+_0x377146(0x29e));return undefined;}function normalizeSessionRuntimeModelFields(_0x498cf7){const _0x56ecab=_0xe09ee2,_0x444cf3=normalizeOptionalString(_0x498cf7?.[_0x56ecab(0x25a)]),_0x2559c3=normalizeOptionalString(_0x498cf7?.[_0x56ecab(0x3b9)+_0x56ecab(0x26a)]);let _0x4aa693=_0x498cf7;if(!_0x444cf3)return(_0x498cf7?.['model']!==undefined||_0x498cf7?.[_0x56ecab(0x3b9)+_0x56ecab(0x26a)]!==undefined)&&(_0x4aa693={..._0x4aa693},delete _0x4aa693[_0x56ecab(0x25a)],delete _0x4aa693[_0x56ecab(0x3b9)+_0x56ecab(0x26a)]),_0x4aa693;if(_0x498cf7?.['model']!==_0x444cf3){if(_0x4aa693===_0x498cf7)_0x4aa693={..._0x4aa693};_0x4aa693[_0x56ecab(0x25a)]=_0x444cf3;}if(!_0x2559c3){if(_0x498cf7?.[_0x56ecab(0x3b9)+_0x56ecab(0x26a)]!==undefined){if(_0x4aa693===_0x498cf7)_0x4aa693={..._0x4aa693};delete _0x4aa693[_0x56ecab(0x3b9)+'vider'];}return _0x4aa693;}if(_0x498cf7?.['modelPro'+_0x56ecab(0x26a)]!==_0x2559c3){if(_0x4aa693===_0x498cf7)_0x4aa693={..._0x4aa693};_0x4aa693[_0x56ecab(0x3b9)+_0x56ecab(0x26a)]=_0x2559c3;}return _0x4aa693;}function mergeSessionEntry(_0x36cdc6,_0x14fac6){const _0xb8430e=_0xe09ee2,_0x1a3baa=_0x14fac6['sessionI'+'d']??_0x36cdc6?.['sessionI'+'d']??randomUUID(),_0x54684c=resolveMergedUpdatedAt(_0x36cdc6,_0x14fac6);if(!_0x36cdc6)return normalizeSessionRuntimeModelFields({..._0x14fac6,'sessionId':_0x1a3baa,'updatedAt':_0x54684c,'sessionStartedAt':_0x14fac6[_0xb8430e(0x174)+'tartedAt']??_0x54684c});const _0x3a15cc={..._0x36cdc6,..._0x14fac6,'sessionId':_0x1a3baa,'updatedAt':_0x54684c,'sessionStartedAt':_0x14fac6[_0xb8430e(0x174)+_0xb8430e(0x24c)]??(_0x36cdc6['sessionI'+'d']===_0x1a3baa?_0x36cdc6[_0xb8430e(0x174)+'tartedAt']:_0x54684c)};if(_0x36cdc6['sessionI'+'d']!==_0x1a3baa){const _0x1d34af=rewriteSessionFileForNewSessionId({'sessionFile':Object[_0xb8430e(0x26b)](_0x14fac6,_0xb8430e(0x2fb)+_0xb8430e(0x2d9))?_0x14fac6[_0xb8430e(0x2fb)+'ile']:_0x36cdc6[_0xb8430e(0x2fb)+_0xb8430e(0x2d9)],'previousSessionId':_0x36cdc6[_0xb8430e(0x2ac)+'d'],'nextSessionId':_0x1a3baa});if(_0x1d34af)_0x3a15cc[_0xb8430e(0x2fb)+'ile']=_0x1d34af;}if(Object[_0xb8430e(0x26b)](_0x14fac6,_0xb8430e(0x25a))&&!Object[_0xb8430e(0x26b)](_0x14fac6,_0xb8430e(0x3b9)+_0xb8430e(0x26a))){const _0x3abb79=normalizeOptionalString(_0x14fac6[_0xb8430e(0x25a)]),_0x239b4b=normalizeOptionalString(_0x36cdc6[_0xb8430e(0x25a)]);if(_0x3abb79&&_0x3abb79!==_0x239b4b)delete _0x3a15cc[_0xb8430e(0x3b9)+_0xb8430e(0x26a)];}return normalizeSessionRuntimeModelFields(_0x3a15cc);}async function runExclusiveStoreWrite(_0xe9531e,_0x2564e8){const _0x45b087=_0xe09ee2,_0x1b3c75=String(_0xe9531e||''),_0x1b840e=STORE_WRITE_QUEUES[_0x45b087(0x22b)](_0x1b3c75)??Promise[_0x45b087(0x363)]();let _0x1f7469;const _0x236f62=new Promise(_0x388e75=>{_0x1f7469=_0x388e75;});STORE_WRITE_QUEUES[_0x45b087(0x341)](_0x1b3c75,_0x1b840e[_0x45b087(0x19b)](()=>{})[_0x45b087(0x26d)](()=>_0x236f62)),await _0x1b840e['catch'](()=>{});try{return await _0x2564e8();}finally{_0x1f7469(),STORE_WRITE_QUEUES['get'](_0x1b3c75)===_0x236f62&&STORE_WRITE_QUEUES[_0x45b087(0x3c1)](_0x1b3c75);}}function cloneStoreObject(_0x33cfe2){const _0x8a710e=_0xe09ee2;return JSON[_0x8a710e(0x1db)](JSON[_0x8a710e(0x1f4)+'y'](_0x33cfe2||{}));}function isCloneRequested(_0x4a5ba9={}){const _0x33e459=_0xe09ee2;return _0x4a5ba9[_0x33e459(0x388)]!==![];}function createCacheKey(_0x560fa4){return String(_0x560fa4||'');}function readCachedStore(_0x136ca5,_0x5b27d0={}){const _0x56e64d=_0xe09ee2;if(_0x5b27d0[_0x56e64d(0x173)+'e'])return null;const _0x144117=createCacheKey(_0x136ca5),_0x579f3d=STORE_CACHE['get'](_0x144117);if(!_0x579f3d)return null;if(Date[_0x56e64d(0x31f)]()-_0x579f3d[_0x56e64d(0x132)]>SESSION_STORE_TTL_MS)return STORE_CACHE[_0x56e64d(0x3c1)](_0x144117),null;return isCloneRequested(_0x5b27d0)?cloneStoreObject(_0x579f3d[_0x56e64d(0x380)]):_0x579f3d[_0x56e64d(0x380)];}function writeCachedStore(_0x37ddae,_0x46836f){const _0x325cb5=_0xe09ee2;STORE_CACHE[_0x325cb5(0x341)](createCacheKey(_0x37ddae),{'store':_0x46836f,'storedAt':Date[_0x325cb5(0x31f)]()});}function invalidateCachedStore(_0x6c6b03){const _0x566b7e=_0xe09ee2;STORE_CACHE[_0x566b7e(0x3c1)](createCacheKey(_0x6c6b03));}function cloneJsonValue(_0x54fca9){const _0x422ca7=_0xe09ee2;if(_0x54fca9===undefined)return undefined;if(_0x54fca9===null)return null;const _0x54767d=JSON[_0x422ca7(0x1f4)+'y'](_0x54fca9);return _0x54767d===undefined?undefined:JSON[_0x422ca7(0x1db)](_0x54767d);}function coerceSectionKind(_0x3d1410){const _0x4cc10e=_0xe09ee2;if(Array[_0x4cc10e(0x3a3)](_0x3d1410))return _0x4cc10e(0x130);if(_0x3d1410===null)return _0x4cc10e(0x30c);if(typeof _0x3d1410===_0x4cc10e(0x259))return _0x4cc10e(0x259);if(typeof _0x3d1410===_0x4cc10e(0x371)&&Number[_0x4cc10e(0x3d9)](_0x3d1410))return _0x4cc10e(0x371);if(typeof _0x3d1410===_0x4cc10e(0x309))return _0x4cc10e(0x309);return _0x4cc10e(0x38d);}function listMigrationFilesSync(){const _0x234dd6=_0xe09ee2,_0x2718cc=readdirSync(MIGRATIONS_DIR,{'withFileTypes':!![]});return _0x2718cc[_0x234dd6(0x157)](_0x47c7d1=>_0x47c7d1['isFile']()&&_0x47c7d1['name'][_0x234dd6(0x1ec)](_0x234dd6(0x351)))[_0x234dd6(0x35c)](_0x3d4b26=>_0x3d4b26[_0x234dd6(0x27b)])[_0x234dd6(0x2a1)]();}function extractAgentIdFromSessionKey(_0x4b602b){const _0x56c3b9=_0xe09ee2,_0x59775c=String(_0x4b602b||'')[_0x56c3b9(0x1cc)](':'),_0x3c6a44=_0x59775c[0x1]?.[_0x56c3b9(0x298)]();return _0x3c6a44||_0x56c3b9(0x19d);}function legacySessionJsonPath(_0x5bcc9c,_0x3eb237=_0xe09ee2(0x19d)){const _0x1807de=_0xe09ee2;return join(_0x5bcc9c,_0x1807de(0x336),_0x3eb237,_0x1807de(0x179),_0x1807de(0x179)+_0x1807de(0x349));}function touchSessionStoreMarkerSync(_0x34f051){const _0x4d45d3=_0xe09ee2,_0x3b1f42=String(_0x34f051||'')[_0x4d45d3(0x298)]();if(!_0x3b1f42)return;try{mkdirSync(dirname(_0x3b1f42),{'recursive':!![]});if(!existsSync(_0x3b1f42)){writeFileSync(_0x3b1f42,_0x4d45d3(0x1d4),{'mode':0x180});return;}const _0x3ac645=new Date();utimesSync(_0x3b1f42,_0x3ac645,_0x3ac645);}catch{}}function writeLegacySessionJsonMirrorSync(_0x340be3,_0x3c4357){const _0x1fa2f6=_0xe09ee2,_0x42374c=String(_0x340be3||'')['trim']();if(!_0x42374c)return;try{mkdirSync(dirname(_0x42374c),{'recursive':!![]}),writeFileSync(_0x42374c,JSON[_0x1fa2f6(0x1f4)+'y'](_0x3c4357||{},null,0x2)+'\x0a',{'mode':0x180});}catch{}}function readLegacySessionJsonSync(_0x1eecf9){const _0x52de78=_0xe09ee2;try{return asRecord(JSON['parse'](readFileSync(_0x1eecf9,_0x52de78(0x1b0))));}catch{return{};}}function rowToSessionSummary(_0x1e7a43){const _0x48173a=_0xe09ee2;if(!_0x1e7a43)return null;const _0x2a1598={'agentId':String(_0x1e7a43['agent_id']),'sessionKey':String(_0x1e7a43['session_'+_0x48173a(0x1b9)])};for(const [_0xe3f1b3,_0xd3d0be,_0xc74c8f]of CORE_FIELD_SPECS){const _0x5cd4b1=_0x1e7a43[_0xd3d0be];if(_0x5cd4b1===null||_0x5cd4b1===undefined)continue;if(_0xc74c8f===_0x48173a(0x309)){_0x2a1598[_0xe3f1b3]=fromSqliteBoolean(_0x5cd4b1);continue;}_0x2a1598[_0xe3f1b3]=_0xc74c8f===_0x48173a(0x371)?Number(_0x5cd4b1):String(_0x5cd4b1);}return _0x2a1598;}function buildCoreRecord(_0x3ad470,_0x185de9,_0x196bf0){const _0x20fce4=_0xe09ee2,_0x14d765={'agent_id':_0x3ad470,'session_key':_0x185de9};for(const [_0x22a76e,_0x44bac5,_0x37fa5f]of CORE_FIELD_SPECS){const _0x4afd0b=_0x196bf0[_0x22a76e];if(_0x37fa5f===_0x20fce4(0x309)){const _0x4eee81=normalizeBoolean(_0x4afd0b);_0x14d765[_0x44bac5]=_0x4eee81===null?null:toSqliteBoolean(_0x4eee81);continue;}if(_0x37fa5f===_0x20fce4(0x371)){_0x14d765[_0x44bac5]=normalizeNumber(_0x4afd0b);continue;}_0x14d765[_0x44bac5]=typeof _0x4afd0b===_0x20fce4(0x259)?_0x4afd0b:null;}return _0x14d765;}function collectSections(_0x8920b6){const _0x134dcb=_0xe09ee2,_0x2e99d3=[];for(const [_0x5c5308,_0x480813]of Object['entries'](asRecord(_0x8920b6))){if(_0x5c5308===_0x134dcb(0x374)||_0x5c5308===_0x134dcb(0x287)+'ey'||CORE_FIELD_NAMES[_0x134dcb(0x28c)](_0x5c5308))continue;if(_0x480813===undefined)continue;const _0x42b697=cloneJsonValue(_0x480813);if(_0x42b697===undefined)continue;_0x2e99d3[_0x134dcb(0x3bd)]({'name':_0x5c5308,'value':_0x42b697,'kind':coerceSectionKind(_0x42b697)});}return _0x2e99d3;}function materializeNode(_0x2b2da1,_0x46bdc6,_0xefbcf9,_0x13fd9d=null,_0x23fbb8=null,_0x701e74=null){const _0x499585=_0xe09ee2;if(Array[_0x499585(0x3a3)](_0xefbcf9)){const {lastInsertRowid:_0x3b41bf}=_0x2b2da1[_0x499585(0x355)](_0x499585(0x255)+_0x499585(0x314)+'INTO\x20ses'+'sion_sec'+'tion_nod'+_0x499585(0x2bf)+'\x20\x20\x20\x20\x20\x20\x20s'+_0x499585(0x27e)+'d,\x20paren'+_0x499585(0x291)+_0x499585(0x201)+_0x499585(0x16e)+'ay_index'+_0x499585(0x271)+'ind\x0a\x20\x20\x20\x20'+'\x20\x20\x20\x20)\x20VA'+_0x499585(0x3b2)+_0x499585(0x321)+_0x499585(0x369)+'\x20\x20\x20')['run'](_0x46bdc6,_0x13fd9d,_0x23fbb8,_0x701e74,_0x499585(0x130));_0xefbcf9[_0x499585(0x269)]((_0xf08c44,_0x24f942)=>materializeNode(_0x2b2da1,_0x46bdc6,_0xf08c44,Number(_0x3b41bf),null,_0x24f942));return;}if(_0xefbcf9&&typeof _0xefbcf9===_0x499585(0x38d)){const {lastInsertRowid:_0x1ead28}=_0x2b2da1[_0x499585(0x355)](_0x499585(0x255)+_0x499585(0x314)+'INTO\x20ses'+'sion_sec'+_0x499585(0x2b9)+_0x499585(0x2bf)+_0x499585(0x231)+_0x499585(0x27e)+_0x499585(0x153)+_0x499585(0x291)+'d,\x20node_'+'key,\x20arr'+_0x499585(0x281)+_0x499585(0x271)+_0x499585(0x27d)+_0x499585(0x164)+_0x499585(0x3b2)+_0x499585(0x321)+_0x499585(0x369)+_0x499585(0x382))[_0x499585(0x31e)](_0x46bdc6,_0x13fd9d,_0x23fbb8,_0x701e74,_0x499585(0x38d));for(const [_0x3eda88,_0x5bdb2b]of Object['entries'](asRecord(_0xefbcf9))){materializeNode(_0x2b2da1,_0x46bdc6,_0x5bdb2b,Number(_0x1ead28),_0x3eda88,null);}return;}const _0x13b83b=normalizeScalarNode(_0xefbcf9)??{'node_kind':_0x499585(0x30c)};_0x2b2da1[_0x499585(0x355)](_0x499585(0x272)+_0x499585(0x326)+_0x499585(0x39e)+_0x499585(0x3c8)+_0x499585(0x37a)+_0x499585(0x324)+_0x499585(0x27e)+'d,\x0a\x20\x20\x20\x20\x20'+'\x20parent_'+_0x499585(0x2f4)+_0x499585(0x178)+_0x499585(0x22e)+_0x499585(0x389)+'rray_ind'+_0x499585(0x1b6)+_0x499585(0x17e)+_0x499585(0x160)+_0x499585(0x3a1)+_0x499585(0x111)+'\x20\x20\x20\x20\x20num'+'ber_valu'+_0x499585(0x267)+'\x20boolean'+_0x499585(0x342)+_0x499585(0x365)+_0x499585(0x2a0)+_0x499585(0x1fb)+_0x499585(0x321)+_0x499585(0x147))[_0x499585(0x31e)](_0x46bdc6,_0x13fd9d,_0x23fbb8,_0x701e74,_0x13b83b[_0x499585(0x19f)+'d'],_0x13b83b[_0x499585(0x397)+'ue']??null,_0x13b83b[_0x499585(0x10f)+_0x499585(0x393)]??null,_0x13b83b[_0x499585(0x2fd)+_0x499585(0x129)]??null);}function nodeRowsToValue(_0x269056,_0x541ab5=null){const _0x628b26=_0xe09ee2,_0x368a99=_0x269056['filter'](_0x5261af=>_0x541ab5===null?_0x5261af[_0x628b26(0x2f9)+_0x628b26(0x385)]===null:Number(_0x5261af[_0x628b26(0x2f9)+_0x628b26(0x385)])===_0x541ab5)['sort']((_0x595578,_0x5a9ee1)=>{const _0x412a01=_0x628b26,_0x57995c=_0x595578[_0x412a01(0x1f8)+_0x412a01(0x14a)]===null||_0x595578['array_in'+_0x412a01(0x14a)]===undefined?Number[_0x412a01(0x1ca)+_0x412a01(0x2ce)]:Number(_0x595578[_0x412a01(0x1f8)+'dex']),_0x48cb72=_0x5a9ee1['array_in'+_0x412a01(0x14a)]===null||_0x5a9ee1[_0x412a01(0x1f8)+'dex']===undefined?Number[_0x412a01(0x1ca)+_0x412a01(0x2ce)]:Number(_0x5a9ee1[_0x412a01(0x1f8)+_0x412a01(0x14a)]);if(_0x57995c!==_0x48cb72)return _0x57995c-_0x48cb72;return String(_0x595578[_0x412a01(0x28b)]||'')[_0x412a01(0x35a)+_0x412a01(0x253)](String(_0x5a9ee1[_0x412a01(0x28b)]||''));});if(_0x368a99[_0x628b26(0x323)]===0x0)return null;if(_0x368a99[_0x628b26(0x323)]===0x1&&_0x368a99[0x0][_0x628b26(0x2f9)+_0x628b26(0x385)]===null)return nodeRowToValue(_0x368a99[0x0],_0x269056);const _0x116af9=_0x368a99[_0x628b26(0x31a)](_0x5883eb=>_0x5883eb['array_in'+_0x628b26(0x14a)]!==null&&_0x5883eb[_0x628b26(0x1f8)+'dex']!==undefined);if(_0x116af9)return _0x368a99[_0x628b26(0x35c)](_0x108c96=>nodeRowToValue(_0x108c96,_0x269056));const _0x5f4075={};for(const _0x141d32 of _0x368a99){if(!_0x141d32['node_key'])continue;_0x5f4075[String(_0x141d32[_0x628b26(0x28b)])]=nodeRowToValue(_0x141d32,_0x269056);}return _0x5f4075;}function nodeRowToValue(_0x3d759b,_0x4a573c){const _0x720592=_0xe09ee2;switch(_0x3d759b[_0x720592(0x19f)+'d']){case'object':return nodeRowsToValue(_0x4a573c,Number(_0x3d759b['id']))??{};case _0x720592(0x130):return nodeRowsToValue(_0x4a573c,Number(_0x3d759b['id']))??[];case'string':return _0x3d759b[_0x720592(0x397)+'ue']??'';case'number':return _0x3d759b[_0x720592(0x10f)+_0x720592(0x393)]===null||_0x3d759b[_0x720592(0x10f)+'alue']===undefined?null:Number(_0x3d759b[_0x720592(0x10f)+'alue']);case _0x720592(0x309):return fromSqliteBoolean(_0x3d759b[_0x720592(0x2fd)+_0x720592(0x129)]);case _0x720592(0x30c):default:return null;}}function sectionRowToValue(_0x39997d,_0x3a4f10){const _0x5d3253=_0xe09ee2;if(!_0x39997d)return null;switch(_0x39997d['section_'+_0x5d3253(0x3da)]){case'string':return _0x39997d['text_val'+'ue']??'';case _0x5d3253(0x371):return _0x39997d[_0x5d3253(0x10f)+_0x5d3253(0x393)]===null||_0x39997d[_0x5d3253(0x10f)+_0x5d3253(0x393)]===undefined?null:Number(_0x39997d[_0x5d3253(0x10f)+_0x5d3253(0x393)]);case _0x5d3253(0x309):return fromSqliteBoolean(_0x39997d['boolean_'+_0x5d3253(0x129)]);case _0x5d3253(0x30c):return null;case _0x5d3253(0x130):case _0x5d3253(0x38d):default:return nodeRowsToValue(_0x3a4f10,null)??(_0x39997d[_0x5d3253(0x292)+_0x5d3253(0x3da)]===_0x5d3253(0x130)?[]:{});}}function isEmptyObjectValue(_0x3d59c1){const _0x13488a=_0xe09ee2;return _0x3d59c1&&typeof _0x3d59c1===_0x13488a(0x38d)&&!Array['isArray'](_0x3d59c1)&&Object['keys'](_0x3d59c1)[_0x13488a(0x323)]===0x0;}function buildSectionRecord(_0x42e37d){const _0x527314=_0xe09ee2,_0x548bc9=normalizeScalarNode(_0x42e37d[_0x527314(0x129)]);return{'section_kind':_0x42e37d['kind'],'text_value':_0x548bc9?.[_0x527314(0x397)+'ue']??null,'number_value':_0x548bc9?.['number_v'+_0x527314(0x393)]??null,'boolean_value':_0x548bc9?.[_0x527314(0x2fd)+_0x527314(0x129)]??null};}function extractAgentIdFromStorePath(_0x4c044f,_0x5078e4){const _0x2d83da=_0xe09ee2,_0x544990=String(_0x5078e4||'')[_0x2d83da(0x16f)+'ll']('\x5c','/'),_0x23af86=String(_0x4c044f||'')[_0x2d83da(0x16f)+'ll']('\x5c','/'),_0x14ca59=_0x23af86+_0x2d83da(0x1ac);if(!_0x544990[_0x2d83da(0x1eb)+'th'](_0x14ca59))return'main';const _0x348df=_0x544990['slice'](_0x14ca59[_0x2d83da(0x323)]),_0x3ce308=_0x348df[_0x2d83da(0x1cc)]('/')[0x0]?.[_0x2d83da(0x298)]();return _0x3ce308||_0x2d83da(0x19d);}function rowsToSessionKeys(_0x5efecf){const _0x1a9feb=_0xe09ee2;return _0x5efecf['map'](_0x281fc5=>String(_0x281fc5[_0x1a9feb(0x188)+_0x1a9feb(0x1b9)]||'')[_0x1a9feb(0x298)]())[_0x1a9feb(0x157)](Boolean);}function rowToSessionLocalMetadata(_0x1e3586){const _0xf003dd=_0xe09ee2;if(!_0x1e3586)return null;const _0x17ee1f=String(_0x1e3586[_0xf003dd(0x188)+_0xf003dd(0x1b9)]||'')[_0xf003dd(0x298)]();if(!_0x17ee1f)return null;return{'sessionKey':_0x17ee1f,'customName':typeof _0x1e3586[_0xf003dd(0x1d5)+'ame']===_0xf003dd(0x259)&&_0x1e3586['custom_n'+_0xf003dd(0x33d)]['trim']()?_0x1e3586['custom_n'+_0xf003dd(0x33d)]['trim']():'','pinned':Number(_0x1e3586[_0xf003dd(0x20d)])===SQL_BOOLEAN_TRUE,'pinnedOrder':_0x1e3586[_0xf003dd(0x118)+'rder']===null||_0x1e3586[_0xf003dd(0x118)+_0xf003dd(0x18a)]===undefined?null:Number(_0x1e3586[_0xf003dd(0x118)+_0xf003dd(0x18a)])};}function runTransactionSync(_0x59084e,_0xaf997){const _0x58136e=_0xe09ee2;_0x59084e[_0x58136e(0x227)](_0x58136e(0x23c)+_0x58136e(0x1ed));try{const _0x1b19eb=_0xaf997();return _0x59084e[_0x58136e(0x227)](_0x58136e(0x1a8)),_0x1b19eb;}catch(_0x430bb8){try{_0x59084e[_0x58136e(0x227)](_0x58136e(0x34e)+';');}catch{}throw _0x430bb8;}}export function createSessionSqliteStore({stateDir:_0x64ae96,dbPath:dbPath=storeDbPath(_0x64ae96)}){const _0x525a05=_0xe09ee2;let _0x5e3d77=null,_0x259d66=![];function _0x5074d5(){const _0x36d1d1=_0x4ed3;if(_0x5e3d77)return _0x5e3d77;return _0x5e3d77=new DatabaseSync(dbPath),_0x5e3d77['exec'](_0x36d1d1(0x123)+_0x36d1d1(0x10d)+_0x36d1d1(0x1ee)+'L;'),_0x5e3d77['exec']('PRAGMA\x20s'+_0x36d1d1(0x2a2)+_0x36d1d1(0x386)+_0x36d1d1(0x377)),_0x5e3d77['exec'](_0x36d1d1(0x3c2)+_0x36d1d1(0x24b)+_0x36d1d1(0x1a6)+';'),_0x5e3d77;}function _0xb2c908(){const _0x10fcb4=_0x4ed3,_0x2fffe9=_0x5074d5();_0x2fffe9[_0x10fcb4(0x227)](_0x10fcb4(0x34b)+_0x10fcb4(0x2f3)+_0x10fcb4(0x2fc)+_0x10fcb4(0x2de)+_0x10fcb4(0x288)+_0x10fcb4(0x263)+_0x10fcb4(0x2a3)+'ns\x20(\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20id\x20'+_0x10fcb4(0x3df)+_0x10fcb4(0x2e8)+_0x10fcb4(0x2c7)+_0x10fcb4(0x18e)+_0x10fcb4(0x126)+_0x10fcb4(0x295)+_0x10fcb4(0x284)+'NOT\x20NULL'+_0x10fcb4(0x218)+_0x10fcb4(0x255)+_0x10fcb4(0x151)+_0x10fcb4(0x205)+_0x10fcb4(0x142)+_0x10fcb4(0x21a)+'T\x20CURREN'+_0x10fcb4(0x2e5)+_0x10fcb4(0x154)+_0x10fcb4(0x15f)+'\x20');const _0x23782c=_0x2fffe9[_0x10fcb4(0x355)]('SELECT\x20v'+_0x10fcb4(0x2d0)+_0x10fcb4(0x180)+'ion_stor'+_0x10fcb4(0x17d)+_0x10fcb4(0x3ac)+_0x10fcb4(0x332)+_0x10fcb4(0x265))[_0x10fcb4(0x181)](),_0x26e524=new Set(_0x23782c['map'](_0x1ce97d=>String(_0x1ce97d[_0x10fcb4(0x189)]))),_0xced8c5=listMigrationFilesSync();for(const _0x26c482 of _0xced8c5){if(_0x26e524[_0x10fcb4(0x28c)](_0x26c482))continue;const _0x1ab1e4=readFileSync(join(MIGRATIONS_DIR,_0x26c482),_0x10fcb4(0x1b0));_0x2fffe9[_0x10fcb4(0x227)](_0x1ab1e4),_0x2fffe9['prepare'](_0x10fcb4(0x255)+_0x10fcb4(0x175)+_0x10fcb4(0x2ee)+_0x10fcb4(0x1a0)+'tore_mig'+_0x10fcb4(0x134)+_0x10fcb4(0x232)+_0x10fcb4(0x251)+'\x20\x20\x20\x20VALU'+_0x10fcb4(0x21c)+_0x10fcb4(0x1cb))['run'](_0x26c482);}}function _0x1fc789(_0x26c99e,_0x49f3ee,_0x33bd25,_0x94e4e1){const _0x399d91=_0x4ed3,_0x2773d7=normalizeStoreSessionKey(_0x33bd25),_0x4eccb9=buildCoreRecord(_0x49f3ee,_0x2773d7,asRecord(_0x94e4e1));_0x26c99e[_0x399d91(0x355)]('\x0a\x20\x20\x20\x20\x20\x20I'+'NSERT\x20IN'+_0x399d91(0x12e)+'on_recor'+'ds\x20(\x0a\x20\x20\x20'+_0x399d91(0x381)+_0x399d91(0x15c)+_0x399d91(0x231)+_0x399d91(0x119)+_0x399d91(0x128)+_0x399d91(0x391)+_0x399d91(0x335)+_0x399d91(0x3a7)+_0x399d91(0x1e4)+'\x20\x20\x20\x20\x20\x20\x20s'+_0x399d91(0x29b)+_0x399d91(0x11a)+_0x399d91(0x36b)+_0x399d91(0x20a)+'\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x399d91(0x39e)+'_started'+_0x399d91(0x3de)+_0x399d91(0x3d2)+_0x399d91(0x2e2)+_0x399d91(0x280)+_0x399d91(0x347)+_0x399d91(0x338)+_0x399d91(0x2af)+_0x399d91(0x12b)+_0x399d91(0x3b0)+'ast_run,'+_0x399d91(0x255)+_0x399d91(0x36d)+_0x399d91(0x115)+_0x399d91(0x146)+_0x399d91(0x1c4)+_0x399d91(0x347)+_0x399d91(0x22f)+_0x399d91(0x347)+_0x399d91(0x12f)+'d_at,\x0a\x20\x20'+'\x20\x20\x20\x20\x20\x20en'+_0x399d91(0x1b8)+_0x399d91(0x3a7)+_0x399d91(0x2ba)+'ms,\x0a\x20\x20\x20\x20'+'\x20\x20\x20\x20mode'+_0x399d91(0x195)+_0x399d91(0x158)+_0x399d91(0x379)+_0x399d91(0x378)+_0x399d91(0x316)+'xt_token'+'s,\x0a\x20\x20\x20\x20\x20'+_0x399d91(0x1b4)+_0x399d91(0x35b)+_0x399d91(0x255)+'\x20output_'+_0x399d91(0x3ae)+_0x399d91(0x3a7)+_0x399d91(0x13d)+_0x399d91(0x310)+'\x20\x20\x20\x20cach'+_0x399d91(0x38b)+_0x399d91(0x255)+_0x399d91(0x262)+_0x399d91(0x135)+_0x399d91(0x2bc)+_0x399d91(0x320)+'al_token'+_0x399d91(0x3a4)+'\x20\x20\x20total'+_0x399d91(0x1c6)+_0x399d91(0x3cf)+_0x399d91(0x3bc)+'pdated_r'+'ow_at\x0a\x20\x20'+_0x399d91(0x164)+'LUES\x20(\x0a\x20'+_0x399d91(0x294)+'agent_id'+_0x399d91(0x347)+'\x20\x20@sessi'+'on_key,\x0a'+_0x399d91(0x3a7)+_0x399d91(0x3ca)+_0x399d91(0x192)+_0x399d91(0x2d5)+_0x399d91(0x10a)+'\x20\x20\x20\x20\x20@se'+_0x399d91(0x17f)+_0x399d91(0x32e)+_0x399d91(0x1ad)+_0x399d91(0x20a)+'\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x399d91(0x163)+_0x399d91(0x39b)+_0x399d91(0x28e)+_0x399d91(0x24d)+_0x399d91(0x199)+_0x399d91(0x353)+_0x399d91(0x176)+'\x20\x20\x20\x20@sys'+_0x399d91(0x350)+_0x399d91(0x347)+_0x399d91(0x2ed)+_0x399d91(0x1f2)+_0x399d91(0x3db)+_0x399d91(0x396)+_0x399d91(0x3dd)+_0x399d91(0x255)+'\x20@last_c'+_0x399d91(0x166)+_0x399d91(0x3a7)+_0x399d91(0x21e)+'\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20@starte'+_0x399d91(0x28e)+_0x399d91(0x28d)+'nded_at,'+_0x399d91(0x255)+_0x399d91(0x2ae)+'e_ms,\x0a\x20\x20'+_0x399d91(0x1c2)+(_0x399d91(0x303)+_0x399d91(0x2bd)+'\x20\x20\x20\x20\x20\x20\x20@'+'model,\x0a\x20'+_0x399d91(0x294)+_0x399d91(0x1a2)+_0x399d91(0x3ae)+_0x399d91(0x3a7)+_0x399d91(0x35f)+_0x399d91(0x3b5)+_0x399d91(0x294)+_0x399d91(0x2c9)+'okens,\x0a\x20'+_0x399d91(0x294)+'cache_re'+_0x399d91(0x310)+_0x399d91(0x219)+'he_write'+_0x399d91(0x347)+_0x399d91(0x3b7)+'ated_cos'+_0x399d91(0x35e)+'\x20\x20\x20\x20\x20\x20\x20@'+'total_to'+_0x399d91(0x109)+'\x20\x20\x20\x20\x20\x20@t'+_0x399d91(0x2d1)+'ens_fres'+_0x399d91(0x13f)+_0x399d91(0x14d)+'NT_TIMES'+'TAMP\x0a\x20\x20\x20'+_0x399d91(0x235)+_0x399d91(0x277)+_0x399d91(0x366)+_0x399d91(0x119)+_0x399d91(0x2b8)+_0x399d91(0x337)+_0x399d91(0x11c)+_0x399d91(0x36e)+_0x399d91(0x230)+'luded.ag'+_0x399d91(0x208)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x399d91(0x188)+_0x399d91(0x230)+_0x399d91(0x3b8)+_0x399d91(0x17c)+_0x399d91(0x347)+'\x20\x20label\x20'+_0x399d91(0x10b)+'ed.label'+_0x399d91(0x347)+_0x399d91(0x2df)+_0x399d91(0x318)+_0x399d91(0x1e2)+_0x399d91(0x22c)+_0x399d91(0x25b)+_0x399d91(0x3a7)+_0x399d91(0x202)+_0x399d91(0x145)+'luded.up'+_0x399d91(0x31c)+',\x0a\x20\x20\x20\x20\x20\x20'+_0x399d91(0x2df)+'n_starte'+_0x399d91(0x11d)+_0x399d91(0x20c)+_0x399d91(0x188)+_0x399d91(0x171)+_0x399d91(0x176)+_0x399d91(0x146)+_0x399d91(0x352)+_0x399d91(0x2f5)+'=\x20exclud'+'ed.last_'+_0x399d91(0x2cd)+_0x399d91(0x346)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x399d91(0x2c4)+_0x399d91(0x340)+'cluded.s'+_0x399d91(0x1bf)+_0x399d91(0x296)+'\x20\x20\x20\x20abor'+_0x399d91(0x239)+_0x399d91(0x35d)+_0x399d91(0x20c)+_0x399d91(0x1a1)+'last_run'+_0x399d91(0x347)+_0x399d91(0x383)+_0x399d91(0x21f)+_0x399d91(0x124)+_0x399d91(0x32d)+',\x0a\x20\x20\x20\x20\x20\x20'+_0x399d91(0x3c4)+_0x399d91(0x1de)+_0x399d91(0x1e2)+_0x399d91(0x1d7)+'hannel,\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x399d91(0x2f2)+'\x20exclude'+_0x399d91(0x307)+',\x0a\x20\x20\x20\x20\x20\x20'+_0x399d91(0x12f)+_0x399d91(0x11d)+'xcluded.'+_0x399d91(0x171)+_0x399d91(0x176)+'\x20\x20\x20\x20ende'+_0x399d91(0x11d)+_0x399d91(0x20c)+_0x399d91(0x125)+',\x0a\x20\x20\x20\x20\x20\x20'+_0x399d91(0x354)+_0x399d91(0x322)+_0x399d91(0x20c)+'runtime_'+_0x399d91(0x25c)+_0x399d91(0x379)+_0x399d91(0x195)+_0x399d91(0x311)+_0x399d91(0x39f))+(_0x399d91(0x38c)+_0x399d91(0x304)+_0x399d91(0x1c8)+_0x399d91(0x20b)+_0x399d91(0x1d0)+'odel,\x0a\x20\x20'+_0x399d91(0x3ce)+_0x399d91(0x3d0)+_0x399d91(0x1b7)+_0x399d91(0x20c)+_0x399d91(0x1a2)+_0x399d91(0x3ae)+_0x399d91(0x3a7)+'input_to'+_0x399d91(0x1b7)+_0x399d91(0x20c)+_0x399d91(0x329)+_0x399d91(0x109)+'\x20\x20\x20\x20\x20\x20ou'+_0x399d91(0x2a7)+'ens\x20=\x20ex'+_0x399d91(0x182)+_0x399d91(0x1c9)+_0x399d91(0x109)+_0x399d91(0x226)+_0x399d91(0x3b6)+'\x20=\x20exclu'+_0x399d91(0x198)+_0x399d91(0x1da)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'cache_wr'+_0x399d91(0x204)+_0x399d91(0x124)+'ache_wri'+_0x399d91(0x16d)+_0x399d91(0x1c0)+_0x399d91(0x1a3)+_0x399d91(0x2d2)+_0x399d91(0x1e2)+_0x399d91(0x149)+'ted_cost'+_0x399d91(0x1d1)+'\x20\x20\x20\x20\x20\x20to'+_0x399d91(0x215)+_0x399d91(0x370)+_0x399d91(0x1d3)+'tal_toke'+_0x399d91(0x221)+_0x399d91(0x237)+_0x399d91(0x220)+_0x399d91(0x2ec)+_0x399d91(0x1e2)+'d.total_'+_0x399d91(0x2e6)+_0x399d91(0x155)+'\x20\x20\x20\x20\x20\x20up'+_0x399d91(0x37e)+'w_at\x20=\x20C'+_0x399d91(0x196)+_0x399d91(0x2dd)+_0x399d91(0x2a8)))[_0x399d91(0x31e)](_0x4eccb9);const _0x11cdb6=_0x26c99e[_0x399d91(0x355)]('SELECT\x20i'+_0x399d91(0x1fd)+_0x399d91(0x29f)+'ecords\x20W'+'HERE\x20ses'+_0x399d91(0x1cd)+'\x20=\x20?')[_0x399d91(0x22b)](_0x2773d7),_0x1aec13=Number(_0x11cdb6['id']);_0x26c99e[_0x399d91(0x355)](_0x399d91(0x1c7)+_0x399d91(0x180)+_0x399d91(0x17b)+_0x399d91(0x328)+'s\x20WHERE\x20'+_0x399d91(0x292)+_0x399d91(0x32f)+_0x399d91(0x3a7)+'SELECT\x20i'+_0x399d91(0x1fd)+'ession_s'+_0x399d91(0x240)+_0x399d91(0x185)+_0x399d91(0x372)+_0x399d91(0x1cf)+_0x399d91(0x299)+'\x20\x20)')[_0x399d91(0x31e)](_0x1aec13),_0x26c99e[_0x399d91(0x355)](_0x399d91(0x1c7)+_0x399d91(0x180)+'ion_sect'+'ions\x20WHE'+_0x399d91(0x30b)+_0x399d91(0x1ae)+_0x399d91(0x1d9))[_0x399d91(0x31e)](_0x1aec13);for(const _0x404311 of collectSections(_0x94e4e1)){const _0x56ca5c=buildSectionRecord(_0x404311),{lastInsertRowid:_0x122231}=_0x26c99e[_0x399d91(0x355)](_0x399d91(0x255)+_0x399d91(0x175)+_0x399d91(0x2ee)+_0x399d91(0x1a0)+_0x399d91(0x240)+_0x399d91(0x25e)+_0x399d91(0x249)+_0x399d91(0x372)+'cord_id,'+'\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x399d91(0x186)+_0x399d91(0x2c3)+'e,\x0a\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20\x20\x20s'+_0x399d91(0x2d4)+_0x399d91(0x160)+_0x399d91(0x3a7)+_0x399d91(0x1bd)+_0x399d91(0x1bc)+_0x399d91(0x3a7)+'\x20number_'+_0x399d91(0x111)+_0x399d91(0x3a7)+_0x399d91(0x131)+_0x399d91(0x325)+_0x399d91(0x255)+_0x399d91(0x365)+_0x399d91(0x2a0)+_0x399d91(0x1fb)+_0x399d91(0x3c7)+_0x399d91(0x1cb))[_0x399d91(0x31e)](_0x1aec13,_0x404311[_0x399d91(0x27b)],_0x56ca5c[_0x399d91(0x292)+_0x399d91(0x3da)],_0x56ca5c[_0x399d91(0x397)+'ue'],_0x56ca5c[_0x399d91(0x10f)+_0x399d91(0x393)],_0x56ca5c[_0x399d91(0x2fd)+_0x399d91(0x129)]);(_0x404311[_0x399d91(0x3da)]===_0x399d91(0x38d)||_0x404311[_0x399d91(0x3da)]===_0x399d91(0x130))&&materializeNode(_0x26c99e,Number(_0x122231),_0x404311[_0x399d91(0x129)]);}}function _0x55fd98(_0x4e893f,_0x5c4798,_0x1b7a30){const _0x32dad0=_0x5074d5();runTransactionSync(_0x32dad0,()=>{_0x1fc789(_0x32dad0,_0x4e893f,_0x5c4798,_0x1b7a30);});}function _0x3551c5(_0x26691d,_0xd6c427){const _0x385734=_0x4ed3,_0x115221=existsSync(_0xd6c427);if(!_0x115221)return 0x0;const _0x3ce796=statSync(_0xd6c427),_0x2f09fc=_0x5074d5(),_0x3e93cb=_0x2f09fc[_0x385734(0x355)](_0x385734(0x207)+'d\x20FROM\x20s'+_0x385734(0x1a0)+_0x385734(0x15a)+_0x385734(0x1ba)+_0x385734(0x18b)+_0x385734(0x11f)+_0x385734(0x236)+'?')[_0x385734(0x22b)](_0xd6c427);if(_0x3e93cb)return 0x0;const _0x3ba4b8=readLegacySessionJsonSync(_0xd6c427);let _0x14cc9b=0x0;for(const [_0x4106db,_0x4e9db7]of Object['entries'](_0x3ba4b8)){if(!_0x4106db)continue;_0x55fd98(_0x26691d,_0x4106db,_0x4e9db7),_0x14cc9b+=0x1;}return _0x2f09fc[_0x385734(0x355)](_0x385734(0x255)+_0x385734(0x314)+_0x385734(0x3a5)+_0x385734(0x152)+_0x385734(0x222)+_0x385734(0x133)+'s\x20(\x0a\x20\x20\x20\x20'+_0x385734(0x32c)+'urce_pat'+_0x385734(0x13f)+_0x385734(0x381)+'nt_id,\x0a\x20'+_0x385734(0x3a7)+_0x385734(0x1b1)+_0x385734(0x360)+_0x385734(0x347)+_0x385734(0x14b)+'ce_size_'+_0x385734(0x3aa)+_0x385734(0x3a7)+_0x385734(0x1f6)+_0x385734(0x23f)+_0x385734(0x1e3)+_0x385734(0x3a7)+_0x385734(0x15d)+'\x20(?,\x20?,\x20'+_0x385734(0x245)+'\x0a\x20\x20\x20\x20\x20\x20')[_0x385734(0x31e)](_0xd6c427,_0x26691d,Number(_0x3ce796[_0x385734(0x3d5)])||null,Number(_0x3ce796[_0x385734(0x1f1)])||null,_0x14cc9b),_0x14cc9b;}function _0x3017ae(){const _0x2deece=_0x4ed3,_0x2bae50=join(_0x64ae96,'agents');if(!existsSync(_0x2bae50))return;const _0x3543cb=readdirSync(_0x2bae50,{'withFileTypes':!![]});for(const _0x19e8fd of _0x3543cb){if(!_0x19e8fd[_0x2deece(0x22a)+_0x2deece(0x136)]())continue;const _0x10bfbd=_0x19e8fd['name'];_0x3551c5(_0x10bfbd,legacySessionJsonPath(_0x64ae96,_0x10bfbd));}}function _0x1be115(){if(_0x259d66)return;mkdirSync(dirname(dbPath),{'recursive':!![]}),_0xb2c908(),_0x3017ae(),_0x259d66=!![];}async function _0x8e4799(){if(_0x259d66)return;await mkdir(dirname(dbPath),{'recursive':!![]}),_0x1be115();}async function _0x30f232(_0x21b85c){const _0x2ceb00=_0x4ed3;_0x1be115();const _0x5a4c23=normalizeStoreSessionKey(_0x21b85c),_0x28e327=_0x5074d5()[_0x2ceb00(0x355)](_0x2ceb00(0x255)+_0x2ceb00(0x214)+_0x2ceb00(0x3a7)+_0x2ceb00(0x197)+_0x2ceb00(0x3a7)+_0x2ceb00(0x3d4)+_0x2ceb00(0x347)+'\x20\x20\x20\x20sess'+'ion_key,'+_0x2ceb00(0x255)+_0x2ceb00(0x212)+'on_id,\x0a\x20'+_0x2ceb00(0x3a7)+_0x2ceb00(0x3a2)+_0x2ceb00(0x3a7)+_0x2ceb00(0x2df)+_0x2ceb00(0x25b)+_0x2ceb00(0x3a7)+_0x2ceb00(0x270)+_0x2ceb00(0x28e)+_0x2ceb00(0x3a7)+_0x2ceb00(0x188)+_0x2ceb00(0x171)+_0x2ceb00(0x176)+'\x20\x20\x20\x20\x20\x20la'+_0x2ceb00(0x3d6)+'action_a'+_0x2ceb00(0x1e5)+_0x2ceb00(0x14e)+_0x2ceb00(0x350)+_0x2ceb00(0x347)+'\x20\x20\x20\x20abor'+'ted_last'+'_run,\x0a\x20\x20'+_0x2ceb00(0x3a7)+'chat_typ'+_0x2ceb00(0x267)+_0x2ceb00(0x3d2)+_0x2ceb00(0x246)+'l,\x0a\x20\x20\x20\x20\x20'+_0x2ceb00(0x1f3)+_0x2ceb00(0x184)+_0x2ceb00(0x231)+'tarted_a'+'t,\x0a\x20\x20\x20\x20\x20'+_0x2ceb00(0x1d8)+_0x2ceb00(0x315)+_0x2ceb00(0x3a7)+_0x2ceb00(0x243)+_0x2ceb00(0x26f)+_0x2ceb00(0x3ba)+_0x2ceb00(0x303)+_0x2ceb00(0x2bd)+_0x2ceb00(0x3a7)+'\x20model,\x0a'+_0x2ceb00(0x3a7)+_0x2ceb00(0x26c)+'t_tokens'+_0x2ceb00(0x347)+_0x2ceb00(0x2b6)+_0x2ceb00(0x394)+_0x2ceb00(0x347)+_0x2ceb00(0x1c3)+'ut_token'+_0x2ceb00(0x3a4)+_0x2ceb00(0x14c)+_0x2ceb00(0x319)+_0x2ceb00(0x255)+'\x20\x20\x20cache'+_0x2ceb00(0x2f1)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x2ceb00(0x30d)+_0x2ceb00(0x24f)+_0x2ceb00(0x1d1)+_0x2ceb00(0x3a7)+_0x2ceb00(0x3a8)+_0x2ceb00(0x109)+_0x2ceb00(0x3a7)+_0x2ceb00(0x3a8)+_0x2ceb00(0x3af)+'sh\x0a\x20\x20\x20\x20\x20'+_0x2ceb00(0x334)+_0x2ceb00(0x188)+_0x2ceb00(0x2b1)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'WHERE\x20se'+_0x2ceb00(0x120)+_0x2ceb00(0x286)+_0x2ceb00(0x140))[_0x2ceb00(0x22b)](_0x5a4c23);return _0x28e327?{'id':Number(_0x28e327['id']),'summary':rowToSessionSummary(_0x28e327)}:null;}function _0x3a8990(_0x2a0f41){const _0x242b2f=_0x4ed3;_0x1be115();const _0x38aa89=normalizeStoreSessionKey(_0x2a0f41),_0x4ea4f0=_0x5074d5()[_0x242b2f(0x355)](_0x242b2f(0x255)+_0x242b2f(0x214)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x242b2f(0x197)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x242b2f(0x3d4)+',\x0a\x20\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20sess'+_0x242b2f(0x261)+'\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x242b2f(0x212)+_0x242b2f(0x13a)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x242b2f(0x3a2)+_0x242b2f(0x3a7)+_0x242b2f(0x2df)+'n_file,\x0a'+_0x242b2f(0x3a7)+_0x242b2f(0x270)+_0x242b2f(0x28e)+_0x242b2f(0x3a7)+'session_'+_0x242b2f(0x171)+_0x242b2f(0x176)+'\x20\x20\x20\x20\x20\x20la'+_0x242b2f(0x3d6)+_0x242b2f(0x110)+'t,\x0a\x20\x20\x20\x20\x20'+_0x242b2f(0x14e)+'tem_sent'+',\x0a\x20\x20\x20\x20\x20\x20'+_0x242b2f(0x13e)+_0x242b2f(0x239)+_0x242b2f(0x187)+_0x242b2f(0x3a7)+_0x242b2f(0x2e0)+_0x242b2f(0x267)+'\x20\x20\x20\x20\x20las'+'t_channe'+_0x242b2f(0x378)+_0x242b2f(0x1f3)+_0x242b2f(0x184)+_0x242b2f(0x231)+'tarted_a'+_0x242b2f(0x1e5)+_0x242b2f(0x1d8)+'ed_at,\x0a\x20'+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x242b2f(0x243)+_0x242b2f(0x26f)+_0x242b2f(0x3ba)+_0x242b2f(0x303)+_0x242b2f(0x2bd)+_0x242b2f(0x3a7)+_0x242b2f(0x13c)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'\x20\x20contex'+_0x242b2f(0x394)+_0x242b2f(0x347)+_0x242b2f(0x2b6)+_0x242b2f(0x394)+_0x242b2f(0x347)+_0x242b2f(0x1c3)+_0x242b2f(0x29d)+_0x242b2f(0x3a4)+_0x242b2f(0x14c)+_0x242b2f(0x319)+'\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x242b2f(0x1b3)+_0x242b2f(0x2f1)+_0x242b2f(0x3a7)+'\x20\x20estima'+_0x242b2f(0x24f)+_0x242b2f(0x1d1)+_0x242b2f(0x3a7)+_0x242b2f(0x3a8)+'kens,\x0a\x20\x20'+_0x242b2f(0x3a7)+_0x242b2f(0x3a8)+_0x242b2f(0x3af)+_0x242b2f(0x2cf)+_0x242b2f(0x334)+_0x242b2f(0x188)+_0x242b2f(0x2b1)+_0x242b2f(0x3a7)+_0x242b2f(0x185)+'ssion_ke'+'y\x20=\x20?\x0a\x20\x20'+'\x20\x20\x20\x20')[_0x242b2f(0x22b)](_0x38aa89);return _0x4ea4f0?{'id':Number(_0x4ea4f0['id']),'summary':rowToSessionSummary(_0x4ea4f0)}:null;}async function _0x26496e(_0x3e7852){const _0x362ac2=_0x4ed3;return _0x1be115(),_0x5074d5()['prepare']('\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x362ac2(0x23a)+_0x362ac2(0x188)+_0x362ac2(0x1fe)+_0x362ac2(0x150)+_0x362ac2(0x39e)+'_records'+_0x362ac2(0x255)+_0x362ac2(0x2f7)+_0x362ac2(0x233)+_0x362ac2(0x299)+_0x362ac2(0x1e9)+_0x362ac2(0x29c)+'ated_at\x20'+'DESC,\x20id'+_0x362ac2(0x138)+_0x362ac2(0x140))[_0x362ac2(0x181)](_0x3e7852)[_0x362ac2(0x35c)](_0x1b6114=>String(_0x1b6114[_0x362ac2(0x188)+_0x362ac2(0x1b9)]||'')[_0x362ac2(0x298)]())[_0x362ac2(0x157)](Boolean);}async function _0x576c4f(_0x4d455d=[]){const _0x3d4c58=_0x4ed3;_0x1be115();const _0x241386=[...new Set((Array[_0x3d4c58(0x3a3)](_0x4d455d)?_0x4d455d:[])[_0x3d4c58(0x35c)](normalizeStoreSessionKey)['filter'](Boolean))];if(_0x241386[_0x3d4c58(0x323)]===0x0)return new Map();const _0x919a3f=_0x241386['map'](()=>'?')[_0x3d4c58(0x36c)](',\x20'),_0x368b84=_0x5074d5()[_0x3d4c58(0x355)](_0x3d4c58(0x255)+_0x3d4c58(0x23a)+_0x3d4c58(0x188)+_0x3d4c58(0x275)+_0x3d4c58(0x327)+_0x3d4c58(0x2a5)+',\x20pinned'+_0x3d4c58(0x10e)+_0x3d4c58(0x1fa)+'ROM\x20sess'+'ion_loca'+_0x3d4c58(0x1ce)+_0x3d4c58(0x34a)+_0x3d4c58(0x38e)+'\x20session'+_0x3d4c58(0x1b2)+'('+_0x919a3f+')\x0a\x20\x20\x20\x20\x20\x20')[_0x3d4c58(0x181)](..._0x241386),_0x4c0f4c=new Map();for(const _0x18718a of _0x368b84){const _0x5108c2=rowToSessionLocalMetadata(_0x18718a);if(_0x5108c2)_0x4c0f4c[_0x3d4c58(0x341)](_0x5108c2[_0x3d4c58(0x287)+'ey'],_0x5108c2);}return _0x4c0f4c;}async function _0x3fffae(_0x27cf2a={}){const _0x15277e=_0x4ed3;_0x1be115();const _0xbd915=asRecord(_0x27cf2a),_0x22620f=Object[_0x15277e(0x244)](asRecord(_0xbd915[_0x15277e(0x33e)]))['map'](([_0x48ee36,_0x2e7ec7])=>[normalizeStoreSessionKey(_0x48ee36),normalizeOptionalString(_0x2e7ec7)])['filter'](([_0x4ce03d,_0x45dce2])=>_0x4ce03d&&_0x45dce2),_0x5ab650=Array[_0x15277e(0x3a3)](_0xbd915[_0x15277e(0x210)+'ys'])?[...new Set(_0xbd915[_0x15277e(0x210)+'ys'][_0x15277e(0x35c)](normalizeStoreSessionKey)['filter'](Boolean))]:[];if(_0x22620f[_0x15277e(0x323)]===0x0&&_0x5ab650['length']===0x0)return{'ok':!![],'migratedNames':0x0,'migratedPinnedKeys':0x0};let _0x2b6425=0x0,_0x27b95a=0x0;const _0x10b204=_0x5074d5();return runTransactionSync(_0x10b204,()=>{const _0x514796=_0x15277e;for(const [_0x57a5cb,_0x2a8949]of _0x22620f){const _0x2c71d0=_0x10b204[_0x514796(0x355)]('SELECT\x20s'+'ession_k'+'ey\x20FROM\x20'+'session_'+_0x514796(0x200)+_0x514796(0x185)+'ssion_ke'+_0x514796(0x216))[_0x514796(0x22b)](_0x57a5cb);if(!_0x2c71d0)continue;const _0x8b8a30=_0x10b204[_0x514796(0x355)]('\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x514796(0x167)+'ERT\x20INTO'+'\x20session'+_0x514796(0x27a)+_0x514796(0x23b)+_0x514796(0x25e)+_0x514796(0x3a7)+_0x514796(0x188)+_0x514796(0x2c5)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x514796(0x283)+_0x514796(0x3d3)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x514796(0x193)+_0x514796(0x31c)+_0x514796(0x255)+_0x514796(0x260)+_0x514796(0x3a7)+'\x20\x20\x20VALUE'+_0x514796(0x225)+_0x514796(0x27c)+_0x514796(0x10c)+_0x514796(0x276)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x514796(0x2d8)+_0x514796(0x2eb)+'ion_key)'+_0x514796(0x1e0)+_0x514796(0x1a5)+_0x514796(0x3a7)+_0x514796(0x21d)+_0x514796(0x327)+_0x514796(0x28a)+_0x514796(0x3a7)+_0x514796(0x3a7)+_0x514796(0x317)+_0x514796(0x250)+'al_metad'+'ata.cust'+'om_name\x20'+_0x514796(0x33a)+_0x514796(0x3a7)+_0x514796(0x3a7)+'\x20\x20OR\x20ses'+_0x514796(0x250)+_0x514796(0x1b5)+_0x514796(0x3c9)+_0x514796(0x1d6)+'=\x20\x27\x27\x0a\x20\x20\x20'+_0x514796(0x3a7)+_0x514796(0x333)+_0x514796(0x3c0)+_0x514796(0x116)+_0x514796(0x2fe)+_0x514796(0x3a7)+_0x514796(0x33c)+_0x514796(0x31b)+_0x514796(0x20f)+_0x514796(0x1ce)+'ta.custo'+_0x514796(0x2fe)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20END'+_0x514796(0x347)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x514796(0x202)+_0x514796(0x121)+_0x514796(0x282)+_0x514796(0x3a7)+_0x514796(0x1d2)+_0x514796(0x1a4)+'ocal_met'+_0x514796(0x113)+_0x514796(0x29a)+'e\x20IS\x20NUL'+_0x514796(0x177)+_0x514796(0x3a7)+_0x514796(0x1ff)+_0x514796(0x1a4)+_0x514796(0x34f)+_0x514796(0x113)+_0x514796(0x29a)+_0x514796(0x2da)+_0x514796(0x3a7)+_0x514796(0x258)+'HEN\x20CURR'+'ENT_TIME'+_0x514796(0x1fc)+_0x514796(0x3a7)+_0x514796(0x194)+_0x514796(0x3d7)+'on_local'+_0x514796(0x228)+'a.update'+_0x514796(0x2ad)+_0x514796(0x3a7)+'\x20\x20\x20END\x0a\x20'+_0x514796(0x3a7)+'\x20')[_0x514796(0x31e)](_0x57a5cb,_0x2a8949);if(Number(_0x8b8a30['changes'])>0x0)_0x2b6425+=0x1;}if(_0x5ab650['length']===0x0)return;const _0x343a75=_0x10b204[_0x514796(0x355)](_0x514796(0x255)+_0x514796(0x1ea)+_0x514796(0x3b4)+_0x514796(0x399)+_0x514796(0x3b3)+_0x514796(0x1f7)+_0x514796(0x278)+'on_local'+'_metadat'+_0x514796(0x32b)+_0x514796(0x38a)+'E\x20pinned'+'\x20=\x201\x0a\x20\x20\x20'+_0x514796(0x331))[_0x514796(0x22b)]();if(Number(_0x343a75?.[_0x514796(0x169)]||0x0)>0x0)return;const _0x1557e0=_0x10b204['prepare'](_0x514796(0x255)+'\x20\x20\x20SELEC'+'T\x20sessio'+_0x514796(0x3cc)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'FROM\x20ses'+'sion_rec'+'ords\x0a\x20\x20\x20'+_0x514796(0x36a)+_0x514796(0x217)+'sion_key'+_0x514796(0x21b)+_0x5ab650[_0x514796(0x35c)](()=>'?')[_0x514796(0x36c)](',\x20')+(_0x514796(0x251)+'\x20\x20'))['all'](..._0x5ab650),_0x3cd6f1=new Set(rowsToSessionKeys(_0x1557e0));_0x5ab650[_0x514796(0x269)]((_0x1ef3fd,_0x2cbbd5)=>{const _0x24fc64=_0x514796;if(!_0x3cd6f1[_0x24fc64(0x28c)](_0x1ef3fd))return;_0x10b204[_0x24fc64(0x355)]('\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x24fc64(0x167)+_0x24fc64(0x326)+_0x24fc64(0x39e)+'_local_m'+_0x24fc64(0x23b)+_0x24fc64(0x25e)+_0x24fc64(0x3a7)+_0x24fc64(0x188)+'key,\x0a\x20\x20\x20'+_0x24fc64(0x3a7)+_0x24fc64(0x39c)+_0x24fc64(0x165)+_0x24fc64(0x3a7)+_0x24fc64(0x144)+'order,\x0a\x20'+_0x24fc64(0x3a7)+_0x24fc64(0x36b)+'ated_at\x0a'+_0x24fc64(0x3a7)+'\x20\x20\x20\x20)\x0a\x20\x20'+_0x24fc64(0x3a7)+_0x24fc64(0x2b5)+_0x24fc64(0x2e1)+_0x24fc64(0x229)+'NT_TIMES'+_0x24fc64(0x2be)+_0x24fc64(0x3a7)+_0x24fc64(0x348)+_0x24fc64(0x36f)+_0x24fc64(0x120)+_0x24fc64(0x248)+_0x24fc64(0x3b1)+_0x24fc64(0x255)+_0x24fc64(0x139)+_0x24fc64(0x273)+_0x24fc64(0x395)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'\x20pinned_'+'order\x20=\x20'+_0x24fc64(0x306)+_0x24fc64(0x313)+_0x24fc64(0x343)+_0x24fc64(0x3a7)+_0x24fc64(0x36b)+'ated_at\x20'+_0x24fc64(0x1be)+_0x24fc64(0x2e5)+_0x24fc64(0x154)+_0x24fc64(0x1e1))['run'](_0x1ef3fd,_0x2cbbd5),_0x27b95a+=0x1;});}),{'ok':!![],'migratedNames':_0x2b6425,'migratedPinnedKeys':_0x27b95a};}async function _0x2cc419(_0x40cad8={}){const _0x441b2e=_0x4ed3;_0x1be115();const _0x4a76c5=asRecord(_0x40cad8),_0x557d7e=Array[_0x441b2e(0x3a3)](_0x4a76c5[_0x441b2e(0x179)])?_0x4a76c5['sessions']:[],_0x4ca815=_0x557d7e['map'](_0x210897=>normalizeStoreSessionKey(asRecord(_0x210897)[_0x441b2e(0x287)+'ey']??asRecord(_0x210897)['key']))[_0x441b2e(0x157)](Boolean),_0x44b3f2=await _0x576c4f(_0x4ca815),_0x30980f=await _0x2cb8f9();return{..._0x4a76c5,'pinnedKeys':_0x30980f,'sessions':_0x557d7e[_0x441b2e(0x35c)](_0x56e561=>{const _0x1f111f=_0x441b2e,_0x2bca22=asRecord(_0x56e561),_0xb4ff09=normalizeStoreSessionKey(_0x2bca22['sessionK'+'ey']??_0x2bca22[_0x1f111f(0x1b9)]);if(!_0xb4ff09)return _0x56e561;const _0x35902d=_0x44b3f2[_0x1f111f(0x22b)](_0xb4ff09),_0x484778=_0x35902d?.[_0x1f111f(0x19e)+'me']||'';return{..._0x2bca22,..._0x484778?{'name':_0x484778,'displayName':_0x484778,'label':_0x484778}:{},'pinned':Boolean(_0x35902d?.[_0x1f111f(0x20d)]),'pinnedOrder':_0x35902d?.['pinnedOr'+_0x1f111f(0x2c8)]??null};})};}async function _0x623f32(_0x218521,_0x27b33a){const _0x424f5a=_0x4ed3;_0x1be115();const _0x5f2de3=normalizeStoreSessionKey(_0x218521);if(!_0x5f2de3)throw new Error(_0x424f5a(0x287)+_0x424f5a(0x25f)+_0x424f5a(0x274));const _0x1b1a21=normalizeOptionalString(_0x27b33a),_0x182881=_0x5074d5();return runTransactionSync(_0x182881,()=>{const _0x5a24c3=_0x424f5a,_0xd35f58=_0x182881[_0x5a24c3(0x355)](_0x5a24c3(0x16a)+_0x5a24c3(0x119)+_0x5a24c3(0x289)+_0x5a24c3(0x188)+'records\x20'+_0x5a24c3(0x185)+'ssion_ke'+'y\x20=\x20?')['get'](_0x5f2de3);if(!_0xd35f58)throw new Error(_0x5a24c3(0x117)+_0x5a24c3(0x252)+_0x5a24c3(0x2f0)+_0x5f2de3);if(_0x1b1a21){_0x182881[_0x5a24c3(0x355)](_0x5a24c3(0x255)+'\x20\x20\x20\x20\x20INS'+_0x5a24c3(0x326)+'\x20session'+_0x5a24c3(0x27a)+_0x5a24c3(0x23b)+_0x5a24c3(0x25e)+_0x5a24c3(0x3a7)+_0x5a24c3(0x188)+_0x5a24c3(0x2c5)+_0x5a24c3(0x3a7)+_0x5a24c3(0x283)+'m_name,\x0a'+_0x5a24c3(0x3a7)+'\x20\x20\x20\x20\x20\x20up'+_0x5a24c3(0x31c)+_0x5a24c3(0x255)+_0x5a24c3(0x260)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x5a24c3(0x345)+'S\x20(?,\x20?,'+_0x5a24c3(0x27c)+_0x5a24c3(0x10c)+'MP)\x0a\x20\x20\x20\x20'+_0x5a24c3(0x3a7)+_0x5a24c3(0x2d8)+_0x5a24c3(0x2eb)+_0x5a24c3(0x3be)+'\x20DO\x20UPDA'+_0x5a24c3(0x1a5)+_0x5a24c3(0x3a7)+_0x5a24c3(0x21d)+_0x5a24c3(0x327)+_0x5a24c3(0x19a)+_0x5a24c3(0x2e7)+_0x5a24c3(0x32a)+_0x5a24c3(0x255)+_0x5a24c3(0x3bc)+_0x5a24c3(0x373)+_0x5a24c3(0x2b3)+_0x5a24c3(0x172)+_0x5a24c3(0x1fc)+_0x5a24c3(0x3a7))[_0x5a24c3(0x31e)](_0x5f2de3,_0x1b1a21);return;}_0x182881[_0x5a24c3(0x355)](_0x5a24c3(0x255)+'\x20\x20\x20UPDAT'+_0x5a24c3(0x2ff)+_0x5a24c3(0x39a)+_0x5a24c3(0x30f)+_0x5a24c3(0x255)+'\x20\x20\x20SET\x20c'+'ustom_na'+'me\x20=\x20NUL'+_0x5a24c3(0x28f)+_0x5a24c3(0x3a7)+'\x20updated'+_0x5a24c3(0x312)+_0x5a24c3(0x30e)+'MESTAMP\x0a'+_0x5a24c3(0x3a7)+_0x5a24c3(0x23e)+'session_'+_0x5a24c3(0x3ad)+_0x5a24c3(0x3a7))['run'](_0x5f2de3);}),{'ok':!![]};}async function _0x2cb8f9(){const _0x1736f6=_0x4ed3;return _0x1be115(),rowsToSessionKeys(_0x5074d5()[_0x1736f6(0x355)](_0x1736f6(0x255)+_0x1736f6(0x1ea)+_0x1736f6(0x18f)+_0x1736f6(0x3cc)+_0x1736f6(0x3a7)+_0x1736f6(0x143)+_0x1736f6(0x250)+_0x1736f6(0x1b5)+'ata\x0a\x20\x20\x20\x20'+_0x1736f6(0x2db)+'ERE\x20pinn'+_0x1736f6(0x13b)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x1736f6(0x2ef)+'Y\x20pinned'+_0x1736f6(0x26e)+'SC,\x20upda'+_0x1736f6(0x30a)+_0x1736f6(0x127)+'DESC\x0a\x20\x20\x20'+_0x1736f6(0x331))[_0x1736f6(0x181)]());}async function _0x96284f(_0x21cb84=[]){const _0x5241f8=_0x4ed3;_0x1be115();const _0x2f75c1=Array[_0x5241f8(0x3a3)](_0x21cb84)?[...new Set(_0x21cb84['map'](normalizeStoreSessionKey)[_0x5241f8(0x157)](Boolean))]:[],_0x3695be=_0x5074d5();return runTransactionSync(_0x3695be,()=>{const _0x3db300=_0x5241f8;_0x3695be[_0x3db300(0x355)](_0x3db300(0x255)+_0x3db300(0x293)+'E\x20sessio'+_0x3db300(0x39a)+_0x3db300(0x30f)+_0x3db300(0x255)+'\x20\x20\x20SET\x20p'+'inned\x20=\x20'+_0x3db300(0x256)+_0x3db300(0x3a7)+_0x3db300(0x144)+_0x3db300(0x285)+_0x3db300(0x203)+_0x3db300(0x3a7)+'\x20\x20\x20\x20upda'+'ted_at\x20='+_0x3db300(0x27c)+_0x3db300(0x10c)+_0x3db300(0x361)+_0x3db300(0x382))[_0x3db300(0x31e)]();const _0x3f000e=_0x2f75c1[_0x3db300(0x323)]?_0x3695be[_0x3db300(0x355)](_0x3db300(0x255)+'\x20\x20\x20\x20\x20\x20\x20S'+_0x3db300(0x213)+_0x3db300(0x120)+_0x3db300(0x384)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'FROM\x20ses'+_0x3db300(0x23d)+'ords\x0a\x20\x20\x20'+_0x3db300(0x3a7)+_0x3db300(0x38e)+'\x20session'+_0x3db300(0x1b2)+'('+_0x2f75c1[_0x3db300(0x35c)](()=>'?')[_0x3db300(0x36c)](',\x20')+(_0x3db300(0x251)+_0x3db300(0x1e1)))[_0x3db300(0x181)](..._0x2f75c1):[],_0x3eb27d=new Set(rowsToSessionKeys(_0x3f000e));_0x2f75c1['forEach']((_0x272366,_0x2ffe86)=>{const _0x1ce30d=_0x3db300;if(!_0x3eb27d['has'](_0x272366))return;_0x3695be[_0x1ce30d(0x355)](_0x1ce30d(0x255)+_0x1ce30d(0x167)+_0x1ce30d(0x326)+_0x1ce30d(0x39e)+_0x1ce30d(0x27a)+'etadata\x20'+'(\x0a\x20\x20\x20\x20\x20\x20'+_0x1ce30d(0x3a7)+'session_'+_0x1ce30d(0x2c5)+_0x1ce30d(0x3a7)+_0x1ce30d(0x39c)+_0x1ce30d(0x165)+_0x1ce30d(0x3a7)+_0x1ce30d(0x144)+_0x1ce30d(0x343)+_0x1ce30d(0x3a7)+'\x20\x20\x20\x20\x20upd'+_0x1ce30d(0x2ea)+_0x1ce30d(0x3a7)+_0x1ce30d(0x1a7)+_0x1ce30d(0x3a7)+_0x1ce30d(0x2b5)+_0x1ce30d(0x2e1)+'?,\x20CURRE'+_0x1ce30d(0x3bb)+_0x1ce30d(0x2be)+_0x1ce30d(0x3a7)+_0x1ce30d(0x348)+_0x1ce30d(0x36f)+_0x1ce30d(0x120)+_0x1ce30d(0x248)+'DATE\x20SET'+_0x1ce30d(0x255)+_0x1ce30d(0x139)+'inned\x20=\x20'+_0x1ce30d(0x395)+_0x1ce30d(0x3a7)+_0x1ce30d(0x144)+_0x1ce30d(0x285)+_0x1ce30d(0x306)+_0x1ce30d(0x313)+_0x1ce30d(0x343)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20upd'+_0x1ce30d(0x2f8)+'=\x20CURREN'+_0x1ce30d(0x2e5)+_0x1ce30d(0x154)+_0x1ce30d(0x1e1))[_0x1ce30d(0x31e)](_0x272366,_0x2ffe86);});}),{'ok':!![],'pinnedKeys':await _0x2cb8f9()};}async function _0x300ac1(_0x575dcc){const _0x1a5e76=_0x4ed3;_0x1be115();const _0x5d64e9=normalizeStoreSessionKey(_0x575dcc);if(!_0x5d64e9)throw new Error(_0x1a5e76(0x287)+_0x1a5e76(0x25f)+'quired');return _0x5074d5()[_0x1a5e76(0x355)](_0x1a5e76(0x1c7)+'ROM\x20sess'+_0x1a5e76(0x2a9)+_0x1a5e76(0x2b0)+_0x1a5e76(0x2ff)+'n_key\x20=\x20'+'?')['run'](_0x5d64e9),{'ok':!![]};}function _0x593f52(_0x20da1c){const _0xee5ae7=_0x4ed3;return _0x1be115(),rowsToSessionKeys(_0x5074d5()['prepare'](_0xee5ae7(0x255)+_0xee5ae7(0x1ea)+_0xee5ae7(0x18f)+_0xee5ae7(0x3cc)+_0xee5ae7(0x3a7)+_0xee5ae7(0x143)+'sion_rec'+_0xee5ae7(0x1e7)+_0xee5ae7(0x36a)+_0xee5ae7(0x301)+'nt_id\x20=\x20'+_0xee5ae7(0x2c1)+_0xee5ae7(0x1e9)+_0xee5ae7(0x29c)+'ated_at\x20'+_0xee5ae7(0x14f)+_0xee5ae7(0x138)+_0xee5ae7(0x1e1))['all'](_0x20da1c));}async function _0x545fd8(_0x53f601=_0x525a05(0x19d)){const _0x1964fc=_0x525a05;_0x1be115();const _0x1abc75=_0x5074d5()[_0x1964fc(0x355)]('\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x1964fc(0x23a)+_0x1964fc(0x188)+_0x1964fc(0x367)+_0x1964fc(0x38f)+'\x20\x20\x20\x20\x20\x20\x20\x20'+'FROM\x20ses'+_0x1964fc(0x23d)+_0x1964fc(0x1e7)+_0x1964fc(0x1df)+'RE\x20agent'+'_id\x20=\x20?\x0a'+_0x1964fc(0x3a7)+_0x1964fc(0x24a)+'ssion_id'+_0x1964fc(0x357)+_0x1964fc(0x156)+'\x20\x20\x20\x20\x20ORD'+'ER\x20BY\x20up'+_0x1964fc(0x31c)+_0x1964fc(0x3bf)+_0x1964fc(0x242)+_0x1964fc(0x331))[_0x1964fc(0x181)](_0x53f601),_0x4f1125={};for(const _0x12c401 of _0x1abc75){const _0x5e0d12=String(_0x12c401[_0x1964fc(0x188)+'key']||'')[_0x1964fc(0x298)](),_0xf68c6d=String(_0x12c401[_0x1964fc(0x188)+'id']||'')['trim']();if(!_0x5e0d12||!_0xf68c6d)continue;_0x4f1125[_0x5e0d12]={'sessionId':_0xf68c6d};}return _0x4f1125;}async function _0x418e58(_0x2621fd){const _0x2107ad=_0x525a05,_0x700838=await _0x30f232(_0x2621fd);return _0x700838?.[_0x2107ad(0x141)]?.[_0x2107ad(0x2fb)+'ile']||'';}async function _0xbe772(_0x28a1b7){const _0x3ba9a1=_0x525a05,_0x36343c=_0x5074d5(),_0x4cd010=_0x36343c[_0x3ba9a1(0x355)]('\x0a\x20\x20\x20\x20\x20\x20\x20'+_0x3ba9a1(0x214)+_0x3ba9a1(0x3a7)+'\x20\x20id,\x0a\x20\x20'+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x3ba9a1(0x292)+_0x3ba9a1(0x206)+_0x3ba9a1(0x3a7)+_0x3ba9a1(0x292)+_0x3ba9a1(0x368)+_0x3ba9a1(0x3a7)+_0x3ba9a1(0x397)+'ue,\x0a\x20\x20\x20\x20'+_0x3ba9a1(0x2d7)+_0x3ba9a1(0x1aa)+'ue,\x0a\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20\x20bo'+_0x3ba9a1(0x2a6)+_0x3ba9a1(0x12c)+_0x3ba9a1(0x150)+'\x20session'+'_section'+_0x3ba9a1(0x11e)+_0x3ba9a1(0x23e)+_0x3ba9a1(0x188)+_0x3ba9a1(0x224)+_0x3ba9a1(0x17a)+_0x3ba9a1(0x2e9)+_0x3ba9a1(0x168)+'d\x20ASC\x0a\x20\x20'+_0x3ba9a1(0x140))[_0x3ba9a1(0x181)](_0x28a1b7),_0x2a47e2={};for(const _0x5ecd2b of _0x4cd010){const _0x334af9=_0x36343c[_0x3ba9a1(0x355)]('\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20\x20\x20SELEC'+'T\x0a\x20\x20\x20\x20\x20\x20'+_0x3ba9a1(0x39d)+',\x0a\x20\x20\x20\x20\x20\x20'+_0x3ba9a1(0x161)+_0x3ba9a1(0x25d)+'e_id,\x0a\x20\x20'+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x3ba9a1(0x17e)+_0x3ba9a1(0x128)+_0x3ba9a1(0x3a7)+_0x3ba9a1(0x1f8)+_0x3ba9a1(0x2bb)+_0x3ba9a1(0x3a7)+_0x3ba9a1(0x33b)+_0x3ba9a1(0x137)+_0x3ba9a1(0x3a7)+_0x3ba9a1(0x397)+_0x3ba9a1(0x2d3)+_0x3ba9a1(0x3a7)+_0x3ba9a1(0x10f)+_0x3ba9a1(0x1dd)+_0x3ba9a1(0x3a7)+_0x3ba9a1(0x356)+_0x3ba9a1(0x19c)+_0x3ba9a1(0x3a7)+'\x20\x20FROM\x20s'+_0x3ba9a1(0x1a0)+_0x3ba9a1(0x3cd)+'odes\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20\x20\x20W'+'HERE\x20sec'+_0x3ba9a1(0x279)+_0x3ba9a1(0x299)+'\x20\x20\x20\x20\x20\x20OR'+_0x3ba9a1(0x168)+_0x3ba9a1(0x1c1)+_0x3ba9a1(0x1e1))[_0x3ba9a1(0x181)](Number(_0x5ecd2b['id']));if(_0x5ecd2b['section_'+_0x3ba9a1(0x3da)]==='object'&&_0x334af9[_0x3ba9a1(0x323)]===0x0)continue;const _0x37d810=sectionRowToValue(_0x5ecd2b,_0x334af9);if(_0x5ecd2b['section_'+_0x3ba9a1(0x3da)]===_0x3ba9a1(0x38d)&&isEmptyObjectValue(_0x37d810))continue;_0x2a47e2[String(_0x5ecd2b[_0x3ba9a1(0x292)+_0x3ba9a1(0x27b)])]=_0x37d810;}return _0x2a47e2;}function _0x2c18d1(_0x50d6b5){const _0x1f98d6=_0x525a05,_0x3863b6=_0x5074d5(),_0x3b37b9=_0x3863b6[_0x1f98d6(0x355)](_0x1f98d6(0x255)+_0x1f98d6(0x214)+_0x1f98d6(0x3a7)+'\x20\x20id,\x0a\x20\x20'+_0x1f98d6(0x3a7)+_0x1f98d6(0x292)+_0x1f98d6(0x206)+_0x1f98d6(0x3a7)+_0x1f98d6(0x292)+_0x1f98d6(0x368)+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x1f98d6(0x397)+_0x1f98d6(0x2d3)+_0x1f98d6(0x2d7)+'mber_val'+'ue,\x0a\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20\x20bo'+'olean_va'+'lue\x0a\x20\x20\x20\x20'+_0x1f98d6(0x150)+'\x20session'+_0x1f98d6(0x3c8)+'s\x0a\x20\x20\x20\x20\x20\x20'+_0x1f98d6(0x23e)+_0x1f98d6(0x188)+_0x1f98d6(0x224)+'d\x20=\x20?\x0a\x20\x20'+_0x1f98d6(0x2e9)+_0x1f98d6(0x168)+_0x1f98d6(0x1c1)+_0x1f98d6(0x140))[_0x1f98d6(0x181)](_0x50d6b5),_0x378858={};for(const _0x30a526 of _0x3b37b9){const _0x1bbb1a=_0x3863b6['prepare'](_0x1f98d6(0x255)+_0x1f98d6(0x1ea)+_0x1f98d6(0x11c)+_0x1f98d6(0x39d)+_0x1f98d6(0x347)+_0x1f98d6(0x161)+_0x1f98d6(0x25d)+'e_id,\x0a\x20\x20'+_0x1f98d6(0x3a7)+_0x1f98d6(0x17e)+_0x1f98d6(0x128)+_0x1f98d6(0x3a7)+_0x1f98d6(0x1f8)+'dex,\x0a\x20\x20\x20'+_0x1f98d6(0x3a7)+'\x20node_ki'+'nd,\x0a\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20\x20\x20\x20'+_0x1f98d6(0x397)+_0x1f98d6(0x2d3)+_0x1f98d6(0x3a7)+_0x1f98d6(0x10f)+_0x1f98d6(0x1dd)+_0x1f98d6(0x3a7)+_0x1f98d6(0x356)+'n_value\x0a'+_0x1f98d6(0x3a7)+'\x20\x20FROM\x20s'+_0x1f98d6(0x1a0)+_0x1f98d6(0x3cd)+_0x1f98d6(0x234)+_0x1f98d6(0x36a)+_0x1f98d6(0x390)+_0x1f98d6(0x279)+'=\x20?\x0a\x20\x20\x20\x20'+_0x1f98d6(0x2e9)+'DER\x20BY\x20i'+_0x1f98d6(0x1c1)+'\x20\x20\x20\x20\x20\x20')[_0x1f98d6(0x181)](Number(_0x30a526['id']));if(_0x30a526[_0x1f98d6(0x292)+_0x1f98d6(0x3da)]===_0x1f98d6(0x38d)&&_0x1bbb1a[_0x1f98d6(0x323)]===0x0)continue;const _0x2046f6=sectionRowToValue(_0x30a526,_0x1bbb1a);if(_0x30a526[_0x1f98d6(0x292)+_0x1f98d6(0x3da)]===_0x1f98d6(0x38d)&&isEmptyObjectValue(_0x2046f6))continue;_0x378858[String(_0x30a526['section_'+'name'])]=_0x2046f6;}return _0x378858;}async function _0x468efa(_0x256329){const _0x5d4158=await _0x30f232(_0x256329);if(!_0x5d4158)return null;return{..._0x5d4158['summary'],...await _0xbe772(_0x5d4158['id'])};}function _0x17fa34(_0xf2458e){const _0x361e93=_0x525a05,_0x14c4c3=_0x3a8990(_0xf2458e);if(!_0x14c4c3)return null;return{..._0x14c4c3[_0x361e93(0x141)],..._0x2c18d1(_0x14c4c3['id'])};}async function _0x2c1b52(_0x379bd0){const _0x88863=await _0x26496e(_0x379bd0),_0x26526e={};for(const _0x598830 of _0x88863){const _0x32f5fc=await _0x468efa(_0x598830);if(!_0x32f5fc)continue;const {agentId:_0x2202d2,sessionKey:_0x2c98f8,..._0x47becf}=_0x32f5fc;_0x26526e[_0x598830]=_0x47becf;}return _0x26526e;}function _0x24b5b6(_0x305b04){const _0x122f64=_0x593f52(_0x305b04),_0x280d88={};for(const _0x4d4a1b of _0x122f64){const _0x12f3f1=_0x17fa34(_0x4d4a1b);if(!_0x12f3f1)continue;const {agentId:_0x3dbf24,sessionKey:_0x5edfc2,..._0x5374e3}=_0x12f3f1;_0x280d88[_0x4d4a1b]=_0x5374e3;}return _0x280d88;}async function _0x51a46c(_0x25ac83){const _0x29ee17=readCachedStore(_0x25ac83);if(_0x29ee17)return _0x29ee17;const _0x28e69a=extractAgentIdFromStorePath(_0x64ae96,_0x25ac83),_0x3766e2=await _0x2c1b52(_0x28e69a);return hydratePromptRefsInStore(_0x25ac83,_0x3766e2),writeCachedStore(_0x25ac83,_0x3766e2),cloneStoreObject(_0x3766e2);}function _0x65b903(_0x2024f9,_0x4c5f19={}){const _0x18d073=readCachedStore(_0x2024f9,_0x4c5f19);if(_0x18d073)return _0x18d073;const _0x131535=extractAgentIdFromStorePath(_0x64ae96,_0x2024f9),_0x2f972a=_0x24b5b6(_0x131535);return hydratePromptRefsInStore(_0x2024f9,_0x2f972a),writeCachedStore(_0x2024f9,_0x2f972a),isCloneRequested(_0x4c5f19)?cloneStoreObject(_0x2f972a):_0x2f972a;}async function _0x215c7b({agentId:_0x4237e8,sessionKey:_0x174817,entry:_0x593c70,storePath:_0xbf854b}){_0x1be115(),_0x55fd98(_0x4237e8,_0x174817,_0x593c70);const _0x41d707=_0xbf854b||legacySessionJsonPath(_0x64ae96,_0x4237e8),_0x48e9a4=_0x24b5b6(_0x4237e8);return writeLegacySessionJsonMirrorSync(_0x41d707,_0x48e9a4),invalidateCachedStore(_0x41d707),writeCachedStore(_0x41d707,_0x48e9a4),await _0x468efa(normalizeStoreSessionKey(_0x174817));}async function _0x565469(_0x4a0091,_0x3fd22c){const _0x1af889=extractAgentIdFromStorePath(_0x64ae96,_0x4a0091),_0x3102a7=await ensureStorePromptBlobs(_0x4a0091,_0x3fd22c),_0xd665c6=_0x5074d5();runTransactionSync(_0xd665c6,()=>{const _0x13e0c3=_0x4ed3,_0x3dcd74=_0xd665c6['prepare'](_0x13e0c3(0x16a)+_0x13e0c3(0x119)+_0x13e0c3(0x289)+_0x13e0c3(0x188)+_0x13e0c3(0x200)+_0x13e0c3(0x398)+_0x13e0c3(0x2e4)+'\x20?')[_0x13e0c3(0x181)](_0x1af889),_0x5b3aa1=new Set(Object[_0x13e0c3(0x211)](asRecord(_0x3102a7)));for(const _0x4dd295 of _0x3dcd74){const _0x3746a4=String(_0x4dd295[_0x13e0c3(0x188)+_0x13e0c3(0x1b9)]||'')[_0x13e0c3(0x298)]();if(_0x5b3aa1[_0x13e0c3(0x28c)](_0x3746a4))continue;_0xd665c6['prepare']('DELETE\x20F'+_0x13e0c3(0x180)+_0x13e0c3(0x2a9)+_0x13e0c3(0x2b0)+_0x13e0c3(0x2ff)+'n_key\x20=\x20'+'?')[_0x13e0c3(0x31e)](_0x3746a4);}for(const [_0x47c7db,_0x415013]of Object[_0x13e0c3(0x244)](asRecord(_0x3102a7))){_0x1fc789(_0xd665c6,_0x1af889,_0x47c7db,_0x415013);}}),invalidateCachedStore(_0x4a0091);const _0x26c601=_0x65b903(_0x4a0091,{'clone':![],'skipCache':!![]});return writeLegacySessionJsonMirrorSync(_0x4a0091,_0x26c601),writeCachedStore(_0x4a0091,_0x26c601),cloneStoreObject(_0x26c601);}async function _0x3590ac(_0x4c304a,_0x32c6d7){return _0x1be115(),await runExclusiveStoreWrite(_0x4c304a,async()=>await _0x565469(_0x4c304a,_0x32c6d7));}async function _0x5339ec(_0x529508,_0x579f1a,_0xb2b799={}){return _0x1be115(),await runExclusiveStoreWrite(_0x529508,async()=>{const _0x2e82e8=_0x4ed3,_0x7d3f68=_0x65b903(_0x529508,{'clone':![],'skipCache':!![]}),_0x4948be=await _0x579f1a(_0x7d3f68);if(typeof _0xb2b799[_0x2e82e8(0x266)+_0x2e82e8(0x358)+'lt']===_0x2e82e8(0x3a0)&&_0xb2b799[_0x2e82e8(0x266)+_0x2e82e8(0x358)+'lt'](_0x4948be))return writeCachedStore(_0x529508,_0x7d3f68),_0x4948be;return await _0x565469(_0x529508,_0x7d3f68),_0x4948be;});}async function _0x2fa403(_0x439f57,_0x54767c){return await _0x3590ac(_0x439f57,_0x54767c);}async function _0x27cfe5(_0x32eb3a,_0x483f18,_0x483482={}){return await _0x5339ec(_0x32eb3a,_0x483f18,_0x483482);}async function _0x475b67(_0x2589b6){const _0x416aee=_0x525a05;return await runExclusiveStoreWrite(_0x2589b6[_0x416aee(0x376)+'h'],async()=>{const _0x45e944=_0x416aee,_0x5e4de7=_0x65b903(_0x2589b6[_0x45e944(0x376)+'h'],{'clone':![],'skipCache':!![]}),_0x35a49c=resolveSessionStoreEntry({'store':_0x5e4de7,'sessionKey':_0x2589b6[_0x45e944(0x287)+'ey']}),_0x20f795=_0x35a49c[_0x45e944(0x3c5)];if(!_0x20f795)return null;const _0x25f637=await _0x2589b6[_0x45e944(0x247)](cloneJsonValue(_0x20f795));if(!_0x25f637)return cloneJsonValue(_0x20f795);const _0x380c95=mergeSessionEntry(_0x20f795,_0x25f637);delete _0x5e4de7[_0x35a49c[_0x45e944(0x15b)+_0x45e944(0x254)]];for(const _0x21a647 of _0x35a49c[_0x45e944(0x16c)+'ys'])delete _0x5e4de7[_0x21a647];return _0x5e4de7[_0x35a49c['normaliz'+_0x45e944(0x254)]]=_0x380c95,await _0x565469(_0x2589b6[_0x45e944(0x376)+'h'],_0x5e4de7),await _0x468efa(_0x35a49c[_0x45e944(0x15b)+_0x45e944(0x254)]);});}async function _0x3683c4(_0x25250b){const _0x21d32d=_0x525a05;return await _0x475b67({..._0x25250b,'update':async()=>_0x25250b[_0x21d32d(0x344)]||{}});}async function _0x51572d(_0x5b6da7){const _0x544e3f=_0x525a05;return await _0x3590ac(_0x5b6da7[_0x544e3f(0x376)+'h'],_0x5b6da7[_0x544e3f(0x380)]);}async function _0x347cda(){const _0x1a7191=_0x525a05;if(!_0x5e3d77)return;_0x5e3d77[_0x1a7191(0x2b7)](),_0x5e3d77=null,_0x259d66=![];}return{'ensureInitialized':_0x8e4799,'ensureInitializedSync':_0x1be115,'getSessionsMap':_0x545fd8,'getSessionFileByKey':_0x418e58,'getSessionRecordByKey':_0x30f232,'getSessionRecordByKeySync':_0x3a8990,'applySessionLocalMetadataToList':_0x2cc419,'deleteSessionRecord':_0x300ac1,'getPinnedSessionKeys':_0x2cb8f9,'getSessionLocalMetadataByKeys':_0x576c4f,'importSessionLocalMetadata':_0x3fffae,'setPinnedSessionKeys':_0x96284f,'setSessionCustomName':_0x623f32,'readSessionEntry':_0x468efa,'readSessionEntrySync':_0x17fa34,'readStoreByAgent':_0x2c1b52,'readStoreByAgentSync':_0x24b5b6,'readStoreByPath':_0x51a46c,'readStoreByPathSync':_0x65b903,'upsertSessionEntry':_0x215c7b,'importLegacySessionsJson':async(_0x7da0a4,_0x54d87f)=>_0x3551c5(_0x7da0a4,_0x54d87f),'writeStoreByPath':_0x3590ac,'mutateStoreByPath':_0x5339ec,'saveSessionStore':_0x2fa403,'updateSessionStore':_0x27cfe5,'updateSessionStoreEntry':_0x475b67,'applySessionStoreEntryPatch':_0x3683c4,'writeSessionStoreAtomic':_0x51572d,'close':_0x347cda,'resolveDbPath':()=>dbPath};}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
PRAGMA foreign_keys = ON;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS session_store_migrations (
|
|
4
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
5
|
+
version TEXT NOT NULL UNIQUE,
|
|
6
|
+
applied_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
CREATE TABLE IF NOT EXISTS session_store_meta (
|
|
10
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
11
|
+
meta_key TEXT NOT NULL UNIQUE,
|
|
12
|
+
meta_value TEXT
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE TABLE IF NOT EXISTS session_store_legacy_imports (
|
|
16
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
17
|
+
source_path TEXT NOT NULL UNIQUE,
|
|
18
|
+
agent_id TEXT NOT NULL,
|
|
19
|
+
imported_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
20
|
+
source_mtime_ms INTEGER,
|
|
21
|
+
source_size_bytes INTEGER,
|
|
22
|
+
imported_session_count INTEGER NOT NULL DEFAULT 0
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
CREATE TABLE IF NOT EXISTS session_records (
|
|
26
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
27
|
+
agent_id TEXT NOT NULL,
|
|
28
|
+
session_key TEXT NOT NULL UNIQUE,
|
|
29
|
+
session_id TEXT,
|
|
30
|
+
label TEXT,
|
|
31
|
+
session_file TEXT,
|
|
32
|
+
updated_at INTEGER,
|
|
33
|
+
session_started_at INTEGER,
|
|
34
|
+
last_interaction_at INTEGER,
|
|
35
|
+
system_sent INTEGER,
|
|
36
|
+
aborted_last_run INTEGER,
|
|
37
|
+
chat_type TEXT,
|
|
38
|
+
last_channel TEXT,
|
|
39
|
+
status TEXT,
|
|
40
|
+
started_at INTEGER,
|
|
41
|
+
ended_at INTEGER,
|
|
42
|
+
runtime_ms INTEGER,
|
|
43
|
+
model_provider TEXT,
|
|
44
|
+
model TEXT,
|
|
45
|
+
context_tokens INTEGER,
|
|
46
|
+
input_tokens INTEGER,
|
|
47
|
+
output_tokens INTEGER,
|
|
48
|
+
cache_read INTEGER,
|
|
49
|
+
cache_write INTEGER,
|
|
50
|
+
estimated_cost_usd REAL,
|
|
51
|
+
total_tokens INTEGER,
|
|
52
|
+
total_tokens_fresh INTEGER,
|
|
53
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
54
|
+
updated_row_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
CREATE INDEX IF NOT EXISTS session_records_agent_id_idx
|
|
58
|
+
ON session_records (agent_id);
|
|
59
|
+
|
|
60
|
+
CREATE INDEX IF NOT EXISTS session_records_session_id_idx
|
|
61
|
+
ON session_records (session_id);
|
|
62
|
+
|
|
63
|
+
CREATE INDEX IF NOT EXISTS session_records_updated_at_idx
|
|
64
|
+
ON session_records (updated_at DESC);
|
|
65
|
+
|
|
66
|
+
CREATE TABLE IF NOT EXISTS session_local_metadata (
|
|
67
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
68
|
+
session_key TEXT NOT NULL UNIQUE,
|
|
69
|
+
custom_name TEXT,
|
|
70
|
+
pinned INTEGER NOT NULL DEFAULT 0,
|
|
71
|
+
pinned_order INTEGER,
|
|
72
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
73
|
+
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
74
|
+
FOREIGN KEY (session_key) REFERENCES session_records(session_key) ON DELETE CASCADE
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
CREATE INDEX IF NOT EXISTS session_local_metadata_pinned_idx
|
|
78
|
+
ON session_local_metadata (pinned, pinned_order);
|
|
79
|
+
|
|
80
|
+
CREATE TABLE IF NOT EXISTS session_sections (
|
|
81
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
82
|
+
session_record_id INTEGER NOT NULL,
|
|
83
|
+
section_name TEXT NOT NULL,
|
|
84
|
+
section_kind TEXT NOT NULL,
|
|
85
|
+
text_value TEXT,
|
|
86
|
+
number_value REAL,
|
|
87
|
+
boolean_value INTEGER,
|
|
88
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
89
|
+
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
90
|
+
FOREIGN KEY (session_record_id) REFERENCES session_records(id) ON DELETE CASCADE,
|
|
91
|
+
UNIQUE (session_record_id, section_name)
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
CREATE INDEX IF NOT EXISTS session_sections_record_idx
|
|
95
|
+
ON session_sections (session_record_id);
|
|
96
|
+
|
|
97
|
+
CREATE TABLE IF NOT EXISTS session_section_nodes (
|
|
98
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
99
|
+
section_id INTEGER NOT NULL,
|
|
100
|
+
parent_node_id INTEGER,
|
|
101
|
+
node_key TEXT,
|
|
102
|
+
array_index INTEGER,
|
|
103
|
+
node_kind TEXT NOT NULL,
|
|
104
|
+
text_value TEXT,
|
|
105
|
+
number_value REAL,
|
|
106
|
+
boolean_value INTEGER,
|
|
107
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
108
|
+
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
109
|
+
FOREIGN KEY (section_id) REFERENCES session_sections(id) ON DELETE CASCADE,
|
|
110
|
+
FOREIGN KEY (parent_node_id) REFERENCES session_section_nodes(id) ON DELETE CASCADE
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
CREATE INDEX IF NOT EXISTS session_section_nodes_section_idx
|
|
114
|
+
ON session_section_nodes (section_id);
|
|
115
|
+
|
|
116
|
+
CREATE INDEX IF NOT EXISTS session_section_nodes_parent_idx
|
|
117
|
+
ON session_section_nodes (parent_node_id);
|
|
118
|
+
|
|
119
|
+
CREATE INDEX IF NOT EXISTS session_section_nodes_array_idx
|
|
120
|
+
ON session_section_nodes (section_id, parent_node_id, array_index);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
PRAGMA foreign_keys = ON;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS session_local_metadata (
|
|
4
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
5
|
+
session_key TEXT NOT NULL UNIQUE,
|
|
6
|
+
custom_name TEXT,
|
|
7
|
+
pinned INTEGER NOT NULL DEFAULT 0,
|
|
8
|
+
pinned_order INTEGER,
|
|
9
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
11
|
+
FOREIGN KEY (session_key) REFERENCES session_records(session_key) ON DELETE CASCADE
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE INDEX IF NOT EXISTS session_local_metadata_pinned_idx
|
|
15
|
+
ON session_local_metadata (pinned, pinned_order);
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Session SQLite Schema
|
|
2
|
+
|
|
3
|
+
## 目标
|
|
4
|
+
|
|
5
|
+
- `session_records` 仅保留运行时热点核心字段。
|
|
6
|
+
- 原 `sessions.json` 的二级及更深层字段不再落 JSON 列,而是进入关联子表。
|
|
7
|
+
- 所有表主键都使用内部 surrogate key,不使用业务字段作为主键。
|
|
8
|
+
- 通过 `sql/*.sql` 增量脚本驱动初始化和升级。
|
|
9
|
+
|
|
10
|
+
## 表结构
|
|
11
|
+
|
|
12
|
+
### `session_records`
|
|
13
|
+
|
|
14
|
+
核心会话摘要表,保留以下热点字段:
|
|
15
|
+
|
|
16
|
+
- `agent_id`
|
|
17
|
+
- `session_key`
|
|
18
|
+
- `session_id`
|
|
19
|
+
- `label`
|
|
20
|
+
- `session_file`
|
|
21
|
+
- `updated_at`
|
|
22
|
+
- `session_started_at`
|
|
23
|
+
- `last_interaction_at`
|
|
24
|
+
- `system_sent`
|
|
25
|
+
- `aborted_last_run`
|
|
26
|
+
- `chat_type`
|
|
27
|
+
- `last_channel`
|
|
28
|
+
- `status`
|
|
29
|
+
- `started_at`
|
|
30
|
+
- `ended_at`
|
|
31
|
+
- `runtime_ms`
|
|
32
|
+
- `model_provider`
|
|
33
|
+
- `model`
|
|
34
|
+
- `context_tokens`
|
|
35
|
+
- `input_tokens`
|
|
36
|
+
- `output_tokens`
|
|
37
|
+
- `cache_read`
|
|
38
|
+
- `cache_write`
|
|
39
|
+
- `estimated_cost_usd`
|
|
40
|
+
- `total_tokens`
|
|
41
|
+
- `total_tokens_fresh`
|
|
42
|
+
|
|
43
|
+
约束:
|
|
44
|
+
|
|
45
|
+
- `id` 为自增主键
|
|
46
|
+
- `session_key` 唯一索引
|
|
47
|
+
- `agent_id`、`session_id`、`updated_at` 独立索引
|
|
48
|
+
|
|
49
|
+
### `session_sections`
|
|
50
|
+
|
|
51
|
+
顶层非核心字段表。每个 `session_records` 可关联多个 section,例如:
|
|
52
|
+
|
|
53
|
+
- `route`
|
|
54
|
+
- `deliveryContext`
|
|
55
|
+
- `origin`
|
|
56
|
+
- `skillsSnapshot`
|
|
57
|
+
- `systemPromptReport`
|
|
58
|
+
- 以及未来新增的其他顶层非核心字段
|
|
59
|
+
|
|
60
|
+
字段说明:
|
|
61
|
+
|
|
62
|
+
- `section_name`:顶层字段名
|
|
63
|
+
- `section_kind`:`object` / `array` / `string` / `number` / `boolean` / `null`
|
|
64
|
+
- 标量 section 直接落在 `text_value` / `number_value` / `boolean_value`
|
|
65
|
+
|
|
66
|
+
约束:
|
|
67
|
+
|
|
68
|
+
- `id` 为自增主键
|
|
69
|
+
- `(session_record_id, section_name)` 唯一
|
|
70
|
+
|
|
71
|
+
### `session_section_nodes`
|
|
72
|
+
|
|
73
|
+
递归规范化 section 内部的全部嵌套结构,不使用 JSON 列。
|
|
74
|
+
|
|
75
|
+
字段说明:
|
|
76
|
+
|
|
77
|
+
- `section_id`:所属 section
|
|
78
|
+
- `parent_node_id`:父节点,根层节点为空
|
|
79
|
+
- `node_key`:对象属性名
|
|
80
|
+
- `array_index`:数组序号
|
|
81
|
+
- `node_kind`:`object` / `array` / `string` / `number` / `boolean` / `null`
|
|
82
|
+
- 标量值落在 `text_value` / `number_value` / `boolean_value`
|
|
83
|
+
|
|
84
|
+
这张表负责承载原 `skillsSnapshot.skills[]`、`skillsSnapshot.skillFilter[]`、
|
|
85
|
+
`systemPromptReport.tools.entries[]`、`systemPromptReport.injectedWorkspaceFiles[]`
|
|
86
|
+
等所有深层结构。
|
|
87
|
+
|
|
88
|
+
### `session_local_metadata`
|
|
89
|
+
|
|
90
|
+
本地产品扩展元数据表,承载不属于 OpenClaw 原始 session store 的 UI 状态:
|
|
91
|
+
|
|
92
|
+
- `session_key`
|
|
93
|
+
- `custom_name`
|
|
94
|
+
- `pinned`
|
|
95
|
+
- `pinned_order`
|
|
96
|
+
|
|
97
|
+
约束:
|
|
98
|
+
|
|
99
|
+
- `session_key` 唯一
|
|
100
|
+
- `session_key` 外键关联 `session_records(session_key)`,删除 session 时级联清理
|
|
101
|
+
- `pinned_order` 仅在 `pinned = 1` 时参与置顶排序
|
|
102
|
+
|
|
103
|
+
### 元数据表
|
|
104
|
+
|
|
105
|
+
- `session_store_migrations`:记录已执行的 SQL 版本
|
|
106
|
+
- `session_store_meta`:通用元数据
|
|
107
|
+
- `session_store_legacy_imports`:记录 legacy `sessions.json` 的一次性导入状态
|
|
108
|
+
|
|
109
|
+
## 迁移策略
|
|
110
|
+
|
|
111
|
+
1. 初始化或升级时按文件名顺序执行 `sql/*.sql`
|
|
112
|
+
2. 每个脚本成功后写入 `session_store_migrations`
|
|
113
|
+
3. 启动期扫描 legacy `agents/*/sessions/sessions.json`
|
|
114
|
+
4. 已导入的 legacy 文件写入 `session_store_legacy_imports`
|
|
115
|
+
5. 运行时只读写 SQLite,不再把 `sessions.json` 当权威源
|