@kedem/okdb 1.9.1 → 2.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.
Files changed (48) hide show
  1. package/README.md +3 -2
  2. package/bin/okdb.js +1 -1
  3. package/docs/deployment.md +155 -0
  4. package/docs/diagnostics.md +115 -0
  5. package/docs/embeddings.md +1 -1
  6. package/docs/functions.md +30 -27
  7. package/docs/getting-started.md +14 -3
  8. package/docs/http-api.md +3 -3
  9. package/docs/http-cluster.md +93 -60
  10. package/docs/index.md +13 -1
  11. package/docs/manifest.json +6 -3
  12. package/docs/pipelines.md +1 -1
  13. package/docs/process-registry.md +5 -5
  14. package/docs/processors.md +35 -18
  15. package/docs/queue.md +112 -42
  16. package/docs/sync.md +10 -7
  17. package/docs/ttl.md +1 -1
  18. package/docs/upgrade-2.0.md +290 -0
  19. package/okdb-functions-sandbox-worker.js +1 -1
  20. package/okdb-http-worker-child.js +1 -1
  21. package/okdb-views-bootstrap-worker.js +1 -1
  22. package/okdb.js +1 -1
  23. package/package.json +1 -1
  24. package/public/layouts/_default.ok.html +1 -1
  25. package/public/sections/db/modals/create-env-modal.ok.js +1 -1
  26. package/public/sections/db/modals/demo-env-modal.ok.js +1 -1
  27. package/public/sections/db/parts/db-overview.ok.js +1 -1
  28. package/public/sections/engines/engine-ui-utils.js +1 -1
  29. package/public/sections/engines/parts/engine-declaration-editor.ok.js +1 -1
  30. package/public/sections/engines/parts/generic-engine-panel.ok.js +1 -1
  31. package/public/sections/queue/parts/code-panel.ok.js +1 -1
  32. package/public/sections/queue/parts/job-log-panel.ok.js +1 -1
  33. package/public/sections/queue/parts/queue-jobs.ok.js +1 -1
  34. package/public/sections/sync/parts/sync-topology.ok.js +1 -1
  35. package/public/sections/system/index.ok.html +1 -1
  36. package/public/sections/system/parts/system-process-panel.ok.js +1 -1
  37. package/public/sections/system/parts/system-processing-panel.ok.js +1 -1
  38. package/public/sections/system/parts/system-runtime-overview.ok.js +1 -1
  39. package/public/setup-app.js +1 -1
  40. package/public/setup.html +116 -55
  41. package/types/index.d.ts +33 -3
  42. package/types/options.d.ts +19 -10
  43. package/docs/worker-fleet.md +0 -139
  44. package/okdb-functions-runner-child.js +0 -1
  45. package/okdb-queue-load-handler.js +0 -1
  46. package/okdb-queue-spawn-child.js +0 -1
  47. package/okdb-worker-child.js +0 -1
  48. package/public/sections/system/parts/system-workers-panel.ok.js +0 -1
