alvin-bot 5.6.2 → 5.8.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/CHANGELOG.md +29 -0
- package/README.md +1 -1
- package/dist/claude.js +1 -102
- package/dist/config.js +1 -96
- package/dist/engine.js +1 -90
- package/dist/find-claude-binary.js +1 -98
- package/dist/handlers/async-agent-chunk-handler.js +1 -50
- package/dist/handlers/background-bypass.js +1 -75
- package/dist/handlers/commands.js +1 -2336
- package/dist/handlers/cron-progress.js +1 -52
- package/dist/handlers/document.js +1 -194
- package/dist/handlers/message.js +1 -959
- package/dist/handlers/photo.js +1 -154
- package/dist/handlers/platform-message.js +1 -360
- package/dist/handlers/stuck-timer.js +1 -54
- package/dist/handlers/video.js +1 -237
- package/dist/handlers/voice.js +1 -148
- package/dist/i18n.js +1 -805
- package/dist/index.js +1 -697
- package/dist/init-data-dir.js +1 -98
- package/dist/middleware/auth.js +1 -233
- package/dist/migrate.js +1 -162
- package/dist/paths.js +1 -146
- package/dist/platforms/discord.js +1 -175
- package/dist/platforms/index.js +1 -130
- package/dist/platforms/signal.js +1 -205
- package/dist/platforms/slack-slash-parser.js +1 -32
- package/dist/platforms/slack.js +1 -501
- package/dist/platforms/telegram.js +1 -111
- package/dist/platforms/types.js +1 -8
- package/dist/platforms/whatsapp-auth-helpers.js +1 -53
- package/dist/platforms/whatsapp.js +1 -707
- package/dist/providers/claude-sdk-provider.js +1 -565
- package/dist/providers/codex-cli-provider.js +1 -134
- package/dist/providers/index.js +1 -7
- package/dist/providers/ollama-provider.js +1 -32
- package/dist/providers/openai-compatible.js +1 -406
- package/dist/providers/registry.js +1 -352
- package/dist/providers/runtime-header.js +1 -45
- package/dist/providers/tool-executor.js +1 -475
- package/dist/providers/types.js +1 -227
- package/dist/services/access.js +1 -144
- package/dist/services/allowed-users-gate.js +1 -56
- package/dist/services/alvin-dispatch.js +1 -130
- package/dist/services/alvin-mcp-tools.js +1 -104
- package/dist/services/asset-index.js +1 -224
- package/dist/services/async-agent-parser.js +1 -418
- package/dist/services/async-agent-watcher.js +1 -443
- package/dist/services/auto-diagnostic.js +1 -228
- package/dist/services/broadcast.js +1 -52
- package/dist/services/browser-manager.js +1 -562
- package/dist/services/browser-webfetch.js +1 -127
- package/dist/services/browser.js +1 -121
- package/dist/services/cdp-bootstrap.js +1 -357
- package/dist/services/compaction.js +1 -144
- package/dist/services/critical-notify.js +1 -203
- package/dist/services/cron-resolver.js +1 -58
- package/dist/services/cron-scheduling.js +1 -310
- package/dist/services/cron.js +1 -861
- package/dist/services/custom-tools.js +1 -317
- package/dist/services/delivery-queue.js +1 -173
- package/dist/services/delivery-registry.js +1 -21
- package/dist/services/disk-cleanup.js +1 -203
- package/dist/services/elevenlabs.js +1 -58
- package/dist/services/embeddings/auto-detect.js +1 -74
- package/dist/services/embeddings/fts5.js +1 -108
- package/dist/services/embeddings/gemini.js +1 -65
- package/dist/services/embeddings/index.js +1 -496
- package/dist/services/embeddings/ollama.js +1 -78
- package/dist/services/embeddings/openai.js +1 -49
- package/dist/services/embeddings/provider.js +1 -22
- package/dist/services/embeddings/vector-base.js +1 -113
- package/dist/services/embeddings-migration.js +1 -193
- package/dist/services/embeddings.js +1 -9
- package/dist/services/env-file.js +1 -50
- package/dist/services/exec-guard.js +1 -71
- package/dist/services/fallback-order.js +1 -154
- package/dist/services/file-permissions.js +1 -93
- package/dist/services/heartbeat-file.js +1 -65
- package/dist/services/heartbeat.js +1 -313
- package/dist/services/hooks.js +1 -44
- package/dist/services/imagegen.js +1 -72
- package/dist/services/language-detect.js +1 -154
- package/dist/services/markdown.js +1 -63
- package/dist/services/mcp.js +1 -263
- package/dist/services/memory-extractor.js +1 -178
- package/dist/services/memory-inject-mode.js +1 -43
- package/dist/services/memory-layers.js +1 -156
- package/dist/services/memory.js +1 -146
- package/dist/services/ollama-manager.js +1 -339
- package/dist/services/permissions-wizard.js +1 -291
- package/dist/services/personality.js +1 -376
- package/dist/services/plugins.js +1 -171
- package/dist/services/preflight.js +1 -292
- package/dist/services/process-manager.js +1 -291
- package/dist/services/release-highlights.js +1 -79
- package/dist/services/reminders.js +1 -97
- package/dist/services/restart.js +1 -48
- package/dist/services/security-audit.js +1 -74
- package/dist/services/self-diagnosis.js +1 -272
- package/dist/services/self-search.js +1 -129
- package/dist/services/session-persistence.js +1 -237
- package/dist/services/session.js +1 -282
- package/dist/services/skills.js +1 -290
- package/dist/services/ssrf-guard.js +1 -162
- package/dist/services/standing-orders.js +1 -29
- package/dist/services/steer-channel.js +1 -46
- package/dist/services/stop-controller.js +1 -52
- package/dist/services/subagent-dedup.js +1 -0
- package/dist/services/subagent-delivery.js +1 -452
- package/dist/services/subagent-stats.js +1 -123
- package/dist/services/subagents.js +1 -814
- package/dist/services/sudo.js +1 -329
- package/dist/services/telegram.js +1 -158
- package/dist/services/timing-safe-bearer.js +1 -51
- package/dist/services/tool-discovery.js +1 -214
- package/dist/services/trends.js +1 -580
- package/dist/services/updater.js +1 -291
- package/dist/services/usage-tracker.js +1 -144
- package/dist/services/users.js +1 -271
- package/dist/services/voice.js +1 -104
- package/dist/services/watchdog-brake.js +1 -154
- package/dist/services/watchdog.js +1 -311
- package/dist/services/workspaces.js +1 -276
- package/dist/tui/index.js +1 -667
- package/dist/util/console-formatter.js +1 -109
- package/dist/util/debounce.js +1 -24
- package/dist/util/telegram-error-filter.js +1 -62
- package/dist/version.js +1 -24
- package/dist/web/bind-strategy.js +1 -42
- package/dist/web/canvas.js +1 -30
- package/dist/web/doctor-api.js +1 -604
- package/dist/web/openai-compat.js +1 -252
- package/dist/web/server.js +1 -1831
- package/dist/web/setup-api.js +1 -1101
- package/package.json +5 -2
- package/dist/.metadata_never_index +0 -0
package/dist/services/plugins.js
CHANGED
|
@@ -1,171 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Plugin System — Drop-in extensible capabilities.
|
|
3
|
-
*
|
|
4
|
-
* Plugins are loaded from the `plugins/` directory.
|
|
5
|
-
* Each plugin is a directory with an `index.js` (or `index.ts` compiled) file
|
|
6
|
-
* that exports a PluginDefinition.
|
|
7
|
-
*
|
|
8
|
-
* Plugin structure:
|
|
9
|
-
* plugins/
|
|
10
|
-
* weather/
|
|
11
|
-
* index.js — Plugin entry (exports PluginDefinition)
|
|
12
|
-
* package.json — Optional: dependencies
|
|
13
|
-
* finance/
|
|
14
|
-
* index.js
|
|
15
|
-
*
|
|
16
|
-
* Plugin API:
|
|
17
|
-
* - name: unique identifier
|
|
18
|
-
* - description: what the plugin does
|
|
19
|
-
* - version: semver
|
|
20
|
-
* - commands: Telegram commands the plugin registers
|
|
21
|
-
* - tools: Functions the AI can call
|
|
22
|
-
* - onMessage: Optional hook for every message
|
|
23
|
-
* - onInit/onDestroy: Lifecycle hooks
|
|
24
|
-
*/
|
|
25
|
-
import fs from "fs";
|
|
26
|
-
import { resolve } from "path";
|
|
27
|
-
import { PLUGINS_DIR } from "../paths.js";
|
|
28
|
-
// ── Plugin Registry ─────────────────────────────────────
|
|
29
|
-
const loadedPlugins = new Map();
|
|
30
|
-
/**
|
|
31
|
-
* Load all plugins from the plugins/ directory.
|
|
32
|
-
*/
|
|
33
|
-
export async function loadPlugins() {
|
|
34
|
-
const loaded = [];
|
|
35
|
-
const errors = [];
|
|
36
|
-
if (!fs.existsSync(PLUGINS_DIR)) {
|
|
37
|
-
fs.mkdirSync(PLUGINS_DIR, { recursive: true });
|
|
38
|
-
return { loaded, errors };
|
|
39
|
-
}
|
|
40
|
-
const entries = fs.readdirSync(PLUGINS_DIR, { withFileTypes: true });
|
|
41
|
-
for (const entry of entries) {
|
|
42
|
-
if (!entry.isDirectory())
|
|
43
|
-
continue;
|
|
44
|
-
if (entry.name.startsWith(".") || entry.name.startsWith("_"))
|
|
45
|
-
continue;
|
|
46
|
-
const pluginDir = resolve(PLUGINS_DIR, entry.name);
|
|
47
|
-
const indexFile = resolve(pluginDir, "index.js");
|
|
48
|
-
if (!fs.existsSync(indexFile)) {
|
|
49
|
-
errors.push({ name: entry.name, error: "Missing index.js" });
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
// Dynamic import
|
|
54
|
-
const module = await import(`file://${indexFile}`);
|
|
55
|
-
const definition = module.default || module;
|
|
56
|
-
if (!definition.name) {
|
|
57
|
-
errors.push({ name: entry.name, error: "Plugin has no name" });
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
// Run init hook
|
|
61
|
-
if (definition.onInit) {
|
|
62
|
-
await definition.onInit();
|
|
63
|
-
}
|
|
64
|
-
loadedPlugins.set(definition.name, definition);
|
|
65
|
-
loaded.push(definition.name);
|
|
66
|
-
console.log(`✅ Plugin loaded: ${definition.name} v${definition.version}`);
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
70
|
-
errors.push({ name: entry.name, error: msg });
|
|
71
|
-
console.error(`❌ Plugin failed: ${entry.name} — ${msg}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return { loaded, errors };
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Register all plugin commands with the bot.
|
|
78
|
-
*/
|
|
79
|
-
export function registerPluginCommands(bot) {
|
|
80
|
-
for (const [, plugin] of loadedPlugins) {
|
|
81
|
-
if (!plugin.commands)
|
|
82
|
-
continue;
|
|
83
|
-
for (const cmd of plugin.commands) {
|
|
84
|
-
bot.command(cmd.command, async (ctx) => {
|
|
85
|
-
const args = ctx.match?.toString().trim() || "";
|
|
86
|
-
await cmd.handler(ctx, args);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Run plugin message hooks.
|
|
93
|
-
* Returns true if any plugin handled the message (stops propagation).
|
|
94
|
-
*/
|
|
95
|
-
export async function runPluginMessageHooks(ctx, text) {
|
|
96
|
-
for (const [, plugin] of loadedPlugins) {
|
|
97
|
-
if (plugin.onMessage) {
|
|
98
|
-
try {
|
|
99
|
-
const handled = await plugin.onMessage(ctx, text);
|
|
100
|
-
if (handled === true)
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
console.error(`Plugin ${plugin.name} onMessage error:`, err);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Get all registered plugin tools (for AI function calling).
|
|
112
|
-
*/
|
|
113
|
-
export function getPluginTools() {
|
|
114
|
-
const tools = [];
|
|
115
|
-
for (const [, plugin] of loadedPlugins) {
|
|
116
|
-
if (plugin.tools) {
|
|
117
|
-
tools.push(...plugin.tools);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return tools;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Execute a plugin tool by name.
|
|
124
|
-
*/
|
|
125
|
-
export async function executePluginTool(name, params) {
|
|
126
|
-
for (const [, plugin] of loadedPlugins) {
|
|
127
|
-
const tool = plugin.tools?.find(t => t.name === name);
|
|
128
|
-
if (tool) {
|
|
129
|
-
return tool.execute(params);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
throw new Error(`Plugin tool "${name}" not found`);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Get loaded plugin info for /plugins command.
|
|
136
|
-
*/
|
|
137
|
-
export function getLoadedPlugins() {
|
|
138
|
-
const result = [];
|
|
139
|
-
for (const [, plugin] of loadedPlugins) {
|
|
140
|
-
result.push({
|
|
141
|
-
name: plugin.name,
|
|
142
|
-
description: plugin.description,
|
|
143
|
-
version: plugin.version,
|
|
144
|
-
commands: plugin.commands?.map(c => `/${c.command}`) || [],
|
|
145
|
-
tools: plugin.tools?.map(t => t.name) || [],
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
return result;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Unload all plugins (for graceful shutdown).
|
|
152
|
-
*/
|
|
153
|
-
export async function unloadPlugins() {
|
|
154
|
-
for (const [name, plugin] of loadedPlugins) {
|
|
155
|
-
try {
|
|
156
|
-
if (plugin.onDestroy)
|
|
157
|
-
await plugin.onDestroy();
|
|
158
|
-
console.log(`Plugin unloaded: ${name}`);
|
|
159
|
-
}
|
|
160
|
-
catch (err) {
|
|
161
|
-
console.error(`Plugin ${name} destroy error:`, err);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
loadedPlugins.clear();
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Get the plugins directory path (for documentation).
|
|
168
|
-
*/
|
|
169
|
-
export function getPluginsDir() {
|
|
170
|
-
return PLUGINS_DIR;
|
|
171
|
-
}
|
|
1
|
+
(function(_0x326c76,_0x3916ee){const _0x3a389f=_0x446a,_0x4242df=_0x446a,_0x45b9df=_0x326c76();while(!![]){try{const _0xb90305=-parseInt(_0x3a389f(0x11e))/(0x1*-0x769+0x1*-0x1d21+0x248b)+-parseInt(_0x4242df(0x124))/(-0x75c+-0x1715*-0x1+-0x53d*0x3)*(-parseInt(_0x4242df(0x114))/(-0x446+0x45c*0x4+-0xd27))+-parseInt(_0x3a389f(0x12a))/(0x17b1+-0x5b*-0x3+-0xc5f*0x2)*(-parseInt(_0x4242df(0x109))/(0x182+0x1a17+-0x1b94))+-parseInt(_0x3a389f(0x11d))/(0xf2f*-0x1+0x8*0x1c+0xe55)+parseInt(_0x3a389f(0x11b))/(0x49e+-0x249c+0x1*0x2005)*(-parseInt(_0x3a389f(0x11c))/(-0x22d7+0xedf+0x1400))+parseInt(_0x4242df(0x110))/(-0x12c8+-0x6c6+0x1997)*(-parseInt(_0x4242df(0x12f))/(-0x17b1+-0x1d58+0x3513))+-parseInt(_0x4242df(0x10f))/(-0x761*0x1+-0x27*0x39+0x101b)*(-parseInt(_0x3a389f(0xfe))/(-0x654+0x2091+0x1*-0x1a31));if(_0xb90305===_0x3916ee)break;else _0x45b9df['push'](_0x45b9df['shift']());}catch(_0x451549){_0x45b9df['push'](_0x45b9df['shift']());}}}(_0x19e9,-0x1e249+-0x52553+0x1d*0x5c77));const _0x4e0cd2=(function(){let _0x3ffa58=!![];return function(_0x19ee20,_0x309703){const _0x19d354=_0x3ffa58?function(){const _0x3124da=_0x446a;if(_0x309703){const _0x2d7510=_0x309703[_0x3124da(0x113)](_0x19ee20,arguments);return _0x309703=null,_0x2d7510;}}:function(){};return _0x3ffa58=![],_0x19d354;};}()),_0x55d1e9=_0x4e0cd2(this,function(){const _0x3d57ec=_0x446a,_0x13e5bd=_0x446a;return _0x55d1e9[_0x3d57ec(0x108)]()[_0x13e5bd(0x127)](_0x13e5bd(0x105)+'+$')['toString']()[_0x3d57ec(0x100)+'r'](_0x55d1e9)[_0x3d57ec(0x127)](_0x13e5bd(0x105)+'+$');});_0x55d1e9();import _0x45ec30 from'fs';import{resolve}from'path';function _0x446a(_0x4bdbb3,_0x255626){_0x4bdbb3=_0x4bdbb3-(0x4db*0x4+-0xb*-0x16+-0x3*0x676);const _0x347355=_0x19e9();let _0x332779=_0x347355[_0x4bdbb3];if(_0x446a['YVsiVJ']===undefined){var _0x3d3fa9=function(_0x774d2d){const _0x43889d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5a27fe='',_0x6309c0='',_0x4c9a44=_0x5a27fe+_0x3d3fa9;for(let _0x30fcf6=-0x7f*0x25+0xe*-0x293+0x3665,_0x117073,_0x53f60b,_0x6b9434=-0x11d4+0xbd+0x7*0x271;_0x53f60b=_0x774d2d['charAt'](_0x6b9434++);~_0x53f60b&&(_0x117073=_0x30fcf6%(-0x10c3*-0x1+0x14fb+0x25ba*-0x1)?_0x117073*(-0x1725+0xa0d*0x1+0xd58)+_0x53f60b:_0x53f60b,_0x30fcf6++%(0x40f*0x1+-0x1b3a*-0x1+-0x1f45))?_0x5a27fe+=_0x4c9a44['charCodeAt'](_0x6b9434+(-0x4d*-0x62+-0x1f16+-0x2*-0xd3))-(0x118d*0x2+0x229b+-0x45ab)!==-0x1*0x74b+0x175d+-0x1012?String['fromCharCode'](-0x938+-0x1036*-0x2+-0x1635&_0x117073>>(-(0x1*0xcf1+-0x1*-0x1981+-0x334*0xc)*_0x30fcf6&0xe01+-0x13b*0xf+0x47a)):_0x30fcf6:-0x1492+-0xb5*0x17+0x24d5){_0x53f60b=_0x43889d['indexOf'](_0x53f60b);}for(let _0x50659b=0x59f+0xc80*-0x3+0x1*0x1fe1,_0x16ed77=_0x5a27fe['length'];_0x50659b<_0x16ed77;_0x50659b++){_0x6309c0+='%'+('00'+_0x5a27fe['charCodeAt'](_0x50659b)['toString'](0x1b6*-0x13+0x2655+-0x5c3*0x1))['slice'](-(0x16de+-0x20e0+0xa04));}return decodeURIComponent(_0x6309c0);};_0x446a['RIjdGq']=_0x3d3fa9,_0x446a['PqIOJz']={},_0x446a['YVsiVJ']=!![];}const _0x7b3a32=_0x347355[-0x31c*0xb+0x12a+0x210a],_0x2a7882=_0x4bdbb3+_0x7b3a32,_0x44f8cc=_0x446a['PqIOJz'][_0x2a7882];if(!_0x44f8cc){const _0x31874b=function(_0x4f880a){this['VxUHXL']=_0x4f880a,this['JPHGlH']=[-0x920+0x806+0x11b,-0x233b+-0xe5*-0x9+0x1b2e,-0x18b+-0x1032+0x11bd],this['qNSzpD']=function(){return'newState';},this['WrGRAe']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['GTKARM']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x31874b['prototype']['LAtQgM']=function(){const _0x27fa30=new RegExp(this['WrGRAe']+this['GTKARM']),_0x287066=_0x27fa30['test'](this['qNSzpD']['toString']())?--this['JPHGlH'][-0x106f*0x2+-0x2*-0xadb+0xb29]:--this['JPHGlH'][-0x2370+0x11d8+0x1*0x1198];return this['spkBAe'](_0x287066);},_0x31874b['prototype']['spkBAe']=function(_0xde9988){if(!Boolean(~_0xde9988))return _0xde9988;return this['MWJGft'](this['VxUHXL']);},_0x31874b['prototype']['MWJGft']=function(_0x1d277f){for(let _0x30c1fc=-0x5*0x5bf+-0x333+0x1fee,_0x513f47=this['JPHGlH']['length'];_0x30c1fc<_0x513f47;_0x30c1fc++){this['JPHGlH']['push'](Math['round'](Math['random']())),_0x513f47=this['JPHGlH']['length'];}return _0x1d277f(this['JPHGlH'][0x1*0x491+0x14b+-0x5dc]);},new _0x31874b(_0x446a)['LAtQgM'](),_0x332779=_0x446a['RIjdGq'](_0x332779),_0x446a['PqIOJz'][_0x2a7882]=_0x332779;}else _0x332779=_0x44f8cc;return _0x332779;}import{PLUGINS_DIR}from'../paths.js';const loadedPlugins=new Map();export async function loadPlugins(){const _0x1ba0c7=_0x446a,_0x308c82=_0x446a,_0x40b433=[],_0x3c605c=[];if(!_0x45ec30[_0x1ba0c7(0x107)](PLUGINS_DIR))return _0x45ec30[_0x1ba0c7(0x10e)](PLUGINS_DIR,{'recursive':!![]}),{'loaded':_0x40b433,'errors':_0x3c605c};const _0x4425ba=_0x45ec30[_0x1ba0c7(0x121)+'c'](PLUGINS_DIR,{'withFileTypes':!![]});for(const _0x494bd0 of _0x4425ba){if(!_0x494bd0[_0x1ba0c7(0x10d)+'y']())continue;if(_0x494bd0[_0x308c82(0x12b)][_0x308c82(0x104)]('.')||_0x494bd0['name'][_0x308c82(0x104)]('_'))continue;const _0x50699c=resolve(PLUGINS_DIR,_0x494bd0['name']),_0x3b965c=resolve(_0x50699c,_0x308c82(0x112));if(!_0x45ec30[_0x308c82(0x107)](_0x3b965c)){_0x3c605c[_0x1ba0c7(0x10b)]({'name':_0x494bd0['name'],'error':'Missing\x20in'+_0x1ba0c7(0x11a)});continue;}try{const _0x749436=await import(_0x1ba0c7(0x111)+_0x3b965c),_0x372bbc=_0x749436['default']||_0x749436;if(!_0x372bbc['name']){_0x3c605c[_0x1ba0c7(0x10b)]({'name':_0x494bd0[_0x308c82(0x12b)],'error':'Plugin\x20has'+'\x20no\x20name'});continue;}_0x372bbc[_0x1ba0c7(0x12e)]&&await _0x372bbc[_0x308c82(0x12e)](),loadedPlugins['set'](_0x372bbc['name'],_0x372bbc),_0x40b433[_0x308c82(0x10b)](_0x372bbc['name']),console['log']('✅\x20Plugin\x20l'+_0x1ba0c7(0x118)+_0x372bbc['name']+'\x20v'+_0x372bbc['version']);}catch(_0x5daffb){const _0x1370d4=_0x5daffb instanceof Error?_0x5daffb['message']:String(_0x5daffb);_0x3c605c[_0x1ba0c7(0x10b)]({'name':_0x494bd0[_0x308c82(0x12b)],'error':_0x1370d4}),console[_0x1ba0c7(0x115)](_0x308c82(0x120)+_0x308c82(0x12c)+_0x494bd0['name']+_0x308c82(0x125)+_0x1370d4);}}return{'loaded':_0x40b433,'errors':_0x3c605c};}export function registerPluginCommands(_0x3bf44d){const _0x3c6814=_0x446a,_0x1fe17d=_0x446a;for(const [,_0x27e85f]of loadedPlugins){if(!_0x27e85f[_0x3c6814(0x126)])continue;for(const _0x5b06f7 of _0x27e85f[_0x1fe17d(0x126)]){_0x3bf44d[_0x3c6814(0xff)](_0x5b06f7[_0x3c6814(0xff)],async _0x545ab8=>{const _0xbb73c6=_0x3c6814,_0x4c6b41=_0x3c6814,_0x2f9b5e=_0x545ab8[_0xbb73c6(0x123)]?.['toString']()[_0xbb73c6(0x10c)]()||'';await _0x5b06f7[_0x4c6b41(0xfc)](_0x545ab8,_0x2f9b5e);});}}}export async function runPluginMessageHooks(_0x34a44b,_0x50eb79){const _0x24b6b2=_0x446a,_0x3cef46=_0x446a;for(const [,_0x38f638]of loadedPlugins){if(_0x38f638[_0x24b6b2(0x11f)])try{const _0x4f23f5=await _0x38f638['onMessage'](_0x34a44b,_0x50eb79);if(_0x4f23f5===!![])return!![];}catch(_0x50abe7){console[_0x24b6b2(0x115)](_0x3cef46(0xfd)+_0x38f638['name']+(_0x3cef46(0x128)+'\x20error:'),_0x50abe7);}}return![];}export function getPluginTools(){const _0x2e6bac=_0x446a,_0x48b86f=_0x446a,_0x1f4d5=[];for(const [,_0x2a63b9]of loadedPlugins){_0x2a63b9[_0x2e6bac(0x101)]&&_0x1f4d5[_0x2e6bac(0x10b)](..._0x2a63b9['tools']);}return _0x1f4d5;}export async function executePluginTool(_0x53a9bd,_0x9bfb00){const _0x36b601=_0x446a,_0x4749a3=_0x446a;for(const [,_0x353aa6]of loadedPlugins){const _0x1913e3=_0x353aa6['tools']?.['find'](_0x1693fc=>_0x1693fc[_0x36b601(0x12b)]===_0x53a9bd);if(_0x1913e3)return _0x1913e3[_0x4749a3(0x10a)](_0x9bfb00);}throw new Error(_0x36b601(0x106)+_0x4749a3(0x122)+_0x53a9bd+(_0x4749a3(0x12d)+'d'));}export function getLoadedPlugins(){const _0x2fd2eb=_0x446a,_0x36ee42=_0x446a,_0x3fa087=[];for(const [,_0x1d5233]of loadedPlugins){_0x3fa087[_0x2fd2eb(0x10b)]({'name':_0x1d5233[_0x36ee42(0x12b)],'description':_0x1d5233[_0x2fd2eb(0x103)+'n'],'version':_0x1d5233[_0x36ee42(0x119)],'commands':_0x1d5233[_0x36ee42(0x126)]?.[_0x36ee42(0x129)](_0x5a885e=>'/'+_0x5a885e[_0x2fd2eb(0xff)])||[],'tools':_0x1d5233[_0x36ee42(0x101)]?.[_0x36ee42(0x129)](_0x59ec50=>_0x59ec50['name'])||[]});}return _0x3fa087;}export async function unloadPlugins(){const _0x340703=_0x446a,_0x45778c=_0x446a;for(const [_0x354d01,_0x4f36b0]of loadedPlugins){try{if(_0x4f36b0[_0x340703(0x117)])await _0x4f36b0[_0x340703(0x117)]();console[_0x45778c(0x116)]('Plugin\x20unl'+_0x45778c(0x118)+_0x354d01);}catch(_0x184197){console['error'](_0x45778c(0xfd)+_0x354d01+('\x20destroy\x20e'+_0x340703(0x102)),_0x184197);}}loadedPlugins['clear']();}function _0x19e9(){const _0x47cbe1=['AxneAxjLy3rVCG','BwTKAxjtEw5J','nZD2CwnmANq','mtHTAxLWy3O','zMLSztOVlW','Aw5KzxGUANm','yxbWBhK','mZC4BgPeyMjb','zxjYB3i','Bg9N','B25ezxn0CM95','B2fKzwq6ia','DMvYC2LVBG','zgv4lMPZ','ntiWnJGXz2PTDezW','ogT6y0z3ra','mte0nZGYnhzUDwrbsW','odqYotHkzKPUz08','B25nzxnZywDL','4P2mifbSDwDPBIbM','CMvHzgrPCLn5BG','BcaI','Bwf0y2G','ndi4nMzLBxbPuW','iokaLca','y29TBwfUzhm','C2vHCMnO','ig9UtwvZC2fNzq','BwfW','mti3nJCWmfLyrwvAvq','BMfTzq','ywLSzwq6ia','iIbUB3qGzM91BG','B25jBML0','mtq4mZG3mgrLt0nNqG','AgfUzgXLCG','ugX1z2LUia','ndG1nZaWvKjNEe1Y','y29TBwfUza','y29UC3rYDwn0BW','Dg9VBhm','CNjVCJO','zgvZy3jPChrPBW','C3rHCNrZv2L0Aa','kcGOlISPkYKRkq','ugX1z2LUihrVBW','zxHPC3rZu3LUyW','Dg9tDhjPBMC','nvnYu2nqzq','zxHLy3v0zq','ChvZAa','DhjPBq'];_0x19e9=function(){return _0x47cbe1;};return _0x19e9();}export function getPluginsDir(){return PLUGINS_DIR;}
|
|
@@ -1,292 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pre-Flight Sanity Check (Self-Preservation Phase 1, feature 1A).
|
|
3
|
-
*
|
|
4
|
-
* Runs in PARALLEL at startup, fire-and-forget: never blocks the bot's main
|
|
5
|
-
* startup sequence. Each check has a tight timeout. Results are logged with
|
|
6
|
-
* a severity classification (ok / warn / critical). Critical findings can
|
|
7
|
-
* optionally feed into the cross-channel notify pipeline (1D).
|
|
8
|
-
*
|
|
9
|
-
* Provider-agnostic: AI-provider check is routed through the active
|
|
10
|
-
* Provider's `isAvailable()` method, which every concrete provider
|
|
11
|
-
* implements — so the same check works for claude-sdk, codex-cli,
|
|
12
|
-
* groq, gemini, openai, openrouter, ollama (gemma), nvidia.
|
|
13
|
-
*
|
|
14
|
-
* Opt-out:
|
|
15
|
-
* ALVIN_DISABLE_PREFLIGHT=true → skip Pre-Flight specifically
|
|
16
|
-
* ALVIN_DISABLE_SELF_PRESERVATION=true → skip ALL Phase-1 features
|
|
17
|
-
*
|
|
18
|
-
* Performance budget (measured on Apple Silicon M-series):
|
|
19
|
-
* - Telegram getMe: typical 150-400ms, timeout 3000ms
|
|
20
|
-
* - AI Provider isAvailable: typical 50-800ms, timeout 5000ms
|
|
21
|
-
* - SQLite PRAGMA quick_check: typical 5-50ms, timeout 10000ms
|
|
22
|
-
* - df disk space: typical 5-15ms, timeout 2000ms
|
|
23
|
-
* - Total wall-clock = max of all four (Promise.all) — typically <1s
|
|
24
|
-
*/
|
|
25
|
-
import { existsSync } from "fs";
|
|
26
|
-
import { join } from "path";
|
|
27
|
-
import { homedir } from "os";
|
|
28
|
-
function isDisabled() {
|
|
29
|
-
return (process.env.ALVIN_DISABLE_PREFLIGHT === "true" ||
|
|
30
|
-
process.env.ALVIN_DISABLE_SELF_PRESERVATION === "true");
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Run a promise with a wall-clock timeout. Returns `fallback` if the
|
|
34
|
-
* promise doesn't settle in time. Never rejects.
|
|
35
|
-
*/
|
|
36
|
-
function withTimeout(promise, ms, fallback) {
|
|
37
|
-
return new Promise((resolve) => {
|
|
38
|
-
let settled = false;
|
|
39
|
-
const timer = setTimeout(() => {
|
|
40
|
-
if (!settled) {
|
|
41
|
-
settled = true;
|
|
42
|
-
resolve(fallback);
|
|
43
|
-
}
|
|
44
|
-
}, ms);
|
|
45
|
-
promise.then((value) => {
|
|
46
|
-
if (!settled) {
|
|
47
|
-
settled = true;
|
|
48
|
-
clearTimeout(timer);
|
|
49
|
-
resolve(value);
|
|
50
|
-
}
|
|
51
|
-
}, () => {
|
|
52
|
-
if (!settled) {
|
|
53
|
-
settled = true;
|
|
54
|
-
clearTimeout(timer);
|
|
55
|
-
resolve(fallback);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
async function checkTelegram(botToken) {
|
|
61
|
-
const start = Date.now();
|
|
62
|
-
if (!botToken) {
|
|
63
|
-
return {
|
|
64
|
-
name: "telegram",
|
|
65
|
-
ok: true,
|
|
66
|
-
severity: "ok",
|
|
67
|
-
message: "skipped (WebUI-only mode, no BOT_TOKEN)",
|
|
68
|
-
durationMs: Date.now() - start,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const url = `https://api.telegram.org/bot${botToken}/getMe`;
|
|
72
|
-
const result = await withTimeout(fetch(url).then(async (r) => ({ ok: r.ok, status: r.status, body: await r.json().catch(() => null) })), 3000, null);
|
|
73
|
-
if (!result) {
|
|
74
|
-
return {
|
|
75
|
-
name: "telegram",
|
|
76
|
-
ok: false,
|
|
77
|
-
severity: "warn",
|
|
78
|
-
message: "getMe timed out (3s) — bot may have network / Telegram issues",
|
|
79
|
-
durationMs: Date.now() - start,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
if (!result.ok) {
|
|
83
|
-
return {
|
|
84
|
-
name: "telegram",
|
|
85
|
-
ok: false,
|
|
86
|
-
severity: "critical",
|
|
87
|
-
message: `getMe HTTP ${result.status} — token may be invalid`,
|
|
88
|
-
durationMs: Date.now() - start,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
const username = result.body?.result?.username;
|
|
92
|
-
return {
|
|
93
|
-
name: "telegram",
|
|
94
|
-
ok: true,
|
|
95
|
-
severity: "ok",
|
|
96
|
-
message: username ? `bot=@${username}` : "bot reachable",
|
|
97
|
-
durationMs: Date.now() - start,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
async function checkAiProvider(registry) {
|
|
101
|
-
const start = Date.now();
|
|
102
|
-
if (!registry) {
|
|
103
|
-
return {
|
|
104
|
-
name: "ai-provider",
|
|
105
|
-
ok: false,
|
|
106
|
-
severity: "warn",
|
|
107
|
-
message: "no provider configured (AI features will be disabled)",
|
|
108
|
-
durationMs: Date.now() - start,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
let provider;
|
|
112
|
-
let activeKey = "(unknown)";
|
|
113
|
-
try {
|
|
114
|
-
provider = registry.getActive();
|
|
115
|
-
activeKey = registry.getActiveKey();
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
return {
|
|
119
|
-
name: "ai-provider",
|
|
120
|
-
ok: false,
|
|
121
|
-
severity: "warn",
|
|
122
|
-
message: "no active provider in registry",
|
|
123
|
-
durationMs: Date.now() - start,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
if (!provider) {
|
|
127
|
-
return {
|
|
128
|
-
name: "ai-provider",
|
|
129
|
-
ok: false,
|
|
130
|
-
severity: "warn",
|
|
131
|
-
message: "no active provider in registry",
|
|
132
|
-
durationMs: Date.now() - start,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
const available = await withTimeout(provider.isAvailable(), 5000, false);
|
|
136
|
-
return {
|
|
137
|
-
name: "ai-provider",
|
|
138
|
-
ok: available,
|
|
139
|
-
severity: available ? "ok" : "warn",
|
|
140
|
-
message: available
|
|
141
|
-
? `${activeKey} reachable`
|
|
142
|
-
: `${activeKey} not reachable / not configured — bot will degrade gracefully on AI calls`,
|
|
143
|
-
durationMs: Date.now() - start,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
async function checkSqliteIntegrity() {
|
|
147
|
-
const start = Date.now();
|
|
148
|
-
const dbPath = join(homedir(), ".alvin-bot", "memory", ".embeddings.db");
|
|
149
|
-
if (!existsSync(dbPath)) {
|
|
150
|
-
return {
|
|
151
|
-
name: "sqlite",
|
|
152
|
-
ok: true,
|
|
153
|
-
severity: "ok",
|
|
154
|
-
message: "embeddings DB not yet created (lazily on first use)",
|
|
155
|
-
durationMs: Date.now() - start,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
const { createRequire } = await import("module");
|
|
160
|
-
const req = createRequire(import.meta.url);
|
|
161
|
-
const Database = req("better-sqlite3");
|
|
162
|
-
const db = new Database(dbPath, { readonly: true });
|
|
163
|
-
// PRAGMA quick_check is materially faster than integrity_check
|
|
164
|
-
// (catches the same classes of corruption but doesn't verify every
|
|
165
|
-
// page). For our purpose — "is the file readable + structurally
|
|
166
|
-
// sane?" — quick_check is the right tool.
|
|
167
|
-
const result = await withTimeout(Promise.resolve(db.prepare("PRAGMA quick_check").get()), 10_000, null);
|
|
168
|
-
db.close();
|
|
169
|
-
if (result === null) {
|
|
170
|
-
return {
|
|
171
|
-
name: "sqlite",
|
|
172
|
-
ok: false,
|
|
173
|
-
severity: "warn",
|
|
174
|
-
message: "PRAGMA quick_check timed out (>10s) — DB may be very large or locked",
|
|
175
|
-
durationMs: Date.now() - start,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
const r = result;
|
|
179
|
-
const checkResult = r.quick_check || "(unknown)";
|
|
180
|
-
const ok = checkResult === "ok";
|
|
181
|
-
return {
|
|
182
|
-
name: "sqlite",
|
|
183
|
-
ok,
|
|
184
|
-
severity: ok ? "ok" : "critical",
|
|
185
|
-
message: ok ? "embeddings DB integrity ok" : `embeddings DB integrity FAILED: ${checkResult}`,
|
|
186
|
-
durationMs: Date.now() - start,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
catch (err) {
|
|
190
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
191
|
-
return {
|
|
192
|
-
name: "sqlite",
|
|
193
|
-
ok: true,
|
|
194
|
-
severity: "ok",
|
|
195
|
-
message: `check skipped: ${message.split("\n")[0]}`,
|
|
196
|
-
durationMs: Date.now() - start,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
async function checkDiskSpace() {
|
|
201
|
-
const start = Date.now();
|
|
202
|
-
try {
|
|
203
|
-
const { execSync } = await import("child_process");
|
|
204
|
-
const dataDir = join(homedir(), ".alvin-bot");
|
|
205
|
-
const out = execSync(`df -k "${dataDir}"`, { encoding: "utf-8", timeout: 2000 });
|
|
206
|
-
const lines = out.trim().split("\n");
|
|
207
|
-
const data = lines[lines.length - 1].split(/\s+/);
|
|
208
|
-
// df output: Filesystem 1024-blocks Used Available Capacity ...
|
|
209
|
-
const availableKB = parseInt(data[3], 10);
|
|
210
|
-
if (!Number.isFinite(availableKB)) {
|
|
211
|
-
return {
|
|
212
|
-
name: "disk",
|
|
213
|
-
ok: true,
|
|
214
|
-
severity: "ok",
|
|
215
|
-
message: "could not parse df output",
|
|
216
|
-
durationMs: Date.now() - start,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
const availableGB = availableKB / 1024 / 1024;
|
|
220
|
-
const severity = availableKB < 512 * 1024 ? "critical" :
|
|
221
|
-
availableKB < 1024 * 1024 ? "warn" :
|
|
222
|
-
"ok";
|
|
223
|
-
return {
|
|
224
|
-
name: "disk",
|
|
225
|
-
ok: severity === "ok",
|
|
226
|
-
severity,
|
|
227
|
-
message: `${availableGB.toFixed(2)} GB free`,
|
|
228
|
-
durationMs: Date.now() - start,
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
catch (err) {
|
|
232
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
233
|
-
return {
|
|
234
|
-
name: "disk",
|
|
235
|
-
ok: true,
|
|
236
|
-
severity: "ok",
|
|
237
|
-
message: `check skipped: ${message.split("\n")[0]}`,
|
|
238
|
-
durationMs: Date.now() - start,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Run the full pre-flight suite in parallel. Always resolves (never
|
|
244
|
-
* throws). Returns a structured report so the caller can decide how
|
|
245
|
-
* to react.
|
|
246
|
-
*/
|
|
247
|
-
export async function runPreFlight(botToken, registry) {
|
|
248
|
-
if (isDisabled()) {
|
|
249
|
-
return {
|
|
250
|
-
results: [],
|
|
251
|
-
slowestMs: 0,
|
|
252
|
-
totalMs: 0,
|
|
253
|
-
anyCritical: false,
|
|
254
|
-
anyWarning: false,
|
|
255
|
-
skipped: true,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
const start = Date.now();
|
|
259
|
-
const results = await Promise.all([
|
|
260
|
-
checkTelegram(botToken),
|
|
261
|
-
checkAiProvider(registry),
|
|
262
|
-
checkSqliteIntegrity(),
|
|
263
|
-
checkDiskSpace(),
|
|
264
|
-
]);
|
|
265
|
-
return {
|
|
266
|
-
results,
|
|
267
|
-
slowestMs: Math.max(...results.map((r) => r.durationMs)),
|
|
268
|
-
totalMs: Date.now() - start,
|
|
269
|
-
anyCritical: results.some((r) => r.severity === "critical"),
|
|
270
|
-
anyWarning: results.some((r) => r.severity === "warn"),
|
|
271
|
-
skipped: false,
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Format a PreFlightReport for console output. Compact, single line per
|
|
276
|
-
* check, clear severity icons.
|
|
277
|
-
*/
|
|
278
|
-
export function formatPreFlightReport(report) {
|
|
279
|
-
if (report.skipped) {
|
|
280
|
-
return "🩺 Pre-Flight: skipped (ALVIN_DISABLE_PREFLIGHT=true)";
|
|
281
|
-
}
|
|
282
|
-
const icons = { ok: "✓", warn: "⚠", critical: "❌" };
|
|
283
|
-
const headline = report.anyCritical
|
|
284
|
-
? "❌ Pre-Flight: critical issues"
|
|
285
|
-
: report.anyWarning
|
|
286
|
-
? "⚠️ Pre-Flight: warnings"
|
|
287
|
-
: "✅ Pre-Flight: all checks ok";
|
|
288
|
-
const lines = report.results.map((r) => {
|
|
289
|
-
return ` ${icons[r.severity]} ${r.name.padEnd(12)} ${r.message} (${r.durationMs}ms)`;
|
|
290
|
-
});
|
|
291
|
-
return `🩺 ${headline} — ${report.totalMs}ms total\n${lines.join("\n")}`;
|
|
292
|
-
}
|
|
1
|
+
(function(_0x33f19d,_0x474d0e){const _0xcfd7b7=_0x342f,_0x2c07f5=_0x342f,_0x41d764=_0x33f19d();while(!![]){try{const _0xd3bc27=parseInt(_0xcfd7b7(0x1b8))/(-0x1*0xd81+-0x6d9*0x1+0x9*0x243)*(-parseInt(_0x2c07f5(0x225))/(0x23fa+-0x1*0x6f7+-0x1d01))+parseInt(_0x2c07f5(0x1c7))/(0x121*-0x20+0x41f+0x2ab*0xc)*(-parseInt(_0xcfd7b7(0x1b2))/(0x633*0x3+-0x176f+0x4da))+parseInt(_0xcfd7b7(0x1d5))/(0x1*-0x121f+0xae9+0x73b)+parseInt(_0x2c07f5(0x1df))/(0x91c+-0x7*-0x1da+-0x160c)*(parseInt(_0xcfd7b7(0x201))/(0x5*0x89+-0x15*0xcb+0xe01))+-parseInt(_0xcfd7b7(0x219))/(-0xf94+0x1d4a+-0xdae)*(parseInt(_0x2c07f5(0x218))/(-0x1*0x202c+-0x2027+0xc*0x55d))+-parseInt(_0x2c07f5(0x1e2))/(0x1a1a+0x28f*-0xe+0x2*0x4e1)*(-parseInt(_0x2c07f5(0x21e))/(-0x208b+0x9e1+0x16b5))+parseInt(_0xcfd7b7(0x205))/(0x124+-0x1*-0x19e2+-0x6*0x47f)*(parseInt(_0x2c07f5(0x22b))/(-0x298*0xf+-0x1*-0xdcc+0x1929));if(_0xd3bc27===_0x474d0e)break;else _0x41d764['push'](_0x41d764['shift']());}catch(_0x4d7c0d){_0x41d764['push'](_0x41d764['shift']());}}}(_0x5ac2,-0x1871*-0x1b+-0x3df82+0x3f810));const _0xd3fa08=(function(){let _0x23d656=!![];return function(_0x83a5d3,_0x3571f0){const _0x59700c=_0x23d656?function(){const _0x5ac643=_0x342f;if(_0x3571f0){const _0x3f4e74=_0x3571f0[_0x5ac643(0x220)](_0x83a5d3,arguments);return _0x3571f0=null,_0x3f4e74;}}:function(){};return _0x23d656=![],_0x59700c;};}()),_0x5f09ef=_0xd3fa08(this,function(){const _0x41ae0c=_0x342f,_0x10733e=_0x342f;return _0x5f09ef['toString']()[_0x41ae0c(0x1f1)](_0x41ae0c(0x209)+'+$')[_0x41ae0c(0x20a)]()[_0x10733e(0x1fb)+'r'](_0x5f09ef)['search'](_0x41ae0c(0x209)+'+$');});_0x5f09ef();import{existsSync}from'fs';function _0x5ac2(){const _0x3cd143=['CgfKrw5K','yMv0DgvYlxnXBa','DxrMltG','BM8Gywn0AxzLia','y3jPDgLJywW','C2TPChbLza','ignVBMzPz3vYzq','lMfSDMLUlwjVDa','ChjLCgfYzq','icaG','DgvSzwDYyw0','zcaOquXwsu5Fra','z3jHBsbPC3n1zq','t1rFve9lru4P','ndmXnZLrtKPzzxa','zcbVDxqGkdnZkq','Ahr0Chm6lY9HCa','C29Tzq','lMvTyMvKzgLUzW','iercigLUDgvNCG','DgHLBG','Bw9KzsWGBM8GqG','ChjVDMLKzxiGAq','z2v0qwn0AxzLsW','kgXHEMLSEsbVBG','yMXL','DxrWDxq','CY5KyG','nZm0mJvOwNbfuMu','BM93','ywKTChjVDMLKzq','Axr5iezbsuXfra','C3bSAxq','y291BgqGBM90ia','AxnbDMfPBgfIBa','ufjbr01bihf1Aq','yw55v2fYBMLUzW','CgfYC2uGzgyGBW','mZq2nte4r1PlDLnc','l2DLDe1L','CgvKoIa','nZiZnZKWrfLltvDX','yM9KEq','Dg9gAxHLza','BxmP','yxKGyMuGAw52yq','Dhj1zq','BwvTB3j5','khvUA25VD24P','yM90ihjLywnOyq','BwfW','DhjPBq','zwnRCYbVAW','zw1IzwrKAw5NCW','ywjSzsaVig5VDa','C2TPChbLzcaOvW','C2vHCMnO','zw52','B3jRic8GvgvSzq','CMvZB2X2zq','y2HLy2SGC2TPCa','C3fSAxrL','8j+PUIbqCMuTrMXPzW','Aw1LzcbVDxqGka','AM9PBG','Bw9KDwXL','y29UC3rYDwn0BW','AxngAw5PDgu','AxrLmW','igDYywnLzNvSBa','y2HPBgrFChjVyW','z2v0twuGsfruua','n3jbqxrZta','zhvYyxrPB25nCW','BMDZ','qKXfx1bsruzmsq','nJq0mJa4s09LA0zu','CMvZDwX0','ANnVBG','quXwsu5FreLtqq','kcGOlISPkYKRkq','Dg9tDhjPBMC','DcbJCMvHDgvKia','zgLZAW','zcdIGjqGyM90ihDP','ieDcigzYzwu','ig1HEsbIzsb2zq','4P2mifbYzs1gBgLN','DhvYzxmGD2LSBa','As50zwXLz3jHBq','BMfTzq','Dg90ywXnCW','zgyGlwSGiG','BgXZ','4PYfifbYzs1gBgLN','mJG4ANzNzgzq','nde5ndrqELPMqwm','z2v0','BwvZC2fNzq','C3rHDhvZ','CMvZDwX0CW','mJjzvhzgBK8','D2fYBG','yxbWBhK','iokaLca','ihjLywnOywjSzq','r0Hu','Ahq6ihnRAxbWzq','mta5mtz5twrmsK4','BgLK','zxnZ','iercig5VDcb5zq','pJeWCYKG4Ocuierc','BM8GChjVDMLKzq','mta0zKrJEwj3','y2TFy2HLy2SGDa','CxvPy2TFy2HLyW','BIbYzwDPC3rYEq','DxnLCM5HBwu','yw55q3jPDgLJyq','z2v0twuGDgLTzq','C2v2zxjPDhK','ngfqu0HbAq','yM90pua','CNKGBgfYz2uGBW','z2v0qwn0AxzL','lM9YzY9IB3q','igHHDMuGBMv0DW','ntn0wenIBgG'];_0x5ac2=function(){return _0x3cd143;};return _0x5ac2();}import{join}from'path';import{homedir}from'os';function isDisabled(){const _0x111312=_0x342f,_0x5f0703=_0x342f;return process['env'][_0x111312(0x208)+_0x111312(0x204)+_0x111312(0x223)]===_0x111312(0x1e7)||process[_0x111312(0x1f2)][_0x111312(0x208)+'BLE_SELF_P'+'RESERVATIO'+'N']===_0x111312(0x1e7);}function withTimeout(_0x4c6d20,_0x23facf,_0xa93459){return new Promise(_0x41f0f1=>{let _0x37d444=![];const _0x2eea99=setTimeout(()=>{!_0x37d444&&(_0x37d444=!![],_0x41f0f1(_0xa93459));},_0x23facf);_0x4c6d20['then'](_0x3065d1=>{!_0x37d444&&(_0x37d444=!![],clearTimeout(_0x2eea99),_0x41f0f1(_0x3065d1));},()=>{!_0x37d444&&(_0x37d444=!![],clearTimeout(_0x2eea99),_0x41f0f1(_0xa93459));});});}async function checkTelegram(_0x3df45d){const _0x14fda4=_0x342f,_0x3ef0da=_0x342f,_0x16cc2c=Date[_0x14fda4(0x1d6)]();if(!_0x3df45d)return{'name':_0x14fda4(0x1c3),'ok':!![],'severity':'ok','message':_0x14fda4(0x1f0)+'ebUI-only\x20'+_0x14fda4(0x1ce)+_0x3ef0da(0x1c6),'durationMs':Date[_0x3ef0da(0x1d6)]()-_0x16cc2c};const _0x28e5a9=_0x14fda4(0x1c9)+_0x3ef0da(0x212)+_0x14fda4(0x1b6)+_0x3df45d+_0x14fda4(0x1e0),_0xb4dc0f=await withTimeout(fetch(_0x28e5a9)[_0x3ef0da(0x1cd)](async _0x5d1b49=>({'ok':_0x5d1b49['ok'],'status':_0x5d1b49['status'],'body':await _0x5d1b49[_0x14fda4(0x207)]()['catch'](()=>null)})),-0x52d+-0xd*-0x30+-0xe75*-0x1,null);if(!_0xb4dc0f)return{'name':'telegram','ok':![],'severity':_0x14fda4(0x21f),'message':_0x14fda4(0x1b0)+_0x3ef0da(0x1c8)+'\x20—\x20bot\x20may'+_0x14fda4(0x1b7)+_0x3ef0da(0x1f3)+_0x3ef0da(0x1c5)+'s','durationMs':Date[_0x14fda4(0x1d6)]()-_0x16cc2c};if(!_0xb4dc0f['ok'])return{'name':_0x14fda4(0x1c3),'ok':![],'severity':_0x14fda4(0x1bd),'message':_0x3ef0da(0x200)+'\x20'+_0xb4dc0f[_0x14fda4(0x21c)]+('\x20—\x20token\x20m'+_0x14fda4(0x1e6)+_0x3ef0da(0x226)),'durationMs':Date[_0x3ef0da(0x1d6)]()-_0x16cc2c};const _0x198970=_0xb4dc0f[_0x14fda4(0x1e3)]?.[_0x14fda4(0x206)]?.[_0x14fda4(0x22f)];return{'name':_0x3ef0da(0x1c3),'ok':!![],'severity':'ok','message':_0x198970?_0x3ef0da(0x1b3)+_0x198970:_0x14fda4(0x1ea)+_0x3ef0da(0x1d2),'durationMs':Date[_0x3ef0da(0x1d6)]()-_0x16cc2c};}async function checkAiProvider(_0x2e463b){const _0x6b6ac1=_0x342f,_0x3aceac=_0x342f,_0x2aefce=Date[_0x6b6ac1(0x1d6)]();if(!_0x2e463b)return{'name':_0x6b6ac1(0x1d7)+'r','ok':![],'severity':_0x3aceac(0x21f),'message':_0x6b6ac1(0x22a)+'r\x20configur'+'ed\x20(AI\x20fea'+_0x3aceac(0x211)+'\x20be\x20disabl'+'ed)','durationMs':Date[_0x6b6ac1(0x1d6)]()-_0x2aefce};let _0x25be4e,_0x181315=_0x6b6ac1(0x1e9);try{_0x25be4e=_0x2e463b[_0x3aceac(0x1b5)](),_0x181315=_0x2e463b[_0x3aceac(0x1d0)+'ey']();}catch{return{'name':_0x6b6ac1(0x1d7)+'r','ok':![],'severity':_0x6b6ac1(0x21f),'message':_0x6b6ac1(0x1bc)+_0x3aceac(0x1cf)+_0x3aceac(0x22e),'durationMs':Date[_0x3aceac(0x1d6)]()-_0x2aefce};}if(!_0x25be4e)return{'name':'ai-provide'+'r','ok':![],'severity':_0x3aceac(0x21f),'message':'no\x20active\x20'+'provider\x20i'+_0x3aceac(0x22e),'durationMs':Date[_0x3aceac(0x1d6)]()-_0x2aefce};const _0x2de7e5=await withTimeout(_0x25be4e[_0x6b6ac1(0x1db)+'e'](),-0x2707+0x8f*0x13+0x2ff2,![]);return{'name':_0x3aceac(0x1d7)+'r','ok':_0x2de7e5,'severity':_0x2de7e5?'ok':_0x3aceac(0x21f),'message':_0x2de7e5?_0x181315+_0x3aceac(0x222):_0x181315+('\x20not\x20reach'+_0x6b6ac1(0x1ef)+_0x3aceac(0x1bf)+_0x3aceac(0x20d)+'ll\x20degrade'+_0x3aceac(0x1fe)+'y\x20on\x20AI\x20ca'+_0x6b6ac1(0x216)),'durationMs':Date[_0x6b6ac1(0x1d6)]()-_0x2aefce};}async function checkSqliteIntegrity(){const _0x5c1a02=_0x342f,_0x3d874d=_0x342f,_0x4b6388=Date[_0x5c1a02(0x1d6)](),_0x2f433e=join(homedir(),_0x3d874d(0x1c0),_0x5c1a02(0x1e8),_0x3d874d(0x1cb)+_0x3d874d(0x1d4));if(!existsSync(_0x2f433e))return{'name':'sqlite','ok':!![],'severity':'ok','message':_0x5c1a02(0x1ee)+_0x5c1a02(0x228)+_0x5c1a02(0x20b)+_0x3d874d(0x1d1)+'\x20first\x20use'+')','durationMs':Date[_0x3d874d(0x1d6)]()-_0x4b6388};try{const {createRequire:_0x305b34}=await import(_0x5c1a02(0x1fa)),_0xb7bfee=_0x305b34(import.meta.url),_0x4853b7=_0xb7bfee(_0x5c1a02(0x1ba)+_0x5c1a02(0x1fd)),_0x1683de=new _0x4853b7(_0x2f433e,{'readonly':!![]}),_0x534fd6=await withTimeout(Promise[_0x5c1a02(0x1f4)](_0x1683de[_0x3d874d(0x1c1)](_0x5c1a02(0x1dc)+'ck_check')[_0x5c1a02(0x21a)]()),-0x22f3+-0x4c5d*0x1+0x18*0x644,null);_0x1683de['close']();if(_0x534fd6===null)return{'name':_0x5c1a02(0x1f6),'ok':![],'severity':_0x3d874d(0x21f),'message':'PRAGMA\x20qui'+_0x3d874d(0x22c)+_0x3d874d(0x1f8)+_0x3d874d(0x229)+_0x3d874d(0x20f)+_0x3d874d(0x1b4)+'r\x20locked','durationMs':Date['now']()-_0x4b6388};const _0x115dfc=_0x534fd6,_0x34121a=_0x115dfc[_0x3d874d(0x22d)+'k']||_0x5c1a02(0x1e9),_0x2fae0d=_0x34121a==='ok';return{'name':_0x5c1a02(0x1f6),'ok':_0x2fae0d,'severity':_0x2fae0d?'ok':'critical','message':_0x2fae0d?_0x5c1a02(0x1ee)+'\x20DB\x20integr'+'ity\x20ok':_0x3d874d(0x1ee)+_0x3d874d(0x1cc)+_0x5c1a02(0x1d8)+':\x20'+_0x34121a,'durationMs':Date['now']()-_0x4b6388};}catch(_0x426860){const _0x1d54ba=_0x426860 instanceof Error?_0x426860[_0x5c1a02(0x21b)]:String(_0x426860);return{'name':_0x3d874d(0x1f6),'ok':!![],'severity':'ok','message':_0x3d874d(0x1f5)+_0x5c1a02(0x1e1)+_0x1d54ba['split']('\x0a')[-0x15*-0x1af+0x1a47+-0x3da2],'durationMs':Date['now']()-_0x4b6388};}}function _0x342f(_0x29b796,_0x3063e9){_0x29b796=_0x29b796-(-0x831+-0x3df*0x2+0x1*0x119f);const _0x1d0da1=_0x5ac2();let _0x56106c=_0x1d0da1[_0x29b796];if(_0x342f['lTbyNb']===undefined){var _0x478b6a=function(_0x16de48){const _0x17272f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x49b2e3='',_0xf03d8='',_0x45a288=_0x49b2e3+_0x478b6a;for(let _0x56856e=-0x63b+0x1cd+-0x1*-0x46e,_0x523a0f,_0xc19b9d,_0x7fadba=-0x52d+-0xd*-0x30+-0x2bd*-0x1;_0xc19b9d=_0x16de48['charAt'](_0x7fadba++);~_0xc19b9d&&(_0x523a0f=_0x56856e%(-0x2707+0x8f*0x13+0x1c6e)?_0x523a0f*(-0x117a+-0x23f*0x11+0xd*0x44d)+_0xc19b9d:_0xc19b9d,_0x56856e++%(-0x15*-0x1af+0x1a47+-0x3d9e))?_0x49b2e3+=_0x45a288['charCodeAt'](_0x7fadba+(0xb92*0x1+-0x1d2*-0xe+0xce*-0x2e))-(-0x1d5d*0x1+0xb*0x191+0xc2c)!==-0x1ce6+0x1*0x202d+-0x347*0x1?String['fromCharCode'](-0x1*-0x1c69+0x10e*0xd+-0x2920&_0x523a0f>>(-(-0x10af*0x1+-0x10*0x1f5+-0x1*-0x3001)*_0x56856e&0x25db+-0x701+-0x1ed4)):_0x56856e:-0xfac+0x19fd*-0x1+0xed*0x2d){_0xc19b9d=_0x17272f['indexOf'](_0xc19b9d);}for(let _0x855230=-0x736*-0x1+-0x18e7+-0x7*-0x287,_0x2dbaf4=_0x49b2e3['length'];_0x855230<_0x2dbaf4;_0x855230++){_0xf03d8+='%'+('00'+_0x49b2e3['charCodeAt'](_0x855230)['toString'](-0xa9d+-0xd9b+0x1848))['slice'](-(0x17f5+0x16fb+-0x2eee*0x1));}return decodeURIComponent(_0xf03d8);};_0x342f['Rcftlq']=_0x478b6a,_0x342f['bLVqIg']={},_0x342f['lTbyNb']=!![];}const _0x178420=_0x1d0da1[0x127*-0x1c+0x1*0x1615+-0x365*-0x3],_0x2d8ff5=_0x29b796+_0x178420,_0x19fb52=_0x342f['bLVqIg'][_0x2d8ff5];if(!_0x19fb52){const _0x31afb8=function(_0x378bb8){this['KDEpdX']=_0x378bb8,this['JSjqzt']=[-0x1089+0x10c8+-0x3e,0x253d*-0x1+0x5d*-0x59+0x4592,-0x1*0x1e68+0x16*0xae+0xf74],this['MvqlSn']=function(){return'newState';},this['bnODQT']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['MLaRep']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x31afb8['prototype']['WHhLyT']=function(){const _0x18dccd=new RegExp(this['bnODQT']+this['MLaRep']),_0x436201=_0x18dccd['test'](this['MvqlSn']['toString']())?--this['JSjqzt'][-0x590+-0xee8*0x2+0x2361]:--this['JSjqzt'][-0x826+-0x1*0x1359+-0x1b7f*-0x1];return this['VdYXvH'](_0x436201);},_0x31afb8['prototype']['VdYXvH']=function(_0x44f094){if(!Boolean(~_0x44f094))return _0x44f094;return this['OIVlue'](this['KDEpdX']);},_0x31afb8['prototype']['OIVlue']=function(_0x403c63){for(let _0x35acbf=-0x98*-0x22+-0x1*0x14a0+-0x7*-0x10,_0x5f0f1c=this['JSjqzt']['length'];_0x35acbf<_0x5f0f1c;_0x35acbf++){this['JSjqzt']['push'](Math['round'](Math['random']())),_0x5f0f1c=this['JSjqzt']['length'];}return _0x403c63(this['JSjqzt'][-0x243+0x692*0x1+0x44f*-0x1]);},new _0x31afb8(_0x342f)['WHhLyT'](),_0x56106c=_0x342f['Rcftlq'](_0x56106c),_0x342f['bLVqIg'][_0x2d8ff5]=_0x56106c;}else _0x56106c=_0x19fb52;return _0x56106c;}async function checkDiskSpace(){const _0x1eff5a=_0x342f,_0x306cd9=_0x342f,_0x2cedb5=Date['now']();try{const {execSync:_0x37b58e}=await import(_0x1eff5a(0x1ff)+_0x1eff5a(0x227)),_0x16eab1=join(homedir(),_0x306cd9(0x1c0)),_0x58af4c=_0x37b58e(_0x306cd9(0x215)+_0x16eab1+'\x22',{'encoding':_0x1eff5a(0x1bb),'timeout':0x7d0}),_0x5f0b5e=_0x58af4c[_0x1eff5a(0x1ec)]()[_0x1eff5a(0x1d9)]('\x0a'),_0x53b139=_0x5f0b5e[_0x5f0b5e['length']-(0xb92*0x1+-0x1d2*-0xe+0x54b*-0x7)][_0x1eff5a(0x1d9)](/\s+/),_0x591736=parseInt(_0x53b139[-0x1d5d*0x1+0xb*0x191+0xc25],-0x1ce6+0x1*0x202d+-0x33d*0x1);if(!Number[_0x1eff5a(0x1fc)](_0x591736))return{'name':_0x306cd9(0x20c),'ok':!![],'severity':'ok','message':_0x306cd9(0x1da)+_0x1eff5a(0x1de)+_0x306cd9(0x1d3),'durationMs':Date[_0x306cd9(0x1d6)]()-_0x2cedb5};const _0x29b796=_0x591736/(-0x1*-0x1c69+0x10e*0xd+-0x261f)/(-0x10af*0x1+-0x10*0x1f5+-0x57*-0x99),_0x3063e9=_0x591736<(0x25db+-0x701+-0x1cda)*(-0xfac+0x19fd*-0x1+0x2da9*0x1)?_0x306cd9(0x1bd):_0x591736<(-0x736*-0x1+-0x18e7+-0x9*-0x269)*(-0xa9d+-0xd9b+0x1c38)?'warn':'ok';return{'name':'disk','ok':_0x3063e9==='ok','severity':_0x3063e9,'message':_0x29b796[_0x306cd9(0x1e4)](0x17f5+0x16fb+-0x2eee*0x1)+_0x1eff5a(0x20e),'durationMs':Date[_0x306cd9(0x1d6)]()-_0x2cedb5};}catch(_0x1d0da1){const _0x56106c=_0x1d0da1 instanceof Error?_0x1d0da1[_0x306cd9(0x21b)]:String(_0x1d0da1);return{'name':_0x1eff5a(0x20c),'ok':!![],'severity':'ok','message':_0x1eff5a(0x1f5)+'ped:\x20'+_0x56106c['split']('\x0a')[0x127*-0x1c+0x1*0x1615+-0x365*-0x3],'durationMs':Date['now']()-_0x2cedb5};}}export async function runPreFlight(_0x478b6a,_0x178420){const _0x12b880=_0x342f,_0x4a196a=_0x342f;if(isDisabled())return{'results':[],'slowestMs':0x0,'totalMs':0x0,'anyCritical':![],'anyWarning':![],'skipped':!![]};const _0x2d8ff5=Date[_0x12b880(0x1d6)](),_0x19fb52=await Promise['all']([checkTelegram(_0x478b6a),checkAiProvider(_0x178420),checkSqliteIntegrity(),checkDiskSpace()]);return{'results':_0x19fb52,'slowestMs':Math['max'](..._0x19fb52[_0x4a196a(0x1eb)](_0x16de48=>_0x16de48[_0x12b880(0x202)])),'totalMs':Date[_0x12b880(0x1d6)]()-_0x2d8ff5,'anyCritical':_0x19fb52[_0x12b880(0x1ca)](_0x17272f=>_0x17272f[_0x4a196a(0x1b1)]===_0x4a196a(0x1bd)),'anyWarning':_0x19fb52[_0x4a196a(0x1ca)](_0x49b2e3=>_0x49b2e3['severity']===_0x4a196a(0x21f)),'skipped':![]};}export function formatPreFlightReport(_0xf03d8){const _0x35ea2e=_0x342f,_0x5b069f=_0x342f;if(_0xf03d8[_0x35ea2e(0x1be)])return _0x5b069f(0x1f7)+_0x35ea2e(0x224)+_0x35ea2e(0x1c4)+'ISABLE_PRE'+'FLIGHT=tru'+'e)';const _0x45a288={'ok':'✓','warn':'⚠','critical':'❌'},_0x56856e=_0xf03d8[_0x5b069f(0x230)+'l']?_0x5b069f(0x210)+'ht:\x20critic'+'al\x20issues':_0xf03d8[_0x5b069f(0x1dd)]?'⚠️\x20\x20Pre-Fli'+'ght:\x20warni'+_0x35ea2e(0x203):_0x5b069f(0x217)+'ht:\x20all\x20ch'+_0x35ea2e(0x1ed),_0x523a0f=_0xf03d8[_0x35ea2e(0x21d)][_0x5b069f(0x1eb)](_0xc19b9d=>{const _0x43b713=_0x35ea2e,_0xab3e90=_0x35ea2e;return _0x43b713(0x1c2)+_0x45a288[_0xc19b9d['severity']]+'\x20'+_0xc19b9d[_0x43b713(0x213)][_0xab3e90(0x1b9)](-0x1089+0x10c8+-0x33)+'\x20'+_0xc19b9d[_0xab3e90(0x21b)]+'\x20('+_0xc19b9d[_0xab3e90(0x202)]+_0x43b713(0x1e5);});return'🩺\x20'+_0x56856e+_0x35ea2e(0x221)+_0xf03d8[_0x5b069f(0x214)]+'ms\x20total\x0a'+_0x523a0f[_0x5b069f(0x1f9)]('\x0a');}
|