@@ -1 +0,0 @@
1
- "use strict";function loadHandler(e,o){const n=require(e);if(o&&"default"!==o){const e=n?.[o];if("function"!=typeof e)throw new Error(`Spawned queue worker export not found or not a function: ${o}`);return e}if("function"==typeof n)return n;if("function"==typeof n?.default)return n.default;throw new Error("Spawned queue worker module must export a function or default function")}module.exports={loadHandler:loadHandler};
@@ -1 +0,0 @@
1
- "use strict";const path=require("node:path"),OKDB=require(path.join(__dirname,"okdb.js"));let db=null,worker=null,stopping=!1;function send(e){try{"function"==typeof process.send&&process.send(e)}catch{}}async function gracefulShutdown(e){if(stopping)return;stopping=!0;const s=setTimeout(()=>process.exit(e),3e3);"function"==typeof s.unref&&s.unref();try{await(worker?.stop?.())}catch{}try{await(db?.close?.())}catch{}process.exit(e)}function startStatsReporter(e){const s=require("node:os");let t=process.cpuUsage(),n=Date.now();const r=()=>{const r=Date.now(),o=process.cpuUsage(),a=1e3*(r-n),c=o.user-t.user+(o.system-t.system),p=a>0?Math.min(100,Math.round(c/(a*(s.cpus().length||1))*100)):0;t=o,n=r;const u=process.memoryUsage();e({type:"stats",stats:{rss:u.rss,heapUsed:u.heapUsed,heapTotal:u.heapTotal,external:u.external,cpuPct:p,cpuWindowMs:Math.round(a/1e3)||null}})},o=Math.max(1e3,Number(process.env.OKDB_STATS_INTERVAL_MS)||5e3),a=setInterval(r,o);a.unref&&a.unref(),r()}const{loadHandler:loadHandler}=require("./okdb-queue-load-handler.js");async function main(){const e=process.env.OKDB_QUEUE_DB_PATH,s=process.env.OKDB_QUEUE_ENV_NAME||"default",t=process.env.OKDB_QUEUE_TYPE,n=process.env.OKDB_QUEUE_MODULE,r=process.env.OKDB_QUEUE_EXPORT||"default",o=JSON.parse(process.env.OKDB_QUEUE_WORKER_OPTIONS||"{}");if(!e)throw new Error("Missing OKDB_QUEUE_DB_PATH");if(!t)throw new Error("Missing OKDB_QUEUE_TYPE");if(!n)throw new Error("Missing OKDB_QUEUE_MODULE");process.on("disconnect",()=>gracefulShutdown(0));const a=setInterval(()=>{1===process.ppid&&gracefulShutdown(0)},2e3);"function"==typeof a.unref&&a.unref(),db=new OKDB(e,{runtimeDeclarations:!1,compaction:"passive",engines:!1,asyncProcessors:!1,http:!1,envs:[s]}),await db.open();const c=db.env(s);if(!c?.queue)throw new Error(`Queue environment not available: ${s}`);const p=loadHandler(n,r);worker=c.queue.process(t,p,o),process.on("message",e=>{e&&"object"==typeof e&&"stop"===e.type&&gracefulShutdown(0)}),process.on("SIGINT",()=>gracefulShutdown(0)),process.on("SIGTERM",()=>gracefulShutdown(0)),send({type:"ready",pid:process.pid,envName:s,queueType:t}),startStatsReporter(send)}main().catch(async e=>{send({type:"error",error:{message:e?.message||String(e),stack:e?.stack||null,code:e?.code||null}});try{await(worker?.stop?.())}catch{}try{await(db?.close?.())}catch{}process.exit(1)});
@@ -1 +0,0 @@
1
- 'use strict';const _0x275d88=_0x3fcd;(function(_0x489f47,_0x158e35){const _0x28483a=_0x3fcd,_0xdf56c4=_0x489f47();while(!![]){try{const _0x279877=parseInt(_0x28483a(0x254))/0x1*(-parseInt(_0x28483a(0x26d))/0x2)+-parseInt(_0x28483a(0x1cf))/0x3*(-parseInt(_0x28483a(0x1ca))/0x4)+parseInt(_0x28483a(0x211))/0x5*(-parseInt(_0x28483a(0x18b))/0x6)+parseInt(_0x28483a(0x2bb))/0x7*(parseInt(_0x28483a(0x1f8))/0x8)+-parseInt(_0x28483a(0x24e))/0x9*(-parseInt(_0x28483a(0x1ef))/0xa)+-parseInt(_0x28483a(0x1e1))/0xb*(-parseInt(_0x28483a(0x223))/0xc)+-parseInt(_0x28483a(0x2ae))/0xd*(-parseInt(_0x28483a(0x24a))/0xe);if(_0x279877===_0x158e35)break;else _0xdf56c4['push'](_0xdf56c4['shift']());}catch(_0x16a59b){_0xdf56c4['push'](_0xdf56c4['shift']());}}}(_0x33bb,0x9f5ed));function _0x3fcd(_0x1ab090,_0xb6640f){_0x1ab090=_0x1ab090-0x189;const _0x33bb37=_0x33bb();let _0x3fcd38=_0x33bb37[_0x1ab090];return _0x3fcd38;}var require$$0$1=require('path'),require$$1$1=require('os'),require$$0=require(_0x275d88(0x1a9)),require$$1=require(_0x275d88(0x27c));function getDefaultExportFromCjs(_0x912fa){const _0x2d597c=_0x275d88;return _0x912fa&&_0x912fa[_0x2d597c(0x239)]&&Object['prototype'][_0x2d597c(0x1b8)]['call'](_0x912fa,_0x2d597c(0x1f5))?_0x912fa[_0x2d597c(0x1f5)]:_0x912fa;}function commonjsRequire(_0x2353d9){const _0x4640ee=_0x275d88;throw new Error(_0x4640ee(0x21b)+_0x2353d9+'\x22.\x20Please\x20configure\x20the\x20dynamicRequireTargets\x20or/and\x20ignoreDynamicRequires\x20option\x20of\x20@rollup/plugin-commonjs\x20appropriately\x20for\x20this\x20require\x20call\x20to\x20work.');}var okdbWorkerChild$1={},okdbEnums,hasRequiredOkdbEnums;function requireOkdbEnums(){const _0x396ce2=_0x275d88;if(hasRequiredOkdbEnums)return okdbEnums;hasRequiredOkdbEnums=0x1;const _0x14b7d3={'PUT':_0x396ce2(0x274),'REMOVE':'remove','INDEX_DROP':'dropIndex','INDEX_REGISTER':_0x396ce2(0x1e2),'INDEX_RESET':_0x396ce2(0x1bb),'TYPE_REGISTER':_0x396ce2(0x195),'TYPE_DROP':_0x396ce2(0x289),'FTS_REGISTER':'registerFts','FTS_DROP':_0x396ce2(0x1b5),'FTS_RESET':'resetFts','SCHEMA_SET':_0x396ce2(0x1df),'SCHEMA_DROP':_0x396ce2(0x1a3),'TTL_SET':_0x396ce2(0x1d7),'TTL_CLEAR':_0x396ce2(0x1de)},_0x3cc775={'SYSTEM_READY':_0x396ce2(0x1d9),'SYSTEM_STOPPED':_0x396ce2(0x2b1),'SYSTEM_CLOCK_CHANGE':_0x396ce2(0x1eb),'SYSTEM_POKE':_0x396ce2(0x1ea),'SYSTEM_DRAIN':_0x396ce2(0x287),'SYSTEM_TYPE_DROP':_0x396ce2(0x25c),'SYSTEM_PROC':_0x396ce2(0x266),'SYSTEM_BUS_STATE_CHANGE':'system:bus_state_change','ITEM_CREATE':_0x396ce2(0x272),'ITEM_UPDATE':_0x396ce2(0x18a),'ITEM_REMOVE':_0x396ce2(0x232),'INDEX_RESET':_0x396ce2(0x1e3),'INDEX_READY':_0x396ce2(0x27d),'INDEX_PROGRESS':_0x396ce2(0x297),'VIEW_PROGRESS':_0x396ce2(0x21f),'INDEX_DROP':'index:drop','INDEX_REGISTERED':_0x396ce2(0x21c),'FTS_REGISTERED':_0x396ce2(0x1f6),'FTS_DROP':_0x396ce2(0x1b3),'FTS_RESET':_0x396ce2(0x224),'SCHEMA_SET':_0x396ce2(0x276),'SCHEMA_DROP':_0x396ce2(0x1d1),'UNIQUE_VIOLATION':_0x396ce2(0x1c0),'UNIQUE_VIOLATION_RESOLVED':_0x396ce2(0x256),'REF_VIOLATION':_0x396ce2(0x2bf),'REF_VIOLATION_RESOLVED':_0x396ce2(0x1e4),'SYNC_APPLY':_0x396ce2(0x20d),'TXN_START':'txn:start','TXN_END':_0x396ce2(0x1ba),'TXN_ROLLBACK':_0x396ce2(0x1b9),'TYPE_REGISTERED':_0x396ce2(0x19c),'TYPE_DROP':'type:drop','ENV_OPENED':_0x396ce2(0x194),'ENV_REMOVED':_0x396ce2(0x207),'TTL_EXPIRED':_0x396ce2(0x290),'TTL_SET':'ttl:set','TTL_CLEAR':_0x396ce2(0x18e),'LICENSE_INVALID':_0x396ce2(0x1a1),'LICENSE_ADDED':_0x396ce2(0x1cd),'LICENSE_ACTIVATED':_0x396ce2(0x216),'LICENSE_REMOVED':_0x396ce2(0x1e5)},_0x3bc718={'CREATING':_0x396ce2(0x197),'RESETTING':_0x396ce2(0x2be),'READY':_0x396ce2(0x1c6),'DROPPING':_0x396ce2(0x275),'WAITING':'waiting'},_0x4b6744={'CREATED':'created','STARTING':_0x396ce2(0x201),'STARTED':_0x396ce2(0x1fb),'STOPPING':_0x396ce2(0x22e),'STOPPED':_0x396ce2(0x2b2)},_0x2fd3aa={'CREATING':_0x396ce2(0x197),'READY':_0x396ce2(0x1c6),'HALTED':_0x396ce2(0x1dd),'STOPPED':_0x396ce2(0x2b2),'RESETTING':'resetting'},_0x35b09f=Object[_0x396ce2(0x2ad)]({'POKE':_0x396ce2(0x24d),'DRAIN':_0x396ce2(0x2bd),'TYPE_DROP':'bus:type_drop','PROC':'bus:proc'});return okdbEnums={'BUS_EVENTS':_0x35b09f,'CHANGE_ACTIONS':_0x14b7d3,'EVENTS':_0x3cc775,'INDEX_STATE':_0x3bc718,'OKDB_STATE':_0x4b6744,'VIEW_STATE':_0x2fd3aa},okdbEnums;}var okdbLoopMonitor,hasRequiredOkdbLoopMonitor;function requireOkdbLoopMonitor(){const _0x4bcbd1=_0x275d88;if(hasRequiredOkdbLoopMonitor)return okdbLoopMonitor;hasRequiredOkdbLoopMonitor=0x1;const {monitorEventLoopDelay:_0x149e5e,performance:_0x4ce206}=require$$0,_0x558c9e=process.env.OKDB_LOOP_LAG==='1'||process.env.OKDB_LOOP_LAG==='true',_0xe778a=Number(process.env.OKDB_LOOP_LAG_MS)||0x7d0,_0x2ee5db=process.env.OKDB_LOOP_LAG_ALL==='1',_0x1093dd=Number(process.env.OKDB_LOOP_LAG_MIN_MS)||0x64;class _0x3bf88c{constructor(){const _0x5a21c9=_0x3fcd;this[_0x5a21c9(0x1c4)]=_0x558c9e,this[_0x5a21c9(0x244)]=new Map(),this['_h']=null,this['_timer']=null,this[_0x5a21c9(0x1d2)]=![],this[_0x5a21c9(0x29c)]=(_0x440692,_0x38a57f)=>process[_0x5a21c9(0x1bd)][_0x5a21c9(0x231)](_0x440692+(_0x38a57f?'\x20'+JSON[_0x5a21c9(0x2ba)](_0x38a57f):'')+'\x0a');}[_0x4bcbd1(0x247)](){const _0x4de07e=_0x4bcbd1;return _0x4ce206[_0x4de07e(0x247)]();}[_0x4bcbd1(0x273)](_0x59f649){if(typeof _0x59f649==='function')this['_log']=_0x59f649;}[_0x4bcbd1(0x200)](_0x53fa29,_0x1103af,_0x2abfa1){const _0x41509b=_0x4bcbd1;if(!this[_0x41509b(0x1c4)])return;let _0x3f4f55=this[_0x41509b(0x244)][_0x41509b(0x23b)](_0x53fa29);!_0x3f4f55&&(_0x3f4f55={'ms':0x0,'count':0x0,'maxMs':0x0,'maxExtra':''},this[_0x41509b(0x244)][_0x41509b(0x1be)](_0x53fa29,_0x3f4f55)),_0x3f4f55['ms']+=_0x1103af,_0x3f4f55[_0x41509b(0x2b8)]+=0x1,_0x1103af>_0x3f4f55[_0x41509b(0x1bc)]&&(_0x3f4f55[_0x41509b(0x1bc)]=_0x1103af,_0x3f4f55[_0x41509b(0x1dc)]=_0x2abfa1||'');}[_0x4bcbd1(0x26a)](_0x1f510c){const _0x42897e=_0x4bcbd1;if(!this[_0x42897e(0x1c4)]||this[_0x42897e(0x1d2)])return;this[_0x42897e(0x1d2)]=!![];if(_0x1f510c)this[_0x42897e(0x29c)]=_0x1f510c;this['_h']=_0x149e5e({'resolution':0xa}),this['_h'][_0x42897e(0x1b6)](),this[_0x42897e(0x2a2)]=setInterval(()=>this['_report'](),_0xe778a);if(this[_0x42897e(0x2a2)]['unref'])this[_0x42897e(0x2a2)][_0x42897e(0x2b6)]();}[_0x4bcbd1(0x1fe)](_0x468879){const _0x50b488=_0x4bcbd1;if(!this[_0x50b488(0x240)])this['_windowCbs']=new Set();this['_windowCbs']['add'](_0x468879);if(!this['_started'])this[_0x50b488(0x1d8)]();}[_0x4bcbd1(0x1a0)](_0x1b79f8){const _0x5e6ac4=_0x4bcbd1;this[_0x5e6ac4(0x240)]?.[_0x5e6ac4(0x27e)](_0x1b79f8);}[_0x4bcbd1(0x1d8)](){const _0x4480eb=_0x4bcbd1;if(this['_admissionStarted'])return;this['_admissionStarted']=!![];!this['_h']&&(this['_h']=_0x149e5e({'resolution':0xa}),this['_h'][_0x4480eb(0x1b6)]());const _0x2302d2=_0xe778a;this['_admissionTimer']=setInterval(()=>{const _0x23031e=_0x4480eb,_0x54c704=this['_h'];if(!_0x54c704)return;const _0x4171b7=_0x54c704[_0x23031e(0x2a6)](0x63)/0xf4240,_0x3eb897=_0x54c704[_0x23031e(0x270)]/0xf4240,_0x3f34f0=_0x54c704[_0x23031e(0x191)]/0xf4240;_0x54c704[_0x23031e(0x1b1)]();if(this[_0x23031e(0x240)])for(const _0xaf5786 of this['_windowCbs']){try{_0xaf5786({'p99Ms':_0x4171b7,'maxMs':_0x3eb897,'meanMs':_0x3f34f0,'reportMs':_0x2302d2});}catch{}}},_0x2302d2);if(this['_admissionTimer'][_0x4480eb(0x2b6)])this['_admissionTimer'][_0x4480eb(0x2b6)]();}['_report'](){const _0x6685c9=_0x4bcbd1,_0x2c29d9=this['_h'],_0x39a60f=_0x2c29d9[_0x6685c9(0x270)]/0xf4240,_0x4d5bc2=_0x2c29d9[_0x6685c9(0x2a6)](0x63)/0xf4240,_0x2feb16=_0x2c29d9[_0x6685c9(0x191)]/0xf4240;_0x2c29d9[_0x6685c9(0x1b1)]();const _0xd759ef=[...this[_0x6685c9(0x244)][_0x6685c9(0x1aa)]()]['map'](([_0x235a2d,_0x4ad099])=>({'label':_0x235a2d,..._0x4ad099}))[_0x6685c9(0x1fa)]((_0x545d3d,_0x5de3ee)=>_0x5de3ee['ms']-_0x545d3d['ms'])[_0x6685c9(0x25d)](0x0,0x8);this[_0x6685c9(0x244)]['clear']();const _0x37dd3e=_0xd759ef[_0x6685c9(0x269)]((_0x41b9c1,_0x187c51)=>_0x41b9c1+_0x187c51['ms'],0x0),_0x3d0542=_0xd759ef[_0x6685c9(0x1a6)](_0x4bfdbe=>_0x4bfdbe[_0x6685c9(0x192)]+'='+_0x4bfdbe['ms'][_0x6685c9(0x26f)](0x0)+_0x6685c9(0x1c5)+_0x4bfdbe[_0x6685c9(0x2b8)]+(_0x4bfdbe[_0x6685c9(0x1bc)]>0x5?_0x6685c9(0x1af)+_0x4bfdbe[_0x6685c9(0x1bc)][_0x6685c9(0x26f)](0x0)+'ms'+(_0x4bfdbe[_0x6685c9(0x1dc)]?'\x20'+_0x4bfdbe[_0x6685c9(0x1dc)]:'')+')':''));(_0x2ee5db||_0x39a60f>=_0x1093dd)&&this[_0x6685c9(0x29c)](_0x6685c9(0x29a)+_0xe778a+_0x6685c9(0x250)+_0x39a60f['toFixed'](0x0)+_0x6685c9(0x292)+_0x4d5bc2['toFixed'](0x0)+_0x6685c9(0x222)+_0x2feb16[_0x6685c9(0x26f)](0x0)+_0x6685c9(0x1c9)+_0x37dd3e[_0x6685c9(0x26f)](0x0)+'ms'+(_0x3d0542[_0x6685c9(0x23e)]?'\x20│\x20'+_0x3d0542[_0x6685c9(0x271)]('\x20\x20'):''),{'feature':_0x6685c9(0x28f)});if(this[_0x6685c9(0x240)])for(const _0x43af05 of this[_0x6685c9(0x240)]){try{_0x43af05({'p99Ms':_0x4d5bc2,'maxMs':_0x39a60f,'meanMs':_0x2feb16,'reportMs':_0xe778a});}catch{}}}[_0x4bcbd1(0x1d6)](){const _0x2bd108=_0x4bcbd1;if(this[_0x2bd108(0x2a2)])clearInterval(this['_timer']);if(this['_h'])this['_h'][_0x2bd108(0x1e9)]();this['_timer']=null,this['_h']=null,this['_started']=![];}}const _0x4cfd09=new _0x3bf88c();if(_0x4cfd09[_0x4bcbd1(0x1c4)])_0x4cfd09[_0x4bcbd1(0x26a)]();return okdbLoopMonitor={'LOOP':_0x4cfd09},okdbLoopMonitor;}function _0x33bb(){const _0x2fc3d8=['loop-lag\x20','resolve','_log','queue\x20definition\x20SKIPPED:\x20','recycle','~views','detachConsole','env-removed\x20evict\x20FAILED\x20for\x20','_timer','_tiers','error','string','percentile','modulePath','main','_dropTier','close','rootPath','sandbox-','freeze','611ziiULa','random','exit','system:stopped','stopped','env','requestedAt','size','unref','add','count','ms\x20(+','stringify','3395zwTdIP','terminate','bus:drain','resetting','ref:violation','attach','logs','sandbox\x20host\x20stopped','_rootDb','item:update','1025112yzfIru','onEmit','putSync','ttl:clear','_lockHandle','system','mean','label','pending','env:opened','registerType','reject','creating','remove','_runBootstrapScanPhases','version','_terminateTier','type:registered','includes','transactionSync','win32','offWindow','license:invalid','log','dropSchema','object','envName','map','removeSync','view','node:perf_hooks','entries','getRange','FUNCTION_OOM','entry','user','(worst\x20','unhandledRejection','reset','cursorKey','fts:drop','state','dropFts','enable','inflight','hasOwnProperty','txn:rollback','txn:end','resetIndex','maxMs','stderr','set','tick','unique:violation','resume','_stopped','claimRoutedBootstrap','enabled','ms/','ready','run','ms\x20grace)\x20—\x20sandbox\x20terminated','ms\x20busy=','3880732ONaDoW','claimedBy','detail','license:added','_maybeIdle','3IGrUTF','queue.process\x20threw:\x20','schema:drop','_started','control','has','queue','stop','setTtl','_startAdmission','system:ready','clear','env-removed\x20hint:\x20force-evicting\x20','maxExtra','halted','clearTtl','setSchema','cancelled','11xfMfbZ','registerIndex','index:reset','ref:violation_resolved','license:removed','_drainHandler','core','send','disable','system:poke','system:clock_change','stdout','type','options','450BxWjdS','_closeSharedEnvs','cpuUsage','exports','FUNCTION_CANCELLED','postMessage','default','fts:registered','stats','8632qKpsCe','open','sort','started','cancel','timeoutMs','onWindow','worker\x20OKDB\x20open\x20failed:\x20','note','starting','external','rss','SYSTEM_PROC','_tierFor','defaultMemoryMb','env:removed','then','heapTotal','pid','Spawned\x20queue\x20worker\x20export\x20not\x20found\x20or\x20not\x20a\x20function:\x20','openEnv','sync:apply','requestId','runId','worker:\x20no\x20init\x20message\x20received','30HVOOmD','warn','maxConcurrency','ppid','key','license:activated','queue-worker','MB\x20heap\x20cap)','handler\x20module\x20failed\x20to\x20load:\x20','processor','Could\x20not\x20dynamically\x20require\x20\x22','index:registered','SYSTEM_DRAIN','platform','view:progress','function\x20exceeded\x20','openDB','ms\x20mean=','3625788cCJKqe','fts:reset','inFlightCount','viewName','rejectReady','claimAndRunWorkerBootstrap','graceMs','views','okdb.js','events','startsWith','stopping','function\x20sandbox\x20out\x20of\x20memory\x20(tier\x20','isHeld','write','item:remove','function','_envs','sandbox\x20terminated\x20for\x20a\x20sibling\x20job\x20—\x20retryable','result','idleTimer','fn-sandbox:','__esModule','~proc:bootstrap-index','get','round','watchdog','length','worker','_windowCbs','blocks','passive','memoryUsage','_buckets','env\x20has\x20no\x20queue\x20feature\x20attached','_onMessage','now','\x20evicted','values','588judiWh','bootstrap','tierList','bus:poke','164862tgVJNt','Spawned\x20queue\x20worker\x20module\x20must\x20export\x20a\x20function\x20or\x20default\x20function','ms\x20max=','disconnect','catch','FUNCTION_SANDBOX_EXIT','2JAGoED','scope','unique:violation_resolved','function\x20cancelled\x20—\x20did\x20not\x20unwind\x20within\x20grace;\x20sandbox\x20terminated','_failTier','ERR_WORKER_OUT_OF_MEMORY','FUNCTION_FAILED','~fn:requests','system:type_drop','slice','code','_bareOpen','stopAll','off','lastError','\x20(resident=','env-removed','fts','system:proc','clearThreadStats','onThreadStats','reduce','start','unhandledRejection:\x20','active','944038BpOhtZ','reportThreadStats','toFixed','max','join','item:create','setLogger','put','dropping','schema:set','keys','SYSTEM_POKE','processes','finally','listDesired','worker_threads','index:ready','delete','cost','idleMs','fatal','init','message','push','wedged','_viewState','system:drain','exportName','dropType','SandboxHost:\x20rootPath\x20required','name','running','_ensureTier','process','loop-lag','ttl:expired','inFlight','ms\x20p99=','queueType','heapUsed','_processorStops','split','index:progress','level','heavy'];_0x33bb=function(){return _0x2fc3d8;};return _0x33bb();}var okdbIntakeGate,hasRequiredOkdbIntakeGate;function requireOkdbIntakeGate(){if(hasRequiredOkdbIntakeGate)return okdbIntakeGate;hasRequiredOkdbIntakeGate=0x1;const _0x3337fe=0x2,_0x1eea73=0x2,_0x415017=0x2;function _0x59293d({gateMs:_0x281b90}){let _0x24ae0e=0x0,_0x8431b=0x0,_0x1873e5=0x0;return{'level':()=>_0x24ae0e,'blocks'(_0x50c3ce){const _0x4fd271=_0x3fcd;if(_0x50c3ce==='control')return![];if(_0x24ae0e>=0x2)return!![];if(_0x24ae0e>=0x1&&_0x50c3ce===_0x4fd271(0x299))return!![];return![];},'onWindow'(_0x10fa56){if(_0x10fa56>_0x281b90){_0x8431b++,_0x1873e5=0x0;if(_0x8431b>=_0x3337fe&&_0x24ae0e<_0x415017)return _0x24ae0e++,_0x8431b=0x0,{'changed':!![],'level':_0x24ae0e};}else{if(_0x10fa56<_0x281b90/0x2){_0x1873e5++,_0x8431b=0x0;if(_0x1873e5>=_0x1eea73&&_0x24ae0e>0x0)return _0x24ae0e--,_0x1873e5=0x0,{'changed':!![],'level':_0x24ae0e};}else _0x8431b=0x0,_0x1873e5=0x0;}return{'changed':![],'level':_0x24ae0e};}};}return okdbIntakeGate={'createIntakeGate':_0x59293d},okdbIntakeGate;}var okdbQueueLoadHandler,hasRequiredOkdbQueueLoadHandler;function requireOkdbQueueLoadHandler(){if(hasRequiredOkdbQueueLoadHandler)return okdbQueueLoadHandler;hasRequiredOkdbQueueLoadHandler=0x1;function _0x9b1cd9(_0x219665,_0x30ab2f){const _0x9372a9=_0x3fcd,_0x1f8644=commonjsRequire(_0x219665);if(_0x30ab2f&&_0x30ab2f!==_0x9372a9(0x1f5)){const _0xc9346=_0x1f8644?.[_0x30ab2f];if(typeof _0xc9346!=='function')throw new Error(_0x9372a9(0x20b)+_0x30ab2f);return _0xc9346;}if(typeof _0x1f8644===_0x9372a9(0x233))return _0x1f8644;if(typeof _0x1f8644?.[_0x9372a9(0x1f5)]===_0x9372a9(0x233))return _0x1f8644[_0x9372a9(0x1f5)];throw new Error(_0x9372a9(0x24f));}return okdbQueueLoadHandler={'loadHandler':_0x9b1cd9},okdbQueueLoadHandler;}var okdbFunctionsSandboxHost,hasRequiredOkdbFunctionsSandboxHost;function requireOkdbFunctionsSandboxHost(){const _0x2f3b32=_0x275d88;if(hasRequiredOkdbFunctionsSandboxHost)return okdbFunctionsSandboxHost;hasRequiredOkdbFunctionsSandboxHost=0x1;const _0x549994=require$$0$1,{Worker:_0x5aa049}=require$$1,_0x55000f=_0x549994[_0x2f3b32(0x271)](__dirname,'okdb-functions-sandbox-worker.js'),_0x374141=0x100,_0x54e465=0x3e8;function _0x14900d(_0x3c8ffe,_0x425476){const _0x3a5b30=_0x2f3b32,_0x7be452=new Error(_0x3c8ffe);return _0x7be452[_0x3a5b30(0x25e)]=_0x425476,_0x7be452;}class _0x34bbf2{constructor({rootPath:_0x426c15,memoryMb:_0x13c2f1,maxConcurrency:_0x1e7a57,idleMs:_0x45e585,graceMs:_0xc73f9b,onThreadStats:_0xf245ea,log:_0x2998c8}={}){const _0x130c48=_0x2f3b32;if(!_0x426c15)throw new Error(_0x130c48(0x28a));this[_0x130c48(0x2ab)]=_0x426c15,this[_0x130c48(0x206)]=Math[_0x130c48(0x270)](0x20,Math['floor'](_0x13c2f1??_0x374141)),this[_0x130c48(0x213)]=Math[_0x130c48(0x270)](0x1,Number(process.env.OKDB_FN_SANDBOX_CONCURRENCY)||_0x1e7a57||0x4),this['idleMs']=Math['max'](0x3e8,Number(process.env.OKDB_FN_SANDBOX_IDLE_MS)||_0x45e585||0x7530),this['graceMs']=Math['max'](0x64,Number(process.env.OKDB_FN_SANDBOX_GRACE_MS)||_0xc73f9b||0x5dc),this[_0x130c48(0x268)]=_0xf245ea??null,this[_0x130c48(0x1a2)]=_0x2998c8??null,this[_0x130c48(0x2a3)]=new Map(),this[_0x130c48(0x1c2)]=![];}[_0x2f3b32(0x225)](){const _0x200d0a=_0x2f3b32;let _0x4dc506=0x0;for(const _0x279ff0 of this[_0x200d0a(0x2a3)]['values']())_0x4dc506+=_0x279ff0[_0x200d0a(0x1b7)][_0x200d0a(0x2b5)];return _0x4dc506;}['_tierFor'](){const _0x4fa5c7=_0x2f3b32;return this[_0x4fa5c7(0x206)];}[_0x2f3b32(0x28d)](_0xdc0173){const _0x511c8d=_0x2f3b32;let _0x41c4f9=this[_0x511c8d(0x2a3)][_0x511c8d(0x23b)](_0xdc0173);if(_0x41c4f9)return _0x41c4f9;const _0xe18d5b=new _0x5aa049(_0x55000f,{'workerData':{'rootPath':this[_0x511c8d(0x2ab)]},'stdout':!![],'stderr':!![]});_0xe18d5b[_0x511c8d(0x1ec)]?.[_0x511c8d(0x1c1)](),_0xe18d5b['stderr']?.[_0x511c8d(0x1c1)](),_0xe18d5b[_0x511c8d(0x2b6)]?.();let _0x66cba4;const _0x46a4f1=new Promise((_0x5522aa,_0x4c8aae)=>{const _0xe64233=_0x511c8d,_0x1063e2=(_0x596b15,_0x424ded)=>{const _0x57e77b=_0x3fcd;_0x41c4f9['readySettled']=!![],_0xe18d5b['off'](_0x57e77b(0x283),_0x469b9c),_0x596b15(_0x424ded);},_0x469b9c=_0x18497d=>{const _0x5bdab4=_0x3fcd;if(_0x18497d?.[_0x5bdab4(0x1ed)]===_0x5bdab4(0x1c6))_0x1063e2(_0x5522aa);else{if(_0x18497d?.[_0x5bdab4(0x1ed)]===_0x5bdab4(0x281))_0x1063e2(_0x4c8aae,_0x14900d(_0x18497d[_0x5bdab4(0x2a4)]?.[_0x5bdab4(0x283)]??'sandbox\x20failed\x20to\x20boot',_0x5bdab4(0x253)));}};_0x66cba4=_0x3ed5ad=>_0x1063e2(_0x4c8aae,_0x3ed5ad),_0xe18d5b['on'](_0xe64233(0x283),_0x469b9c);});return _0x41c4f9={'worker':_0xe18d5b,'inflight':new Map(),'idleTimer':null,'readySettled':![],'rejectReady':_0x66cba4,'ready':_0x46a4f1},_0x41c4f9[_0x511c8d(0x1c6)][_0x511c8d(0x252)](()=>{}),this[_0x511c8d(0x2a3)][_0x511c8d(0x1be)](_0xdc0173,_0x41c4f9),_0xe18d5b['on'](_0x511c8d(0x283),_0x4889f2=>this[_0x511c8d(0x246)](_0xdc0173,_0x41c4f9,_0x4889f2)),_0xe18d5b['on']('error',_0x38eb05=>{const _0x381e9b=_0x511c8d,_0x410771=_0x38eb05?.[_0x381e9b(0x25e)]===_0x381e9b(0x259);this[_0x381e9b(0x258)](_0xdc0173,_0x41c4f9,_0x410771?_0x14900d(_0x381e9b(0x22f)+_0xdc0173+_0x381e9b(0x218),_0x381e9b(0x1ac)):_0x14900d('function\x20sandbox\x20error:\x20'+(_0x38eb05?.[_0x381e9b(0x283)]??_0x38eb05),_0x381e9b(0x253)));}),_0xe18d5b['on'](_0x511c8d(0x2b0),_0x4d974b=>{const _0x4d6fe9=_0x511c8d;this[_0x4d6fe9(0x258)](_0xdc0173,_0x41c4f9,_0x14900d('function\x20sandbox\x20exited\x20(code\x20'+_0x4d974b+')',_0x4d6fe9(0x253)));}),_0x41c4f9;}[_0x2f3b32(0x246)](_0x163362,_0x48d7bf,_0x5c42cb){const _0x9e561b=_0x2f3b32;if(!_0x5c42cb||typeof _0x5c42cb!==_0x9e561b(0x1a4))return;if(_0x5c42cb[_0x9e561b(0x1ed)]==='stats'){this[_0x9e561b(0x268)]?.(_0x9e561b(0x238)+_0x163362,{'heapUsed':_0x5c42cb[_0x9e561b(0x294)]??0x0});return;}const _0x5dfcd6=_0x5c42cb[_0x9e561b(0x20e)]!=null?_0x48d7bf[_0x9e561b(0x1b7)][_0x9e561b(0x23b)](_0x5c42cb[_0x9e561b(0x20e)]):null;if(!_0x5dfcd6)return;if(_0x5c42cb[_0x9e561b(0x1ed)]===_0x9e561b(0x1a2)){_0x5dfcd6[_0x9e561b(0x2c1)][_0x9e561b(0x284)](_0x5c42cb[_0x9e561b(0x1ad)]);return;}if(_0x5c42cb[_0x9e561b(0x1ed)]===_0x9e561b(0x236)||_0x5c42cb[_0x9e561b(0x1ed)]===_0x9e561b(0x2a4))_0x48d7bf[_0x9e561b(0x1b7)][_0x9e561b(0x27e)](_0x5c42cb['requestId']),clearTimeout(_0x5dfcd6[_0x9e561b(0x23d)]),_0x5dfcd6[_0x9e561b(0x29b)]({'message':_0x5c42cb,'logs':_0x5dfcd6[_0x9e561b(0x2c1)]}),this[_0x9e561b(0x1ce)](_0x163362,_0x48d7bf);else _0x5dfcd6['onEmit']&&_0x5dfcd6[_0x9e561b(0x18c)](_0x5c42cb);}async[_0x2f3b32(0x1c7)](_0x60b654,{onEmit:_0x116a66}={}){const _0x43fb1a=_0x2f3b32;if(this[_0x43fb1a(0x1c2)])throw _0x14900d(_0x43fb1a(0x2c2),'FUNCTION_SANDBOX_EXIT');const _0x234855=this[_0x43fb1a(0x205)](_0x60b654),_0x5f479c=this[_0x43fb1a(0x28d)](_0x234855);return _0x5f479c['idleTimer']&&(clearTimeout(_0x5f479c[_0x43fb1a(0x237)]),_0x5f479c[_0x43fb1a(0x237)]=null),await _0x5f479c[_0x43fb1a(0x1c6)],new Promise((_0x4e25ad,_0x5c2df7)=>{const _0x2dfc8f=_0x43fb1a,_0x2de8ce=Math[_0x2dfc8f(0x270)](0x1,_0x60b654['runtime']?.[_0x2dfc8f(0x1fd)]??_0x54e465),_0x453308={'resolve':_0x4e25ad,'reject':_0x5c2df7,'logs':[],'onEmit':_0x116a66??null,'cancelled':![],'watchdog':setTimeout(()=>{const _0x4d2376=_0x2dfc8f;this[_0x4d2376(0x19b)](_0x234855,_0x5f479c,_0x60b654['requestId'],_0x14900d(_0x4d2376(0x220)+_0x2de8ce+_0x4d2376(0x2b9)+this[_0x4d2376(0x229)]+_0x4d2376(0x1c8),_0x453308[_0x4d2376(0x1e0)]?'FUNCTION_CANCELLED':'FUNCTION_TIMEOUT'));},_0x2de8ce+this[_0x2dfc8f(0x229)])};if(_0x453308[_0x2dfc8f(0x23d)][_0x2dfc8f(0x2b6)])_0x453308['watchdog'][_0x2dfc8f(0x2b6)]();_0x5f479c['inflight'][_0x2dfc8f(0x1be)](_0x60b654[_0x2dfc8f(0x20e)],_0x453308),_0x5f479c['worker'][_0x2dfc8f(0x1f4)]({'type':_0x2dfc8f(0x1c7),'job':_0x60b654});});}[_0x2f3b32(0x1fc)](_0x4052b5){const _0x405b83=_0x2f3b32;for(const [_0xe69efe,_0x25cfe9]of this['_tiers']){const _0x4c5de2=_0x25cfe9[_0x405b83(0x1b7)][_0x405b83(0x23b)](_0x4052b5);if(!_0x4c5de2)continue;if(_0x4c5de2[_0x405b83(0x1e0)])return!![];_0x4c5de2['cancelled']=!![],_0x25cfe9[_0x405b83(0x23f)][_0x405b83(0x1f4)]({'type':'cancel','requestId':_0x4052b5}),clearTimeout(_0x4c5de2[_0x405b83(0x23d)]),_0x4c5de2[_0x405b83(0x23d)]=setTimeout(()=>{const _0x2f6fe8=_0x405b83;this[_0x2f6fe8(0x19b)](_0xe69efe,_0x25cfe9,_0x4052b5,_0x14900d(_0x2f6fe8(0x257),_0x2f6fe8(0x1f3)));},this[_0x405b83(0x229)]);if(_0x4c5de2['watchdog'][_0x405b83(0x2b6)])_0x4c5de2[_0x405b83(0x23d)][_0x405b83(0x2b6)]();return!![];}return![];}[_0x2f3b32(0x19b)](_0xe85e34,_0x49852e,_0x54bb10,_0x8ca10b){const _0x56be72=_0x2f3b32;for(const [_0x830f91,_0x44e8dd]of _0x49852e['inflight']){clearTimeout(_0x44e8dd['watchdog']),_0x44e8dd[_0x56be72(0x196)](_0x830f91===_0x54bb10?_0x8ca10b:_0x14900d(_0x56be72(0x235),_0x56be72(0x253)));}_0x49852e[_0x56be72(0x1b7)][_0x56be72(0x1da)](),this[_0x56be72(0x2a9)](_0xe85e34,_0x49852e);}[_0x2f3b32(0x258)](_0x20a137,_0x1062ef,_0x1e362e){const _0x5ac98f=_0x2f3b32;if(this['_tiers'][_0x5ac98f(0x23b)](_0x20a137)!==_0x1062ef)return;if(!_0x1062ef['readySettled'])_0x1062ef[_0x5ac98f(0x227)]?.(_0x1e362e);for(const [,_0x4fd045]of _0x1062ef[_0x5ac98f(0x1b7)]){clearTimeout(_0x4fd045[_0x5ac98f(0x23d)]),_0x4fd045[_0x5ac98f(0x196)](_0x1e362e);}_0x1062ef[_0x5ac98f(0x1b7)][_0x5ac98f(0x1da)](),this['_dropTier'](_0x20a137,_0x1062ef);}['_dropTier'](_0x41d4ab,_0xd491fa){const _0x28ce67=_0x2f3b32;if(this[_0x28ce67(0x2a3)]['get'](_0x41d4ab)===_0xd491fa)this['_tiers']['delete'](_0x41d4ab);if(_0xd491fa[_0x28ce67(0x237)])clearTimeout(_0xd491fa['idleTimer']);this[_0x28ce67(0x268)]?.('fn-sandbox:'+_0x41d4ab,null),_0xd491fa['worker'][_0x28ce67(0x2bc)]()[_0x28ce67(0x252)](()=>{});}[_0x2f3b32(0x1ce)](_0x593ef4,_0x16ca37){const _0x5a1d92=_0x2f3b32;if(_0x16ca37[_0x5a1d92(0x1b7)][_0x5a1d92(0x2b5)]>0x0||_0x16ca37[_0x5a1d92(0x237)])return;_0x16ca37['idleTimer']=setTimeout(()=>this[_0x5a1d92(0x2a9)](_0x593ef4,_0x16ca37),this[_0x5a1d92(0x280)]);if(_0x16ca37[_0x5a1d92(0x237)][_0x5a1d92(0x2b6)])_0x16ca37[_0x5a1d92(0x237)]['unref']();}[_0x2f3b32(0x29e)](){const _0x4bb180=_0x2f3b32;for(const [_0x26ede3,_0x453947]of[...this[_0x4bb180(0x2a3)]]){this[_0x4bb180(0x258)](_0x26ede3,_0x453947,_0x14900d('sandbox\x20recycled',_0x4bb180(0x253)));}}async[_0x2f3b32(0x1d6)](){const _0x5efd41=_0x2f3b32;this[_0x5efd41(0x1c2)]=!![],this[_0x5efd41(0x29e)]();}}return okdbFunctionsSandboxHost={'SandboxHost':_0x34bbf2,'SANDBOX_ENTRY':_0x55000f},okdbFunctionsSandboxHost;}var hasRequiredOkdbWorkerChild;function requireOkdbWorkerChild(){const _0x328e3b=_0x275d88;if(hasRequiredOkdbWorkerChild)return okdbWorkerChild$1;hasRequiredOkdbWorkerChild=0x1;const _0x16a176=require$$0$1;function _0x34a535(_0x34a0eb){const _0x23554d=_0x3fcd;try{if(typeof process[_0x23554d(0x1e8)]===_0x23554d(0x233))process[_0x23554d(0x1e8)](_0x34a0eb);}catch{}}let _0x3e9c98=![],_0x1f69bb=null;async function _0x1bd3b1(_0x288f2c,_0x4ae721){const _0x316c79=_0x3fcd;if(_0x3e9c98)return;_0x3e9c98=!![];try{await _0x1f69bb?.['stop']?.();}catch{}const _0x15853a=setTimeout(()=>process[_0x316c79(0x2b0)](_0x288f2c),0xbb8);if(typeof _0x15853a['unref']===_0x316c79(0x233))_0x15853a['unref']();try{await _0x4ae721?.[_0x316c79(0x2aa)]?.();}catch{}process['exit'](_0x288f2c);}function _0x453185(_0x425760,_0x43723c,_0x22f8b8=null){const _0x247b67=_0x3fcd,_0x361de3=require$$1$1;let _0x3d3007=process[_0x247b67(0x1f1)](),_0x3c97be=Date[_0x247b67(0x247)]();const _0x4f60ba=()=>{const _0x45fd38=_0x247b67;try{const _0x259c19=[];for(const [_0x3ce171,_0x49de41]of _0x43723c[_0x45fd38(0x234)]){if(_0x3ce171[_0x45fd38(0x22d)]('~'))continue;for(const _0x52a1fd of _0x49de41[_0x45fd38(0x21a)][_0x45fd38(0x24c)]())_0x259c19[_0x45fd38(0x284)]({..._0x52a1fd,'env':_0x3ce171});}return _0x259c19['length']>0x0?{'processors':_0x259c19}:null;}catch{return null;}},_0x4f43da=()=>{const _0xde47=_0x247b67;if(_0x3e9c98)return;const _0x128f15=Date[_0xde47(0x247)](),_0x51cb2d=process[_0xde47(0x1f1)](),_0x1c148f=(_0x128f15-_0x3c97be)*0x3e8,_0x23d73c=_0x51cb2d[_0xde47(0x1ae)]-_0x3d3007[_0xde47(0x1ae)]+(_0x51cb2d[_0xde47(0x190)]-_0x3d3007[_0xde47(0x190)]),_0x5035c3=_0x1c148f>0x0?Math['min'](0x64,Math[_0xde47(0x23c)](_0x23d73c/(_0x1c148f*(_0x361de3['cpus']()[_0xde47(0x23e)]||0x1))*0x64)):0x0;_0x3d3007=_0x51cb2d,_0x3c97be=_0x128f15;const _0x4d7b35=process[_0xde47(0x243)]();_0x425760({'type':_0xde47(0x1f7),'stats':{'rss':_0x4d7b35[_0xde47(0x203)],'heapUsed':_0x4d7b35[_0xde47(0x294)],'heapTotal':_0x4d7b35[_0xde47(0x209)],'external':_0x4d7b35[_0xde47(0x202)],'cpuPct':_0x5035c3,'cpuWindowMs':Math[_0xde47(0x23c)](_0x1c148f/0x3e8)||null,..._0x22f8b8?.()??{}},'processing':_0x4f60ba()});},_0x509020=Math['max'](0x3e8,Number(process.env.OKDB_STATS_INTERVAL_MS)||0x1388),_0x277efe=setInterval(_0x4f43da,_0x509020);if(typeof _0x277efe[_0x247b67(0x2b6)]===_0x247b67(0x233))_0x277efe[_0x247b67(0x2b6)]();}process['on'](_0x328e3b(0x1b0),_0x3a0915=>{const _0x258ca0=_0x328e3b;_0x34a535({'type':_0x258ca0(0x212),'msg':_0x258ca0(0x26b)+(_0x3a0915?.[_0x258ca0(0x283)]??_0x3a0915)});});async function _0x13d282(){const _0x55f329=_0x328e3b,_0x2fd1d5=await new Promise((_0x3644b0,_0xbdb00a)=>{const _0x500fcf=_0x3fcd,_0x2b3ddb=_0xf98c32=>{const _0x5ef6c6=_0x3fcd;_0xf98c32?.[_0x5ef6c6(0x1ed)]===_0x5ef6c6(0x282)&&(process[_0x5ef6c6(0x261)](_0x5ef6c6(0x283),_0x2b3ddb),_0x3644b0(_0xf98c32));};process['on'](_0x500fcf(0x283),_0x2b3ddb);const _0x1459c1=setTimeout(()=>{const _0x1705ea=_0x500fcf;process[_0x1705ea(0x261)](_0x1705ea(0x283),_0x2b3ddb),_0xbdb00a(new Error(_0x1705ea(0x210)));},0x2710);if(typeof _0x1459c1['unref']===_0x500fcf(0x233))_0x1459c1[_0x500fcf(0x2b6)]();}),{rootPath:_0xa5a48f,slot:_0x2d9485,supervisorKey:_0x5f96e2}=_0x2fd1d5,_0x5ecd13=commonjsRequire(_0x16a176[_0x55f329(0x271)](__dirname,'..',_0x55f329(0x22b))),{EVENTS:_0x2e5d86}=requireOkdbEnums(),_0x167555=new _0x5ecd13(_0xa5a48f,{'engines':![],'http':![],'asyncProcessors':!![],'compaction':_0x55f329(0x242),'envs':_0x55f329(0x1e7),'auth':{'open':!![]},'processing':_0x55f329(0x2a8)});{const _0x5abf06={'debug':0x0,'info':0x1,'warn':0x2,'error':0x3},_0x160a78=_0x5abf06[process.env.OKDB_WORKERS_LOG_LEVEL]??_0x5abf06[_0x55f329(0x212)];_0x167555[_0x55f329(0x1a2)][_0x55f329(0x2a0)]?.(),_0x167555['log'][_0x55f329(0x2c0)](_0x24a3a1=>{const _0x522a5e=_0x55f329;if((_0x5abf06[_0x24a3a1[_0x522a5e(0x298)]]??0x1)<_0x160a78)return;_0x34a535({'type':_0x522a5e(0x1a2),'entry':_0x24a3a1});});}try{await _0x167555[_0x55f329(0x1f9)]();}catch(_0x183785){_0x34a535({'type':_0x55f329(0x2a4),'error':_0x55f329(0x1ff)+_0x183785['message']}),process[_0x55f329(0x2b0)](0x1);return;}const _0x3a529e=Math[_0x55f329(0x270)](0x4,Number(process.env.OKDB_WORKERS_ENV_CACHE)||0x40),_0x5787bb=new Map(),_0x403685=new Set();function _0x2570e2(_0x3260bb){const _0x31f7b3=_0x55f329;try{for(const _0xe89462 of _0x3260bb[_0x31f7b3(0x21a)]?.['_registrations']?.[_0x31f7b3(0x249)]()??[]){if(_0xe89462[_0x31f7b3(0x18f)]?.[_0x31f7b3(0x230)]?.())return!![];}}catch{}return![];}function _0x197315(_0x12f9cb,_0x414506){const _0x2124bb=_0x55f329;if(_0x403685[_0x2124bb(0x1d4)](_0x12f9cb))return!![];if(_0x2570e2(_0x414506))return!![];for(const [,_0x45d4c7]of _0x411e51){if(_0x45d4c7?.[_0x2124bb(0x1a5)]===_0x12f9cb)return!![];}return![];}async function _0x302423(_0x4784b1,_0x5c2965){const _0xe49c65=_0x55f329;for(const _0x3120b9 of[..._0x167555['fts'][_0xe49c65(0x295)]?.[_0xe49c65(0x277)]?.()??[]]){if(!_0x3120b9[_0xe49c65(0x22d)](_0x4784b1+':'))continue;const _0x27c9d2=_0x167555[_0xe49c65(0x265)][_0xe49c65(0x295)][_0xe49c65(0x23b)](_0x3120b9);_0x167555[_0xe49c65(0x265)][_0xe49c65(0x295)][_0xe49c65(0x27e)](_0x3120b9);try{await _0x27c9d2?.();}catch{}}try{await _0x5c2965[_0xe49c65(0x21a)]?.[_0xe49c65(0x260)]?.();}catch{}}async function _0x11b83b(_0x450b99){const _0x26fdb8=_0x55f329,_0x3584f8=_0x5787bb['get'](_0x450b99);if(!_0x3584f8)return;_0x5787bb['delete'](_0x450b99),await _0x302423(_0x450b99,_0x3584f8);try{await _0x3584f8['timeMachine']?.[_0x26fdb8(0x1d6)]?.();}catch{}try{await _0x167555['fts'][_0x26fdb8(0x1f0)]?.(_0x450b99);}catch{}_0x167555[_0x26fdb8(0x234)][_0x26fdb8(0x27e)](_0x450b99);try{await _0x3584f8[_0x26fdb8(0x2aa)]();}catch{}}async function _0x3c9051(_0x202526){const _0x5aad65=_0x55f329;if(_0x5787bb[_0x5aad65(0x1d4)](_0x202526)){const _0xd2ed13=_0x5787bb[_0x5aad65(0x23b)](_0x202526);return _0x5787bb['delete'](_0x202526),_0x5787bb[_0x5aad65(0x1be)](_0x202526,_0xd2ed13),_0xd2ed13;}const _0x10b868=_0x167555[_0x5aad65(0x234)][_0x5aad65(0x23b)](_0x202526);if(_0x10b868&&!_0x10b868[_0x5aad65(0x25f)])return _0x10b868;if(_0x5787bb['size']>=_0x3a529e)for(const [_0x53f91d,_0x5e73d7]of _0x5787bb){if(!_0x197315(_0x53f91d,_0x5e73d7)){await _0x11b83b(_0x53f91d);break;}}const _0x4e88bd=await _0x167555[_0x5aad65(0x20c)](_0x202526);return _0x5787bb['set'](_0x202526,_0x4e88bd),_0x4e88bd;}_0x167555['events']['on'](_0x2e5d86[_0x55f329(0x21d)],()=>{const _0x4aadc3=_0x55f329;(async()=>{for(const [_0x30bfd3,_0x35d438]of[..._0x5787bb]){if(!_0x197315(_0x30bfd3,_0x35d438))await _0x11b83b(_0x30bfd3);}})()[_0x4aadc3(0x252)](()=>{});});const _0xc54753=setInterval(()=>{const _0x29e4e2=_0x55f329;if(_0x3e9c98)return;for(const [,_0x520fb6]of _0x167555['_envs']){try{_0x520fb6[_0x29e4e2(0x1e6)]?.();}catch{}}},0xc8);if(typeof _0xc54753['unref']===_0x55f329(0x233))_0xc54753['unref']();process['on'](_0x55f329(0x251),()=>_0x1bd3b1(0x0,_0x167555));if(process[_0x55f329(0x21e)]!==_0x55f329(0x19f)){const _0x40e029=setInterval(()=>{const _0xf10a34=_0x55f329;if(process[_0xf10a34(0x214)]===0x1)_0x1bd3b1(0x0,_0x167555);},0x7d0);if(typeof _0x40e029['unref']===_0x55f329(0x233))_0x40e029[_0x55f329(0x2b6)]();}process['on']('message',_0x18a5c6=>{const _0xc4b97b=_0x55f329;if(_0x18a5c6?.['type']===_0xc4b97b(0x1d6))_0x1bd3b1(0x0,_0x167555);});const {LOOP:_0x39b1b8}=requireOkdbLoopMonitor(),{createIntakeGate:_0x4422a4}=requireOkdbIntakeGate(),_0x224253=Number(process.env.OKDB_WORKERS_MAX_LEASES)||0x20,_0xdd52e9=Number(process.env.OKDB_WORKERS_LAG_GATE_MS)||0xc8,_0x4b384e=Number(process.env.OKDB_WORKERS_WEDGE_MS)||0x7530,_0x1c225e=_0x4422a4({'gateMs':_0xdd52e9});_0x39b1b8[_0x55f329(0x1fe)](({p99Ms:_0x5c7406,maxMs:_0x592db2})=>{const _0x330d83=_0x55f329;_0x592db2>_0x4b384e&&_0x34a535({'type':_0x330d83(0x285),'maxMs':_0x592db2});const {changed:_0x31110d,level:_0x4d4d4f}=_0x1c225e[_0x330d83(0x1fe)](_0x5c7406);if(_0x31110d)_0x34a535({'type':'intake','level':_0x4d4d4f,'p99Ms':_0x5c7406});});const {loadHandler:_0x10d862}=requireOkdbQueueLoadHandler(),_0x411e51=new Map();let _0x3898c9=![],_0x12e641={'defsSeen':-0x1,'lastError':null,'at':0x0};const _0x33cd9f=new Set(),_0x2ab6df=(_0x4abdca,_0x94832e)=>{const _0x226d08=_0x55f329,_0x585676=_0x4abdca+'::'+_0x94832e;if(_0x33cd9f[_0x226d08(0x1d4)](_0x585676))return;_0x33cd9f[_0x226d08(0x2b7)](_0x585676),_0x34a535({'type':'warn','msg':_0x226d08(0x29d)+_0x4abdca+'\x20—\x20'+_0x94832e});},_0x29990d={'name':'queue','cost':_0x55f329(0x1d3),'inFlight':()=>_0x411e51['size'],'detail':()=>({'consumers':[..._0x411e51['keys']()],'tick':_0x12e641}),async 'tick'(){const _0x368aee=_0x55f329;if(_0x3898c9||_0x3e9c98)return;_0x3898c9=!![];try{const _0x3eef53=_0x167555[_0x368aee(0x279)][_0x368aee(0x27b)]?.('queue-worker')??[];_0x12e641={'defsSeen':_0x3eef53['length'],'lastError':null,'at':Date[_0x368aee(0x247)]()};const _0x28cf6a=new Set();for(const {key:_0xdc3b05,value:_0x357cff}of _0x3eef53){if(!_0x357cff||_0x357cff[_0x368aee(0x26c)]===![])continue;_0x28cf6a[_0x368aee(0x2b7)](_0xdc3b05);const _0x4edfed=_0x411e51[_0x368aee(0x23b)](_0xdc3b05);if(_0x4edfed){if(_0x4edfed['version']===_0x357cff[_0x368aee(0x19a)])continue;_0x411e51[_0x368aee(0x27e)](_0xdc3b05);try{await _0x4edfed[_0x368aee(0x23f)]?.['stop']?.();}catch{}}const _0x3cc472=_0x357cff[_0x368aee(0x1a5)]??_0xdc3b05['split']('::')[0x0];let _0x47e9f7;try{_0x47e9f7=await _0x3c9051(_0x3cc472);}catch(_0xe13fda){_0x2ab6df(_0xdc3b05,'env\x20open\x20failed:\x20'+_0xe13fda?.[_0x368aee(0x283)]);continue;}if(!_0x47e9f7?.[_0x368aee(0x1d5)]){_0x2ab6df(_0xdc3b05,_0x368aee(0x245));continue;}let _0x4e1d98;try{_0x4e1d98=_0x10d862(_0x357cff[_0x368aee(0x2a7)],_0x357cff[_0x368aee(0x288)]);}catch(_0x5f1b72){_0x2ab6df(_0xdc3b05,_0x368aee(0x219)+_0x5f1b72?.[_0x368aee(0x283)]);continue;}let _0x575df7;try{_0x575df7=_0x47e9f7['queue'][_0x368aee(0x28e)](_0x357cff[_0x368aee(0x293)]??_0xdc3b05[_0x368aee(0x296)]('::')[0x1],_0x4e1d98,_0x357cff[_0x368aee(0x1ee)]??{});}catch(_0x3d9b4f){_0x2ab6df(_0xdc3b05,_0x368aee(0x1d0)+_0x3d9b4f?.[_0x368aee(0x283)]);continue;}_0x411e51['set'](_0xdc3b05,{'worker':_0x575df7,'version':_0x357cff['version'],'envName':_0x3cc472});}for(const [_0x58661f,_0x291bfd]of[..._0x411e51]){if(!_0x28cf6a['has'](_0x58661f)){_0x411e51[_0x368aee(0x27e)](_0x58661f),_0x34a535({'type':_0x368aee(0x212),'msg':'queue\x20consumer\x20stopped\x20(def\x20deregistered):\x20'+_0x58661f});try{await _0x291bfd['worker']?.[_0x368aee(0x1d6)]?.();}catch{}}}}catch(_0x40731b){_0x12e641[_0x368aee(0x262)]=_0x40731b?.[_0x368aee(0x283)]??String(_0x40731b);throw _0x40731b;}finally{_0x3898c9=![];}}};let _0x4afc6e;{const {SandboxHost:_0x41943f}=requireOkdbFunctionsSandboxHost(),_0x554414=_0x167555[_0x55f329(0x189)][_0x55f329(0x221)](_0x55f329(0x25b),{'dupSort':![]}),_0x2e3d7b=_0x167555[_0x55f329(0x189)][_0x55f329(0x221)]('~fn:responses',{'dupSort':![]}),_0x3efdfd=Number(process.env.OKDB_FN_STALE_MS)||0xea60,_0x94eec6=new _0x41943f({'rootPath':_0xa5a48f,'log':_0x167555[_0x55f329(0x1a2)],'onThreadStats':(_0x40010a,_0x1910c4)=>{const _0x116555=_0x55f329;if(_0x1910c4)_0x167555[_0x116555(0x279)]?.[_0x116555(0x26e)]?.(_0x40010a,_0x1910c4);else _0x167555[_0x116555(0x279)]?.[_0x116555(0x267)]?.(_0x40010a);}});_0x1f69bb=_0x94eec6;const _0x48053d=new Set(),_0x30df13=(_0x296918,_0x2a3f12)=>{const _0x8b82c1=_0x55f329,_0x3ba75d=_0x554414[_0x8b82c1(0x23b)](_0x296918);if(!_0x3ba75d||_0x3ba75d[_0x8b82c1(0x1b4)]===_0x8b82c1(0x1e0)){try{_0x554414[_0x8b82c1(0x1a7)](_0x296918);}catch{}return;}_0x2e3d7b[_0x8b82c1(0x18d)](_0x296918,_0x2a3f12);try{_0x554414[_0x8b82c1(0x1a7)](_0x296918);}catch{}},_0xd78ba0=(_0x286b50,_0x3902e7)=>{const _0x2eef95=_0x55f329;_0x48053d[_0x2eef95(0x2b7)](_0x286b50),_0x94eec6[_0x2eef95(0x1c7)]({..._0x3902e7,'requestId':_0x286b50})[_0x2eef95(0x208)](({message:_0x20d744,logs:_0x1b02eb})=>_0x30df13(_0x286b50,{'message':_0x20d744,'logs':_0x1b02eb}))[_0x2eef95(0x252)](_0x1e55c3=>{const _0x1cee6a=_0x2eef95;if(_0x1e55c3?.[_0x1cee6a(0x25e)]===_0x1cee6a(0x253)){try{const _0x112595=_0x554414['get'](_0x286b50);_0x112595&&_0x112595['state']===_0x1cee6a(0x28c)&&_0x112595[_0x1cee6a(0x1cb)]===process[_0x1cee6a(0x20a)]&&_0x554414[_0x1cee6a(0x18d)](_0x286b50,{..._0x112595,'state':_0x1cee6a(0x193),'requestedAt':Date[_0x1cee6a(0x247)]()});}catch{}return;}_0x30df13(_0x286b50,{'message':{'type':'error','requestId':_0x286b50,'runId':_0x3902e7[_0x1cee6a(0x20f)],'error':{'message':_0x1e55c3?.[_0x1cee6a(0x283)]??String(_0x1e55c3),'code':_0x1e55c3?.['code']??_0x1cee6a(0x25a)},'meta':{'runnerId':_0x1cee6a(0x2ac)+process[_0x1cee6a(0x20a)]}},'logs':[]});})[_0x2eef95(0x27a)](()=>_0x48053d['delete'](_0x286b50));};_0x4afc6e={'name':'fn','cost':_0x55f329(0x1d3),'inFlight':()=>_0x94eec6[_0x55f329(0x225)](),async 'tick'(){const _0x1c9875=_0x55f329;if(_0x3e9c98)return;for(const _0x2eec94 of[..._0x48053d]){const _0x18b740=_0x554414[_0x1c9875(0x23b)](_0x2eec94);if(!_0x18b740||_0x18b740[_0x1c9875(0x1b4)]===_0x1c9875(0x1e0))_0x94eec6[_0x1c9875(0x1fc)](_0x2eec94);}for(const {key:_0x430aa6,value:_0x1ec4bc}of _0x554414[_0x1c9875(0x1ab)]({})){if(_0x3e9c98)break;if(_0x94eec6[_0x1c9875(0x225)]()>=_0x94eec6[_0x1c9875(0x213)])break;if(!_0x1ec4bc||_0x1ec4bc['state']!==_0x1c9875(0x193))continue;if(_0x1ec4bc[_0x1c9875(0x2b4)]&&Date['now']()-_0x1ec4bc[_0x1c9875(0x2b4)]>_0x3efdfd){try{_0x554414['transactionSync'](()=>{const _0x488210=_0x1c9875,_0x1b20fe=_0x554414[_0x488210(0x23b)](_0x430aa6);if(_0x1b20fe?.[_0x488210(0x1b4)]==='pending'&&_0x1b20fe[_0x488210(0x2b4)]&&Date[_0x488210(0x247)]()-_0x1b20fe[_0x488210(0x2b4)]>_0x3efdfd)_0x554414[_0x488210(0x198)](_0x430aa6);});}catch{}continue;}let _0xbe859d=![];_0x554414[_0x1c9875(0x19e)](()=>{const _0x2b2b85=_0x1c9875,_0x435736=_0x554414[_0x2b2b85(0x23b)](_0x430aa6);_0x435736?.[_0x2b2b85(0x1b4)]==='pending'&&(_0x554414[_0x2b2b85(0x274)](_0x430aa6,{..._0x435736,'state':_0x2b2b85(0x28c),'claimedBy':process[_0x2b2b85(0x20a)],'claimedAt':Date['now']()}),_0xbe859d=!![]);});if(!_0xbe859d)continue;_0xd78ba0(_0x430aa6,_0x1ec4bc);}}};}let _0x3a39ca=0x0;const _0x73b1eb=_0x167555[_0x55f329(0x189)][_0x55f329(0x221)](_0x55f329(0x23a),{'dupSort':![]}),_0x223a2a={'name':'bootstrap','cost':'heavy','inFlight':()=>_0x3a39ca,async 'tick'(){const _0xfea844=_0x55f329;if(_0x3e9c98||_0x3a39ca>=0x1)return;const _0x585288=[];try{for(const {key:_0x1ab1de,value:_0x22a249}of _0x73b1eb[_0xfea844(0x1ab)]({})){if(typeof _0x1ab1de===_0xfea844(0x2a5)&&_0x22a249?.[_0xfea844(0x2b3)]&&!_0x22a249[_0xfea844(0x2b3)]['startsWith']('~'))_0x585288['push'](_0x22a249);}}catch{}for(const _0x40a84c of _0x585288){if(_0x3e9c98||_0x3a39ca>=0x1)return;let _0x16b9c9;try{_0x16b9c9=await _0x3c9051(_0x40a84c['env']);}catch{continue;}if(_0x40a84c['kind']===_0xfea844(0x1a8)&&_0x40a84c[_0xfea844(0x226)]){const _0x34ce60=_0x16b9c9['get']?.(_0xfea844(0x29f),_0x40a84c[_0xfea844(0x226)]);if(!_0x34ce60)continue;let _0x2bf69b=![];_0x403685['add'](_0x40a84c[_0xfea844(0x2b3)]);const _0x4803de=_0x16b9c9[_0xfea844(0x21a)][_0xfea844(0x1c3)]({'rowKey':'bootstrap:'+_0x40a84c['cursorKey'],'cursorKey':_0x40a84c[_0xfea844(0x1b2)]},async()=>{const _0x4c7126=_0xfea844;!_0x16b9c9[_0x4c7126(0x22a)][_0x4c7126(0x286)][_0x4c7126(0x1d4)](_0x40a84c[_0x4c7126(0x226)])&&_0x16b9c9[_0x4c7126(0x22a)]['_activateViewStorage'](_0x40a84c['viewName'],_0x34ce60),await _0x16b9c9['views'][_0x4c7126(0x199)](_0x40a84c[_0x4c7126(0x226)],_0x34ce60);},{'onClaimed':()=>{_0x2bf69b=!![],_0x3a39ca++;}})[_0xfea844(0x252)](()=>{})[_0xfea844(0x27a)](()=>{const _0x13d807=_0xfea844;if(_0x2bf69b)_0x3a39ca--;_0x403685[_0x13d807(0x27e)](_0x40a84c[_0x13d807(0x2b3)]);});if(_0x2bf69b)return;await _0x4803de;continue;}try{await _0x167555[_0xfea844(0x265)]['process']({'envs':[_0x40a84c['env']],'types':_0x40a84c[_0xfea844(0x1ed)]?[_0x40a84c['type']]:'*'});}catch{continue;}let _0x2333a5=[];try{_0x2333a5=_0x16b9c9[_0xfea844(0x21a)]['listWorkerBootstrapJobs']();}catch{}for(const _0xba152c of _0x2333a5){if(_0x3e9c98||_0x3a39ca>=0x1)return;let _0x4895f6=![];_0x403685['add'](_0x40a84c[_0xfea844(0x2b3)]);const _0x2fb4aa=_0x16b9c9[_0xfea844(0x21a)][_0xfea844(0x228)](_0xba152c,{'onClaimed':()=>{_0x4895f6=!![],_0x3a39ca++;}})['catch'](()=>{})[_0xfea844(0x27a)](()=>{const _0x771d48=_0xfea844;if(_0x4895f6)_0x3a39ca--;_0x403685['delete'](_0x40a84c[_0x771d48(0x2b3)]);});if(_0x4895f6)return;await _0x2fb4aa;}}}},_0x476855=Math[_0x55f329(0x270)](0x1,Number(process.env.OKDB_WORKERS_PROBE_PER_TICK)||0x2),_0x584e9b=Math[_0x55f329(0x270)](0x1,Number(process.env.OKDB_WORKERS_PROBE_GRACE_TICKS)||0x3);let _0x29031=Math['floor'](Math[_0x55f329(0x2af)]()*0x1000);const _0x50a762=new Set(),_0x3d7808=new Map(),_0x2ac78d=Math['max'](0x3e8,Number(process.env.OKDB_WORKERS_PROBE_COOLDOWN_MS)||0x7530),_0x17b345=new Map(),_0x4c458a={'name':_0x55f329(0x265),'cost':'light','inFlight':()=>{let _0x371735=0x0;for(const [,_0x4662c3]of _0x5787bb)if(_0x2570e2(_0x4662c3))_0x371735++;return _0x371735;},async 'tick'(){const _0x2b8dca=_0x55f329;if(_0x3e9c98)return;const _0x20a37c=_0x167555[_0x2b8dca(0x265)]['listFtsEnvs']();if(_0x20a37c['length']===0x0)return;const _0x590d09=new Map();for(const _0x152827 of _0x20a37c){if(!_0x590d09[_0x2b8dca(0x1d4)](_0x152827['env']))_0x590d09[_0x2b8dca(0x1be)](_0x152827['env'],[]);_0x590d09[_0x2b8dca(0x23b)](_0x152827['env'])['push'](_0x152827[_0x2b8dca(0x1ed)]);}const _0x2e3e5b=[..._0x590d09['keys']()],_0x213292=Date[_0x2b8dca(0x247)](),_0x19b3d0=[];for(const _0x59e433 of _0x50a762){_0x590d09[_0x2b8dca(0x1d4)](_0x59e433)&&!_0x19b3d0[_0x2b8dca(0x19d)](_0x59e433)&&(_0x17b345[_0x2b8dca(0x27e)](_0x59e433),_0x19b3d0[_0x2b8dca(0x284)](_0x59e433));}_0x50a762[_0x2b8dca(0x1da)]();for(let _0x3a27a3=0x0;_0x19b3d0['length']<_0x476855&&_0x3a27a3<_0x2e3e5b['length'];_0x3a27a3++){const _0x2ff9b0=_0x2e3e5b[(_0x29031+_0x3a27a3)%_0x2e3e5b[_0x2b8dca(0x23e)]];if(_0x19b3d0[_0x2b8dca(0x19d)](_0x2ff9b0))continue;if((_0x17b345[_0x2b8dca(0x23b)](_0x2ff9b0)??0x0)>_0x213292)continue;_0x19b3d0[_0x2b8dca(0x284)](_0x2ff9b0);}_0x29031=(_0x29031+_0x476855)%Math[_0x2b8dca(0x270)](0x1,_0x2e3e5b[_0x2b8dca(0x23e)]);for(const _0x251aef of _0x19b3d0){if(_0x3e9c98)return;try{await _0x3c9051(_0x251aef),await _0x167555['fts'][_0x2b8dca(0x28e)]({'envs':[_0x251aef],'types':_0x590d09[_0x2b8dca(0x23b)](_0x251aef)});}catch{}}for(const [_0x507d42,_0x4f14d9]of[..._0x5787bb]){if(_0x197315(_0x507d42,_0x4f14d9)){_0x3d7808[_0x2b8dca(0x27e)](_0x507d42);continue;}const _0x29f2cf=(_0x3d7808[_0x2b8dca(0x23b)](_0x507d42)??0x0)+0x1;_0x29f2cf>=_0x584e9b?(_0x3d7808['delete'](_0x507d42),_0x17b345['set'](_0x507d42,Date[_0x2b8dca(0x247)]()+_0x2ac78d),await _0x11b83b(_0x507d42)):_0x3d7808[_0x2b8dca(0x1be)](_0x507d42,_0x29f2cf);}}};_0x167555[_0x55f329(0x22c)]['on'](_0x2e5d86[_0x55f329(0x278)],_0x53ffd8=>{const _0x29d2c4=_0x55f329,_0x3f12de=_0x53ffd8?.[_0x29d2c4(0x2b3)];if(typeof _0x3f12de===_0x29d2c4(0x2a5)&&_0x3f12de&&!_0x3f12de[_0x29d2c4(0x22d)]('~'))_0x50a762[_0x29d2c4(0x2b7)](_0x3f12de);});const _0x4b9a98=Math[_0x55f329(0x270)](0x64,Number(process.env.OKDB_WORKERS_CLAIM_TICK_MS)||0x3e8),_0x4c3c8f=[_0x4afc6e,_0x29990d,_0x223a2a,_0x4c458a],_0x45c69d=[_0x29990d,_0x223a2a,_0x4c458a];let _0x13f7f2=0x0;const _0x41f70b=_0x147e50=>{const _0x32fdc9=_0x55f329;if(_0x3e9c98||_0x1c225e[_0x32fdc9(0x241)](_0x147e50[_0x32fdc9(0x27f)]))return;_0x147e50[_0x32fdc9(0x1bf)]()[_0x32fdc9(0x252)](()=>{});},_0x2a64d7=setInterval(()=>{const _0x1b76af=_0x55f329;_0x41f70b(_0x4afc6e);for(let _0x222613=0x0;_0x222613<_0x45c69d[_0x1b76af(0x23e)];_0x222613++){_0x41f70b(_0x45c69d[(_0x13f7f2+_0x222613)%_0x45c69d[_0x1b76af(0x23e)]]);}_0x13f7f2=(_0x13f7f2+0x1)%_0x45c69d[_0x1b76af(0x23e)];},_0x4b9a98);if(typeof _0x2a64d7['unref']===_0x55f329(0x233))_0x2a64d7[_0x55f329(0x2b6)]();_0x167555[_0x55f329(0x22c)]['on'](_0x2e5d86[_0x55f329(0x204)],_0x3c82ea=>{const _0x22e0e3=_0x55f329;if(_0x3c82ea?.[_0x22e0e3(0x255)]==='fn')_0x41f70b(_0x4afc6e);else{if(_0x3c82ea?.[_0x22e0e3(0x255)]===_0x22e0e3(0x24b))_0x41f70b(_0x223a2a);else{if(_0x3c82ea?.[_0x22e0e3(0x255)]===_0x22e0e3(0x217))_0x41f70b(_0x29990d);else{if(_0x3c82ea?.[_0x22e0e3(0x255)]===_0x22e0e3(0x264)&&typeof _0x3c82ea[_0x22e0e3(0x215)]===_0x22e0e3(0x2a5)){const _0x5d28f2=_0x3c82ea[_0x22e0e3(0x215)];_0x34a535({'type':'warn','msg':_0x22e0e3(0x1db)+_0x5d28f2+_0x22e0e3(0x263)+_0x5787bb['has'](_0x5d28f2)+')'}),(async()=>{const _0x5a3ce0=_0x22e0e3;for(const [_0x545092,_0x4029a7]of[..._0x411e51]){if(_0x4029a7?.[_0x5a3ce0(0x1a5)]!==_0x5d28f2)continue;_0x411e51[_0x5a3ce0(0x27e)](_0x545092);try{await _0x4029a7[_0x5a3ce0(0x23f)]?.[_0x5a3ce0(0x1d6)]?.();}catch{}}_0x403685[_0x5a3ce0(0x27e)](_0x5d28f2),_0x50a762[_0x5a3ce0(0x27e)](_0x5d28f2),_0x17b345[_0x5a3ce0(0x1be)](_0x5d28f2,Date[_0x5a3ce0(0x247)]()+0x1d4c0),await _0x11b83b(_0x5d28f2),_0x34a535({'type':_0x5a3ce0(0x212),'msg':'env-removed:\x20'+_0x5d28f2+_0x5a3ce0(0x248)});})()['catch'](_0x29553f=>{const _0x209cbe=_0x22e0e3;_0x34a535({'type':_0x209cbe(0x212),'msg':_0x209cbe(0x2a1)+_0x5d28f2+':\x20'+_0x29553f?.['message']});});}}}}});for(const _0x44c68d of _0x4c3c8f)_0x41f70b(_0x44c68d);_0x453185(_0x34a535,_0x167555,()=>({'claims':_0x4c3c8f[_0x55f329(0x1a6)](_0x1acfd1=>({'name':_0x1acfd1[_0x55f329(0x28b)],'inFlight':_0x1acfd1[_0x55f329(0x291)](),'gated':_0x1c225e[_0x55f329(0x241)](_0x1acfd1[_0x55f329(0x27f)]),..._0x1acfd1[_0x55f329(0x1cc)]?{'detail':_0x1acfd1[_0x55f329(0x1cc)]()}:{}})),'envsOpen':_0x167555[_0x55f329(0x234)]['size']})),_0x34a535({'type':_0x55f329(0x1c6),'pid':process[_0x55f329(0x20a)],'slot':_0x2d9485,'supervisorKey':_0x5f96e2,'maxLeases':_0x224253});}return _0x13d282()[_0x328e3b(0x252)](_0x3f43b6=>{const _0x197eb8=_0x328e3b;_0x34a535({'type':_0x197eb8(0x2a4),'error':_0x3f43b6[_0x197eb8(0x283)]}),process[_0x197eb8(0x2b0)](0x1);}),okdbWorkerChild$1;}var okdbWorkerChildExports=requireOkdbWorkerChild(),okdbWorkerChild=getDefaultExportFromCjs(okdbWorkerChildExports);module[_0x275d88(0x1f2)]=okdbWorkerChild;
@@ -1 +0,0 @@
1
- export default{tag:"system-workers-panel",context:e=>({s:null,busy:!1,actionBusy:null,error:null,_timer:null,async load(){this.busy=!0;try{const e=await fetch(`${__ENV__.API}/workers`);if(e.ok){const s=await e.json();this.s=s.data??s.result??null,this.error=null}}catch{}finally{this.busy=!1}},async _action(s,t,a){if(!this.actionBusy){this.actionBusy=s;try{const s=await fetch(`${__ENV__.API}/workers/scale`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scale:t})}),o=await s.json().catch(()=>({}));if(!s.ok||o?.error)throw new Error(o?.error?.message||o?.error||`HTTP ${s.status}`);e.$ok?.shared?.toast?.success?.(a),await this.load()}catch(s){e.$ok?.shared?.toast?.error?.(s?.message||"scale failed")}finally{this.actionBusy=null}}},setAuto(){return this._action("auto","auto","workers set to auto (elastic)")},async setFixed(){const s=e.$ok?.shared?.prompt?await e.$ok.shared.prompt("Fixed worker count (pins min = max):",String(this.s?.live??1)):window.prompt("Fixed worker count (pins min = max):",String(this.s?.live??1));if(null==s)return;const t=Number(s);if(Number.isFinite(t)&&!(t<0))return this._action("fixed",{min:t,max:t},`workers pinned to ${t}`);e.$ok?.shared?.toast?.error?.("enter a non-negative number")},async setOff(){const s="Turn workers OFF (scale 0)? Background work falls back to this instance self-processing.";if(e.$ok?.shared?.confirm?await e.$ok.shared.confirm(s):window.confirm(s))return this._action("off",0,"workers turned off")},scaleLabel(){const e=this.s;return e?0===e.scale?"off":"auto"===e.scale?"auto":e.scale&&"object"==typeof e.scale?null!=e.scale.max?`fixed ${e.scale.min}–${e.scale.max}`:`min ${e.scale.min}`:String(e.scale):"—"},capLabel(){const e=this.s;return e&&null!=e.cap?`cap ${e.cap} · ${e.capReason}`:"uncapped"},gaugePct:(e,s)=>!s||s<=0?e>0?100:0:Math.min(100,Math.round(e/s*100)),gaugeColor:(e,s)=>e?e>=s?"var(--okdb-danger)":"var(--okdb-warning)":"var(--okdb-success)",whyColor(){const e=this.s?.why||"";return e.startsWith("at cap")?"var(--okdb-danger)":e.startsWith("scaling")?"var(--okdb-warning)":"var(--okdb-app-fg-muted)"},btnDisabled(e){return null!=this.actionBusy},btnLabel(e,s){return this.actionBusy===e?"⏳":s},lastScaleLabel(){const e=this.s?.lastScale;return e?`${"up"===e.dir?"▲ up":"▼ down"} to ${e.to} — ${e.reason}`:"none this session"},get signals(){if(!this.s)return[];const e=this.s.backlog||{},s=this.s.thresholds||{};return[{label:"unprocessed changes",value:e.totalLag??0,threshold:s.lagHigh??0,title:"Changelog entries not yet processed by derived-state processors (FTS / views / materializer / etc.), summed across envs."},{label:"queue (ready)",value:e.pendingJobs??0,threshold:s.queueHigh??0,title:"Queue jobs a fleet worker can claim RIGHT NOW: status pending, DUE (scheduled `when` ≤ now), and of a type with a registered queue.worker() runner. Excluded (so the count means what it says): future-scheduled jobs, and types served by a custom user runner or an HTTP handler — a fleet worker never claims those, so they must not drive scaling."},{label:"fn dispatch",value:e.fnPending??0,threshold:s.fnHigh??0,title:"Pending WORKER-DISPATCHED function requests (the durable ~fn:requests queue) awaiting a fleet worker. This is NOT every function call: in-process and HTTP-handler invocations run where they are called and never enter this queue, so they are not counted here. An unexpected non-zero on an idle system suggests orphaned rows from a caller that exited before any worker claimed (these are now reaped after OKDB_FN_STALE_MS)."},{label:"index / FTS builds",value:e.bootstrapPending??0,threshold:1,title:"Pending routed bootstrap (index / FTS) build jobs awaiting a worker."}]},signalNote:e=>0===e.value?"idle":e.threshold>1?`scales up above ${e.threshold}`:"scales up while > 0"}),init(e){this.load(),this._timer=setInterval(()=>this.load(),3e3),this._timer.unref&&this._timer.unref()},unmount(){this._timer&&clearInterval(this._timer),this._timer=null},template:'\n <div style="display:flex;flex-direction:column;gap:16px;">\n\n <div style="display:flex;align-items:center;gap:10px;font-size:12px;color:var(--okdb-method-default);">\n <span>The elastic worker population under this root — backlog-driven, capped, shared by all instances.</span>\n <button @click="load()" :disabled="busy" style="margin-left:auto;font-size:11px;padding:2px 8px;background:var(--okdb-app-bg-2);border:1px solid var(--okdb-app-border);border-radius:4px;cursor:pointer;color:var(--okdb-app-fg);">Refresh</button>\n </div>\n\n <if :="!s">\n <div style="font-size:12px;color:var(--okdb-app-fg-subtle);padding:8px 0;">Loading worker status…</div>\n </if>\n\n <if :="s">\n \x3c!-- Population: ACTUAL (live now) vs DESIRED (the persisted root-wide setting) --\x3e\n <div style="display:flex;align-items:baseline;gap:14px;padding:14px 16px;background:var(--okdb-app-bg-2);border:1px solid var(--okdb-app-border);border-radius:8px;">\n <span style="font-size:30px;font-weight:600;color:var(--okdb-app-fg-strong);">{{ s.live }}</span>\n <span style="font-size:12px;color:var(--okdb-app-fg-subtle);">live now</span>\n <span style="font-size:12px;color:var(--okdb-app-fg-subtle);">·&nbsp; desired</span>\n <span style="font-size:11px;padding:3px 9px;border-radius:5px;background:var(--okdb-app-bg);color:var(--okdb-accent);font-family:monospace;">{{ scaleLabel() }}</span>\n <span style="font-size:11px;padding:3px 9px;border-radius:5px;background:var(--okdb-app-bg);color:var(--okdb-app-fg-muted);font-family:monospace;">{{ capLabel() }}</span>\n <if :="s.supervisor && s.supervisor.isSelf"><span title="This instance currently holds the per-root supervisor lease and reconciles the population." style="font-size:10px;padding:2px 7px;border-radius:4px;background:var(--okdb-app-bg);color:var(--okdb-success);">supervisor</span></if>\n <span :title="s.source === \'operator\' ? \'Set from the admin UI/API — takes precedence over instances re-asserting their boot config.\' : \'Set by an instance at boot (workers.ensure). An operator change here would take precedence.\'" style="font-size:10px;padding:2px 7px;border-radius:4px;background:var(--okdb-app-bg);color:var(--okdb-app-fg-subtle);margin-left:auto;">{{ s.source === \'operator\' ? \'set by operator\' : \'from config\' }}</span>\n </div>\n\n \x3c!-- The setting is ONE persisted, root-wide record — not a per-instance toggle. --\x3e\n <div style="font-size:11px;color:var(--okdb-app-fg-subtle);line-height:1.5;padding:0 2px;">\n <strong>Desired</strong> is a single <strong>persisted, root-wide</strong> setting (durable in <code>~system</code>, keyed by the root path): every instance sharing this database shares <strong>one</strong> worker pool, reconciled by the <strong>elected supervisor</strong>. Changing it below overwrites that one setting for the whole deployment (last write wins) — instances don\'t run competing pools; they converge on this value. <strong>Actual</strong> catches up to desired as the supervisor forks/retires children.\n </div>\n\n \x3c!-- WHY this many — the headline operator answer --\x3e\n <div :style="\'font-size:13px;padding:10px 14px;border-left:3px solid \' + whyColor() + \';background:var(--okdb-app-bg-2);border-radius:0 6px 6px 0;\'">\n <span style="opacity:.6;font-size:11px;text-transform:uppercase;letter-spacing:.5px;">Why this many</span><br/>\n <span :style="\'color:\' + whyColor() + \';\'">{{ s.why }}</span>\n </div>\n\n \x3c!-- Backlog signals that drive scale-up. The number is PENDING WORK; the threshold\n is the LINE above which the scaler adds a worker — not a capacity/utilization. --\x3e\n <div style="font-size:12px;">\n <div style="color:var(--okdb-app-fg-subtle);margin-bottom:6px;">Pending work <span style="opacity:.6;">(hover a row for what it counts; the scaler adds a worker when any rises above its line)</span></div>\n <div style="display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:10px;">\n <each :of="signals" let:item="sig">\n <div :title="sig.title">\n <div style="display:flex;justify-content:space-between;align-items:baseline;">\n <span>{{ sig.label }}</span>\n <span :style="\'font-weight:600;color:\' + gaugeColor(sig.value, sig.threshold) + \';\'">{{ sig.value }}</span>\n </div>\n <div style="height:5px;background:var(--okdb-app-bg);border-radius:3px;margin-top:3px;overflow:hidden;"><div :style="\'height:100%;width:\' + gaugePct(sig.value, sig.threshold) + \'%;background:\' + gaugeColor(sig.value, sig.threshold) + \';\'"></div></div>\n <div style="font-size:10px;opacity:.55;margin-top:2px;">{{ signalNote(sig) }}</div>\n </div>\n </each>\n </div>\n </div>\n\n \x3c!-- Last scale event --\x3e\n <div style="font-size:12px;color:var(--okdb-app-fg-subtle);">\n Last scale event: <span style="color:var(--okdb-app-fg);">{{ lastScaleLabel() }}</span>\n <if :="s.scaling && s.scaling.awaitingOnline"><span style="color:var(--okdb-warning);"> · waiting for the last worker to come online</span></if>\n </div>\n\n \x3c!-- Controls --\x3e\n <div style="display:flex;align-items:center;gap:8px;padding-top:6px;border-top:1px solid var(--okdb-app-border);">\n <span style="font-size:11px;color:var(--okdb-app-fg-subtle);margin-right:4px;">Scale:</span>\n <button @click="setAuto()" :disabled="btnDisabled(\'auto\')" style="font-size:11px;padding:4px 12px;background:var(--okdb-app-bg-2);border:1px solid var(--okdb-app-border);border-radius:4px;cursor:pointer;color:var(--okdb-app-fg);">{{ btnLabel(\'auto\', \'Auto\') }}</button>\n <button @click="setFixed()" :disabled="btnDisabled(\'fixed\')" style="font-size:11px;padding:4px 12px;background:var(--okdb-app-bg-2);border:1px solid var(--okdb-app-border);border-radius:4px;cursor:pointer;color:var(--okdb-app-fg);">{{ btnLabel(\'fixed\', \'Fixed…\') }}</button>\n <button @click="setOff()" :disabled="btnDisabled(\'off\')" style="font-size:11px;padding:4px 12px;background:var(--okdb-app-bg-2);border:1px solid var(--okdb-danger);border-radius:4px;cursor:pointer;color:var(--okdb-danger);">{{ btnLabel(\'off\', \'Off\') }}</button>\n </div>\n </if>\n </div>\n '};