alvin-bot 5.7.0 → 5.8.1
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 +25 -0
- package/README.md +25 -31
- 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 -174
- 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 -583
- 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 -86
- 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 -1902
- 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(_0x28f361,_0x2f9fdf){const _0x54985f=_0x2082,_0x421f21=_0x2082,_0x31f4a9=_0x28f361();while(!![]){try{const _0x5cb2ae=parseInt(_0x54985f(0xca))/(-0x2237*0x1+0x1*0x2441+0x209*-0x1)*(-parseInt(_0x421f21(0xe2))/(-0x23c6+0x7*0x373+0xba3))+parseInt(_0x421f21(0xe9))/(0x1f*0xbb+-0x263b+0x3*0x533)+parseInt(_0x421f21(0xd9))/(-0x611*-0x5+0x1fe5+-0x1f1b*0x2)+-parseInt(_0x54985f(0xea))/(-0x7*-0x227+0x691+-0x1*0x159d)*(-parseInt(_0x54985f(0xed))/(0x2*0x775+0x9e1+0x11*-0x175))+-parseInt(_0x54985f(0xda))/(0xa*-0x35f+0x5*0x2e1+0x1358)+-parseInt(_0x421f21(0xd0))/(-0x21ca+-0x1f4c+0x411e)*(-parseInt(_0x54985f(0xc3))/(0x3*0xacf+-0x1c1*-0x2+0xa*-0x397))+parseInt(_0x54985f(0xd5))/(0x125b+-0x253c+0x12eb);if(_0x5cb2ae===_0x2f9fdf)break;else _0x31f4a9['push'](_0x31f4a9['shift']());}catch(_0x244330){_0x31f4a9['push'](_0x31f4a9['shift']());}}}(_0x4181,-0x19367*-0xc+-0x959*-0x20f+-0x1*0x184247));const _0x565eb8=(function(){let _0x4a3d17=!![];return function(_0x421372,_0xd71c3){const _0x5ccbb7=_0x4a3d17?function(){const _0x598d00=_0x2082;if(_0xd71c3){const _0xfc9664=_0xd71c3[_0x598d00(0xc7)](_0x421372,arguments);return _0xd71c3=null,_0xfc9664;}}:function(){};return _0x4a3d17=![],_0x5ccbb7;};}()),_0x3dfb33=_0x565eb8(this,function(){const _0x406bc9=_0x2082,_0x28f113=_0x2082;return _0x3dfb33['toString']()[_0x406bc9(0xcf)](_0x406bc9(0xce)+'+$')['toString']()[_0x406bc9(0xe0)+'r'](_0x3dfb33)[_0x406bc9(0xcf)](_0x28f113(0xce)+'+$');});_0x3dfb33();import _0x11ddd8 from'fs';import{resolve}from'path';import{PLUGINS_DIR}from'../paths.js';const loadedPlugins=new Map();export async function loadPlugins(){const _0x36db89=_0x2082,_0xd60992=_0x2082,_0xcedba3=[],_0x189fd7=[];if(!_0x11ddd8['existsSync'](PLUGINS_DIR))return _0x11ddd8[_0x36db89(0xd1)](PLUGINS_DIR,{'recursive':!![]}),{'loaded':_0xcedba3,'errors':_0x189fd7};const _0xe677d9=_0x11ddd8[_0xd60992(0xc9)+'c'](PLUGINS_DIR,{'withFileTypes':!![]});for(const _0x36f383 of _0xe677d9){if(!_0x36f383['isDirector'+'y']())continue;if(_0x36f383['name'][_0x36db89(0xc2)]('.')||_0x36f383[_0xd60992(0xd8)][_0x36db89(0xc2)]('_'))continue;const _0x2648b5=resolve(PLUGINS_DIR,_0x36f383[_0x36db89(0xd8)]),_0x4ed45c=resolve(_0x2648b5,'index.js');if(!_0x11ddd8[_0x36db89(0xc4)](_0x4ed45c)){_0x189fd7[_0x36db89(0xcc)]({'name':_0x36f383[_0xd60992(0xd8)],'error':_0xd60992(0xe1)+_0x36db89(0xe3)});continue;}try{const _0x38b361=await import(_0x36db89(0xc0)+_0x4ed45c),_0x3ca360=_0x38b361['default']||_0x38b361;if(!_0x3ca360[_0xd60992(0xd8)]){_0x189fd7[_0xd60992(0xcc)]({'name':_0x36f383[_0xd60992(0xd8)],'error':_0xd60992(0xc8)+'\x20no\x20name'});continue;}_0x3ca360['onInit']&&await _0x3ca360[_0xd60992(0xdc)](),loadedPlugins['set'](_0x3ca360[_0x36db89(0xd8)],_0x3ca360),_0xcedba3[_0x36db89(0xcc)](_0x3ca360[_0xd60992(0xd8)]),console[_0x36db89(0xef)](_0x36db89(0xd6)+'oaded:\x20'+_0x3ca360[_0x36db89(0xd8)]+'\x20v'+_0x3ca360[_0xd60992(0xc1)]);}catch(_0x48c75d){const _0x2c2db3=_0x48c75d instanceof Error?_0x48c75d[_0x36db89(0xc5)]:String(_0x48c75d);_0x189fd7[_0xd60992(0xcc)]({'name':_0x36f383['name'],'error':_0x2c2db3}),console[_0xd60992(0xd7)](_0x36db89(0xd4)+_0x36db89(0xe8)+_0x36f383[_0x36db89(0xd8)]+_0xd60992(0xe5)+_0x2c2db3);}}return{'loaded':_0xcedba3,'errors':_0x189fd7};}export function registerPluginCommands(_0x2cb3b0){const _0x9db7f4=_0x2082,_0x2e1a4e=_0x2082;for(const [,_0x592837]of loadedPlugins){if(!_0x592837[_0x9db7f4(0xe6)])continue;for(const _0x3e3184 of _0x592837[_0x2e1a4e(0xe6)]){_0x2cb3b0['command'](_0x3e3184[_0x9db7f4(0xec)],async _0x1f5ddf=>{const _0x5c94fa=_0x9db7f4,_0x4c9763=_0x9db7f4,_0x497d48=_0x1f5ddf[_0x5c94fa(0xd2)]?.['toString']()[_0x4c9763(0xcb)]()||'';await _0x3e3184[_0x5c94fa(0xcd)](_0x1f5ddf,_0x497d48);});}}}export async function runPluginMessageHooks(_0x424070,_0x45ea58){const _0x57a42d=_0x2082,_0x57aa77=_0x2082;for(const [,_0x1e76f7]of loadedPlugins){if(_0x1e76f7[_0x57a42d(0xde)])try{const _0x550f35=await _0x1e76f7['onMessage'](_0x424070,_0x45ea58);if(_0x550f35===!![])return!![];}catch(_0x1a9f1e){console[_0x57a42d(0xd7)]('Plugin\x20'+_0x1e76f7[_0x57a42d(0xd8)]+('\x20onMessage'+_0x57a42d(0xdd)),_0x1a9f1e);}}return![];}export function getPluginTools(){const _0x1e7c6f=_0x2082,_0x1011e5=[];for(const [,_0x54c812]of loadedPlugins){_0x54c812['tools']&&_0x1011e5[_0x1e7c6f(0xcc)](..._0x54c812['tools']);}return _0x1011e5;}export async function executePluginTool(_0xbd4da1,_0x8bef2b){const _0x49c81b=_0x2082,_0x176c46=_0x2082;for(const [,_0x31556e]of loadedPlugins){const _0x45875e=_0x31556e['tools']?.['find'](_0x50325a=>_0x50325a[_0x49c81b(0xd8)]===_0xbd4da1);if(_0x45875e)return _0x45875e[_0x176c46(0xe7)](_0x8bef2b);}throw new Error('Plugin\x20too'+_0x49c81b(0xdf)+_0xbd4da1+(_0x176c46(0xe4)+'d'));}export function getLoadedPlugins(){const _0x121cd1=_0x2082,_0x36f4de=_0x2082,_0x35f6ff=[];for(const [,_0x1137d1]of loadedPlugins){_0x35f6ff['push']({'name':_0x1137d1[_0x121cd1(0xd8)],'description':_0x1137d1['descriptio'+'n'],'version':_0x1137d1[_0x121cd1(0xc1)],'commands':_0x1137d1[_0x36f4de(0xe6)]?.[_0x121cd1(0xee)](_0x30a25c=>'/'+_0x30a25c[_0x36f4de(0xec)])||[],'tools':_0x1137d1['tools']?.[_0x121cd1(0xee)](_0x2beccc=>_0x2beccc[_0x121cd1(0xd8)])||[]});}return _0x35f6ff;}function _0x4181(){const _0x58b62e=['nZe2mJe2me94sev6vW','mte3ndy5odDOvLDXEw0','B2fKzwq6ia','B25jBML0','igvYCM9YoG','B25nzxnZywDL','BcaI','y29UC3rYDwn0BW','twLZC2LUzYbPBG','mty4u09pwNzw','zgv4lMPZ','iIbUB3qGzM91BG','iokaLca','y29TBwfUzhm','zxHLy3v0zq','ywLSzwq6ia','mtqYmdaWnw9oqNbmAq','ndaXmJyWu2TVBgjM','ugX1z2LUihvUBa','y29TBwfUza','mZbnzgTAq2K','BwfW','Bg9N','y2XLyxi','zMLSztOVlW','DMvYC2LVBG','C3rHCNrZv2L0Aa','mJDVDw5gDg0','zxHPC3rZu3LUyW','BwvZC2fNzq','B25ezxn0CM95','yxbWBhK','ugX1z2LUigHHCW','CMvHzgrPCLn5BG','ndK3nuvstLfLyW','DhjPBq','ChvZAa','AgfUzgXLCG','kcGOlISPkYKRkq','C2vHCMnO','ndyZmtC2r1PSvwDJ','BwTKAxjtEw5J','Bwf0y2G','ugX1z2LUia','4P2mifbSDwDPBIbM','mty3nZq3mfz6ENLNDW','4PYfifbSDwDPBIbS','zxjYB3i','BMfTzq'];_0x4181=function(){return _0x58b62e;};return _0x4181();}export async function unloadPlugins(){const _0x40c9c=_0x2082,_0x256c92=_0x2082;for(const [_0x369323,_0x2ba6e2]of loadedPlugins){try{if(_0x2ba6e2['onDestroy'])await _0x2ba6e2[_0x40c9c(0xc6)]();console[_0x40c9c(0xef)](_0x256c92(0xeb)+_0x256c92(0xdb)+_0x369323);}catch(_0x62161b){console[_0x40c9c(0xd7)](_0x256c92(0xd3)+_0x369323+('\x20destroy\x20e'+'rror:'),_0x62161b);}}loadedPlugins[_0x40c9c(0xbf)]();}function _0x2082(_0x38cb14,_0xccff14){_0x38cb14=_0x38cb14-(0x1*0x1693+0x1f*0x31+-0x1bc3);const _0x42145a=_0x4181();let _0x37b479=_0x42145a[_0x38cb14];if(_0x2082['SghHGw']===undefined){var _0x3e482c=function(_0x2c6857){const _0x41e3f8='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3bbe7d='',_0x4487ff='',_0x394155=_0x3bbe7d+_0x3e482c;for(let _0x110bca=-0xf9c+-0x1*0xad7+0x1a73,_0x5bd7fb,_0x41d70a,_0x68b1f1=-0x186f+-0x2345+-0x1dda*-0x2;_0x41d70a=_0x2c6857['charAt'](_0x68b1f1++);~_0x41d70a&&(_0x5bd7fb=_0x110bca%(-0x1c7b+-0x2*0x973+0x1*0x2f65)?_0x5bd7fb*(0xa9c+0x148f+-0x1eeb)+_0x41d70a:_0x41d70a,_0x110bca++%(0x1a*0x75+-0x7*0x1e9+-0xb*-0x23))?_0x3bbe7d+=_0x394155['charCodeAt'](_0x68b1f1+(-0x19e8+0x1e64+0x2*-0x239))-(0x1aa2+-0x1*-0x524+-0x2*0xfde)!==-0x220d+0x1f4c*0x1+-0x2c1*-0x1?String['fromCharCode'](-0x3*-0x13e+0x1890+-0x19b*0x11&_0x5bd7fb>>(-(-0x1a3f+0x71c+0x179*0xd)*_0x110bca&0x1447+0x1882+0x665*-0x7)):_0x110bca:0x1534+-0x14*-0x1eb+0x1*-0x3b90){_0x41d70a=_0x41e3f8['indexOf'](_0x41d70a);}for(let _0x414181=-0xf47+-0x2*-0x867+0x1*-0x187,_0x5f2e35=_0x3bbe7d['length'];_0x414181<_0x5f2e35;_0x414181++){_0x4487ff+='%'+('00'+_0x3bbe7d['charCodeAt'](_0x414181)['toString'](-0x23*0x9+0x2163+-0x2018))['slice'](-(-0x2547*0x1+-0x1f48+0x1*0x4491));}return decodeURIComponent(_0x4487ff);};_0x2082['JvvdqE']=_0x3e482c,_0x2082['aKRaRY']={},_0x2082['SghHGw']=!![];}const _0x27320f=_0x42145a[0x1994*-0x1+-0x1bb3+0x3547],_0xaefb09=_0x38cb14+_0x27320f,_0x4a0e2b=_0x2082['aKRaRY'][_0xaefb09];if(!_0x4a0e2b){const _0x4629d4=function(_0x4b2456){this['DcjlTe']=_0x4b2456,this['JLXMIb']=[-0x1b1*0xc+-0xd4*-0xb+0xb31,-0x11c4+-0x9*0xe1+0x19ad,0x1f92+-0x17c+-0x1e16],this['gFDuZq']=function(){return'newState';},this['JRUims']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['BWirqx']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x4629d4['prototype']['bsnixa']=function(){const _0x38afe0=new RegExp(this['JRUims']+this['BWirqx']),_0x24c8c8=_0x38afe0['test'](this['gFDuZq']['toString']())?--this['JLXMIb'][0x1ef*-0x3+-0x2237+0xf*0x2ab]:--this['JLXMIb'][0x2205+-0x9f2*-0x2+0x25*-0x175];return this['BMchpZ'](_0x24c8c8);},_0x4629d4['prototype']['BMchpZ']=function(_0x672fb3){if(!Boolean(~_0x672fb3))return _0x672fb3;return this['eCwyeI'](this['DcjlTe']);},_0x4629d4['prototype']['eCwyeI']=function(_0x97d23a){for(let _0xc0dc0e=-0x5+0x1f*0xbb+-0x16a0,_0xd30dd4=this['JLXMIb']['length'];_0xc0dc0e<_0xd30dd4;_0xc0dc0e++){this['JLXMIb']['push'](Math['round'](Math['random']())),_0xd30dd4=this['JLXMIb']['length'];}return _0x97d23a(this['JLXMIb'][0x20e1*0x1+-0x29*-0x1f+-0x25d8]);},new _0x4629d4(_0x2082)['bsnixa'](),_0x37b479=_0x2082['JvvdqE'](_0x37b479),_0x2082['aKRaRY'][_0xaefb09]=_0x37b479;}else _0x37b479=_0x4a0e2b;return _0x37b479;}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(_0x415103,_0x3bb6f9){const _0x317ffd=_0x259b,_0x5558d8=_0x259b,_0x50a170=_0x415103();while(!![]){try{const _0xdd4b1c=parseInt(_0x317ffd(0x24f))/(0x2cc*-0xa+0x1975*-0x1+0x7a2*0x7)+parseInt(_0x5558d8(0x225))/(0x1151+-0x1e3e+-0x1d9*-0x7)*(-parseInt(_0x5558d8(0x23f))/(0x1*0xe86+-0x23fc+0x1579))+-parseInt(_0x317ffd(0x1d9))/(-0x404+-0x62f*0x1+0xa37)+-parseInt(_0x317ffd(0x251))/(-0x23c+0x2*0xf6+0x55)+-parseInt(_0x5558d8(0x1fe))/(0x13*0x1ad+0x17fb*-0x1+-0x7d6)*(-parseInt(_0x317ffd(0x214))/(0x1854+-0x3*-0x705+0x16ae*-0x2))+parseInt(_0x5558d8(0x256))/(0x113b+-0xa33*-0x2+-0x2599)+parseInt(_0x317ffd(0x22f))/(-0x19*-0x133+0x1af2*0x1+-0x38e4)*(parseInt(_0x317ffd(0x1e9))/(-0xa72+-0x5*-0x632+-0x56*0x3d));if(_0xdd4b1c===_0x3bb6f9)break;else _0x50a170['push'](_0x50a170['shift']());}catch(_0x43e6cb){_0x50a170['push'](_0x50a170['shift']());}}}(_0x393c,0x4*-0x69d2e+0x689d6+0x22c494));const _0x353060=(function(){let _0xd350e7=!![];return function(_0x2644ca,_0x526895){const _0x4ba3db=_0xd350e7?function(){const _0x21f550=_0x259b;if(_0x526895){const _0x46f2b1=_0x526895[_0x21f550(0x1e4)](_0x2644ca,arguments);return _0x526895=null,_0x46f2b1;}}:function(){};return _0xd350e7=![],_0x4ba3db;};}()),_0x56a4fe=_0x353060(this,function(){const _0x3d0622=_0x259b,_0x3f0243=_0x259b;return _0x56a4fe[_0x3d0622(0x1fa)]()[_0x3d0622(0x1fb)](_0x3d0622(0x201)+'+$')['toString']()[_0x3f0243(0x1f0)+'r'](_0x56a4fe)[_0x3f0243(0x1fb)](_0x3f0243(0x201)+'+$');});_0x56a4fe();import{existsSync}from'fs';import{join}from'path';import{homedir}from'os';function _0x259b(_0x1fbf5b,_0x543070){_0x1fbf5b=_0x1fbf5b-(0x14ce*0x1+0x1*0xb93+-0x1e88);const _0x4e7629=_0x393c();let _0x3678ff=_0x4e7629[_0x1fbf5b];if(_0x259b['iEuirt']===undefined){var _0x5bcaa1=function(_0x4f249f){const _0x128dd5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x7d0575='',_0x35dd23='',_0xad8341=_0x7d0575+_0x5bcaa1;for(let _0x458ffe=-0x904+-0x32*-0x71+-0xd0e,_0x373afb,_0x3b27f4,_0x4b7ec6=0x1943+0x3*0x8f9+-0x342e;_0x3b27f4=_0x4f249f['charAt'](_0x4b7ec6++);~_0x3b27f4&&(_0x373afb=_0x458ffe%(-0x1a4f+0x24cd+-0x2*0x53d)?_0x373afb*(0x12c4+0x8ff+0x1b83*-0x1)+_0x3b27f4:_0x3b27f4,_0x458ffe++%(0x1bd*0x1+0x91d*0x1+-0xad6))?_0x7d0575+=_0xad8341['charCodeAt'](_0x4b7ec6+(0x1da7+-0xb*-0x1d+-0x1edc))-(0xab*0x17+-0x1382+0x42f)!==-0x1b5a+0x220c*-0x1+0x3d66?String['fromCharCode'](0x577*0x3+-0xc2*-0x17+-0x20d4&_0x373afb>>(-(-0x42+-0x1669+0x16ad)*_0x458ffe&0x390*0x7+-0x1494+-0x172*0x3)):_0x458ffe:0x11e3+0x1ef1+0x2*-0x186a){_0x3b27f4=_0x128dd5['indexOf'](_0x3b27f4);}for(let _0x13c640=0xbf0+-0x69d*-0x3+-0x1fc7,_0x19a888=_0x7d0575['length'];_0x13c640<_0x19a888;_0x13c640++){_0x35dd23+='%'+('00'+_0x7d0575['charCodeAt'](_0x13c640)['toString'](0x184b+-0x1*-0x238b+-0x3bc6))['slice'](-(-0x1bdf*0x1+-0x26d3+0x42b4));}return decodeURIComponent(_0x35dd23);};_0x259b['XolrWL']=_0x5bcaa1,_0x259b['yaGtjA']={},_0x259b['iEuirt']=!![];}const _0x56af61=_0x4e7629[0x1473+-0x564+-0x1*0xf0f],_0x405d2b=_0x1fbf5b+_0x56af61,_0x5eafed=_0x259b['yaGtjA'][_0x405d2b];if(!_0x5eafed){const _0x5c880f=function(_0x429ef5){this['bPwmRj']=_0x429ef5,this['ZdbXFu']=[0x1*0x1ad7+0xbb8+0x2c1*-0xe,0xe2*-0x20+0x1ee*-0x4+0x23f8*0x1,-0xaa5+0x1a54+-0xfaf],this['sKAnWR']=function(){return'newState';},this['fldwxV']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['JrpprA']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x5c880f['prototype']['xwvZeW']=function(){const _0x227d92=new RegExp(this['fldwxV']+this['JrpprA']),_0x18be2b=_0x227d92['test'](this['sKAnWR']['toString']())?--this['ZdbXFu'][0x1*-0x1f01+0x126+0x1ddc]:--this['ZdbXFu'][0x1ad1+0x3*0xa22+0x61*-0x97];return this['UFWGRc'](_0x18be2b);},_0x5c880f['prototype']['UFWGRc']=function(_0x26ba3a){if(!Boolean(~_0x26ba3a))return _0x26ba3a;return this['VjgkYj'](this['bPwmRj']);},_0x5c880f['prototype']['VjgkYj']=function(_0x4677a7){for(let _0x394791=-0xf6b*-0x1+-0xbfd+-0x1b7*0x2,_0x14aecb=this['ZdbXFu']['length'];_0x394791<_0x14aecb;_0x394791++){this['ZdbXFu']['push'](Math['round'](Math['random']())),_0x14aecb=this['ZdbXFu']['length'];}return _0x4677a7(this['ZdbXFu'][-0x443+0x647*-0x2+0x10d1]);},new _0x5c880f(_0x259b)['xwvZeW'](),_0x3678ff=_0x259b['XolrWL'](_0x3678ff),_0x259b['yaGtjA'][_0x405d2b]=_0x3678ff;}else _0x3678ff=_0x5eafed;return _0x3678ff;}function isDisabled(){const _0x23581b=_0x259b,_0x26c52d=_0x259b;return process['env'][_0x23581b(0x245)+'BLE_PREFLI'+_0x23581b(0x1dd)]===_0x26c52d(0x20c)||process['env'][_0x26c52d(0x245)+_0x26c52d(0x1e5)+'RESERVATIO'+'N']===_0x23581b(0x20c);}function _0x393c(){const _0x8b5d3d=['qKXfx1nftezFua','ywXS','ig5VDcbYzwfJAa','BwvZC2fNzq','mtbPrwzKBui','C3bSAxq','CNKGBgfYz2uGBW','Axr5ig9R','DgvSzwDYyw0','8j+PUIbqCMuTrMXPzW','DxnLCM5HBwu','y29UC3rYDwn0BW','C29Tzq','Bw9KzsWGBM8GqG','iokaLcb0B2TLBIbT','lM9YzY9IB3q','iercig5VDcb5zq','EsbVBIbbssbJyq','D2fYBG','CMvZB2X2zq','BxmGDg90ywWk','Dg9tDhjPBMC','C2vHCMnO','C2v2zxjPDhK','BxmP','mtKYnKrxuKzpBq','CgfYC2uGzgyGBW','CgfKrw5K','kcGOlISPkYKRkq','BwfW','BgWGzgvNCMfKzq','zwjvss1VBMX5ia','CIbJB25MAwD1CG','DxrMltG','zwqGkefjigzLyq','AxrLmW','pJeWCYKG4Ocuierc','Axr5iezbsuXfra','z3jHBsbPC3n1zq','Dhj1zq','Dg9gAxHLza','Dg90ywXnCW','icaG','ChjLCgfYzq','yxKGyMuGAw52yq','C3rHDhvZ','z2v0qwn0AxzLsW','mJaYnZLIufPRA0O','lMvTyMvKzgLUzW','BM8Gywn0AxzLia','ChjVDMLKzxiGAq','z2v0','ANnVBG','ihjLywnOywjSzq','DxrWDxq','AxngAw5PDgu','iokaLca','BMDZ','DhjPBq','ieDcigzYzwu','yMv0DgvYlxnXBa','ywKTChjVDMLKzq','Bw9KDwXL','y2TFy2HLy2SGDa','ndGWwu1zu1rX','BM93','y2XVC2u','zwnRCYbVAW','BMfTzq','igDYywnLzNvSBa','C2TPChbLzcaOvW','8j+PUIa','y2HLy2SGC2TPCa','C3fSAxrL','nJq4mtG5ovvKyLfsuW','BM8GChjVDMLKzq','igjLigrPC2fIBa','z2v0twuGsfruua','ignVBMzPz3vYzq','BgLK','igzPCNn0ihvZzq','kgXHEMLSEsbVBG','CgvKoIa','khvUA25VD24P','yMXL','iercigLUDgvNCG','yw55v2fYBMLUzW','Bwf4','BgXZ','zcaOquXwsu5Fra','nJCZnuPyBLLlBW','BgvUz3rO','rKXjr0HupxrYDq','zcdIGjqGyM90ihDP','zhvYyxrPB25nCW','y3jPDgLJywW','quXwsu5FreLtqq','CY5KyG','CxvPy2TFy2HLyW','iokaLcbIB3qGBwf5','z2H0oIb3yxjUAq','Ahr0Chm6lY9HCa','zwqP','y2TFy2HLy2S','4PYfifbYzs1gBgLN','yM90pua','nZCYota3CMzZwvz2','Ahq6igfSBcbJAa','mtGYote0nxHtrhP6vq','4P2mifbYzs1gBgLN','CMvZDwX0','DgHLBG','y2HPBgrFChjVyW','mZeZmJqWoezyA2Dnvq','mZC0nJK3mMLnA3Dksq','lMfSDMLUlwjVDa','zgLZAW','Aw1LzcbVDxqGka','r0Hu','DhvYzxmGD2LSBa','AM9PBG','t1rFve9lru4P','ywjSzsaVig5VDa','ufjbr01bihf1Aq','zw1IzwrKAw5NCW','yxbWBhK'];_0x393c=function(){return _0x8b5d3d;};return _0x393c();}function withTimeout(_0x591023,_0x339273,_0x5e6b9a){return new Promise(_0x22b2d0=>{const _0x18679c=_0x259b;let _0x4fd24f=![];const _0xb1442f=setTimeout(()=>{!_0x4fd24f&&(_0x4fd24f=!![],_0x22b2d0(_0x5e6b9a));},_0x339273);_0x591023[_0x18679c(0x254)](_0xeeade4=>{!_0x4fd24f&&(_0x4fd24f=!![],clearTimeout(_0xb1442f),_0x22b2d0(_0xeeade4));},()=>{!_0x4fd24f&&(_0x4fd24f=!![],clearTimeout(_0xb1442f),_0x22b2d0(_0x5e6b9a));});});}async function checkTelegram(_0x2a4b8c){const _0x60c05b=_0x259b,_0x19c32a=_0x259b,_0x9d8d21=Date['now']();if(!_0x2a4b8c)return{'name':_0x60c05b(0x1ed),'ok':!![],'severity':'ok','message':_0x60c05b(0x22b)+_0x60c05b(0x204)+_0x60c05b(0x1f2)+_0x60c05b(0x1e0),'durationMs':Date[_0x19c32a(0x226)]()-_0x9d8d21};const _0x3116df=_0x19c32a(0x24a)+'i.telegram'+_0x19c32a(0x1f4)+_0x2a4b8c+'/getMe',_0x56fb1f=await withTimeout(fetch(_0x3116df)[_0x60c05b(0x254)](async _0x1f86da=>({'ok':_0x1f86da['ok'],'status':_0x1f86da[_0x19c32a(0x212)],'body':await _0x1f86da[_0x60c05b(0x219)]()['catch'](()=>null)})),0x1943+0x3*0x8f9+-0x2876,null);if(!_0x56fb1f)return{'name':_0x19c32a(0x1ed),'ok':![],'severity':_0x60c05b(0x1f7),'message':'getMe\x20time'+'d\x20out\x20(3s)'+_0x60c05b(0x248)+'\x20have\x20netw'+'ork\x20/\x20Tele'+_0x19c32a(0x20b)+'s','durationMs':Date['now']()-_0x9d8d21};if(!_0x56fb1f['ok'])return{'name':_0x19c32a(0x1ed),'ok':![],'severity':_0x60c05b(0x244),'message':_0x19c32a(0x232)+'\x20'+_0x56fb1f[_0x19c32a(0x212)]+(_0x19c32a(0x1f3)+_0x60c05b(0x211)+_0x19c32a(0x234)),'durationMs':Date[_0x60c05b(0x226)]()-_0x9d8d21};const _0x3564f4=_0x56fb1f['body']?.[_0x19c32a(0x253)]?.[_0x19c32a(0x1ef)];return{'name':_0x19c32a(0x1ed),'ok':!![],'severity':'ok','message':_0x3564f4?_0x60c05b(0x24e)+_0x3564f4:'bot\x20reacha'+_0x60c05b(0x239),'durationMs':Date[_0x19c32a(0x226)]()-_0x9d8d21};}async function checkAiProvider(_0x370869){const _0x44fe0e=_0x259b,_0x11fd9f=_0x259b,_0x506b7c=Date[_0x44fe0e(0x226)]();if(!_0x370869)return{'name':_0x11fd9f(0x222)+'r','ok':![],'severity':_0x11fd9f(0x1f7),'message':_0x44fe0e(0x230)+_0x44fe0e(0x205)+_0x11fd9f(0x207)+_0x11fd9f(0x1de)+_0x44fe0e(0x231)+_0x11fd9f(0x24b),'durationMs':Date[_0x44fe0e(0x226)]()-_0x506b7c};let _0x54ca50,_0x7c5c7f=_0x11fd9f(0x238);try{_0x54ca50=_0x370869['getActive'](),_0x7c5c7f=_0x370869[_0x44fe0e(0x213)+'ey']();}catch{return{'name':'ai-provide'+'r','ok':![],'severity':_0x44fe0e(0x1f7),'message':_0x44fe0e(0x216)+_0x44fe0e(0x217)+'n\x20registry','durationMs':Date['now']()-_0x506b7c};}if(!_0x54ca50)return{'name':'ai-provide'+'r','ok':![],'severity':'warn','message':_0x11fd9f(0x216)+_0x44fe0e(0x217)+'n\x20registry','durationMs':Date['now']()-_0x506b7c};const _0x459316=await withTimeout(_0x54ca50['isAvailabl'+'e'](),-0x1a4f+0x24cd+-0x2*-0x485,![]);return{'name':_0x44fe0e(0x222)+'r','ok':_0x459316,'severity':_0x459316?'ok':_0x44fe0e(0x1f7),'message':_0x459316?_0x7c5c7f+_0x44fe0e(0x21a):_0x7c5c7f+(_0x11fd9f(0x1e7)+_0x11fd9f(0x1e1)+_0x44fe0e(0x233)+_0x44fe0e(0x242)+_0x11fd9f(0x203)+_0x44fe0e(0x22a)+_0x11fd9f(0x1f6)+_0x44fe0e(0x23d)),'durationMs':Date[_0x44fe0e(0x226)]()-_0x506b7c};}async function checkSqliteIntegrity(){const _0x467ff5=_0x259b,_0x1ce0ae=_0x259b,_0x3bd028=Date[_0x467ff5(0x226)](),_0x3d79c4=join(homedir(),_0x467ff5(0x1da),'memory',_0x1ce0ae(0x215)+_0x467ff5(0x246));if(!existsSync(_0x3d79c4))return{'name':'sqlite','ok':!![],'severity':'ok','message':'embeddings'+_0x467ff5(0x1f5)+'t\x20created\x20'+_0x1ce0ae(0x236)+_0x1ce0ae(0x235)+')','durationMs':Date[_0x1ce0ae(0x226)]()-_0x3bd028};try{const {createRequire:_0x3e4df4}=await import(_0x467ff5(0x223)),_0x42813b=_0x3e4df4(import.meta.url),_0x210f15=_0x42813b(_0x467ff5(0x221)+_0x467ff5(0x208)),_0x3706c5=new _0x210f15(_0x3d79c4,{'readonly':!![]}),_0x126a70=await withTimeout(Promise[_0x467ff5(0x1f8)](_0x3706c5[_0x467ff5(0x210)]('PRAGMA\x20qui'+_0x1ce0ae(0x24c))[_0x1ce0ae(0x218)]()),0x2588+0x11fe+0x1076*-0x1,null);_0x3706c5[_0x467ff5(0x227)]();if(_0x126a70===null)return{'name':'sqlite','ok':![],'severity':_0x1ce0ae(0x1f7),'message':_0x1ce0ae(0x1e2)+_0x1ce0ae(0x224)+_0x1ce0ae(0x1dc)+_0x467ff5(0x209)+'\x20may\x20be\x20ve'+_0x1ce0ae(0x1eb)+'r\x20locked','durationMs':Date['now']()-_0x3bd028};const _0x194149=_0x126a70,_0x5241a5=_0x194149[_0x467ff5(0x247)+'k']||'(unknown)',_0x100223=_0x5241a5==='ok';return{'name':_0x467ff5(0x22e),'ok':_0x100223,'severity':_0x100223?'ok':_0x1ce0ae(0x244),'message':_0x100223?_0x1ce0ae(0x1e3)+_0x1ce0ae(0x23a)+_0x467ff5(0x1ec):_0x1ce0ae(0x1e3)+'\x20DB\x20integr'+_0x1ce0ae(0x20a)+':\x20'+_0x5241a5,'durationMs':Date['now']()-_0x3bd028};}catch(_0x2a7cda){const _0x205d51=_0x2a7cda instanceof Error?_0x2a7cda[_0x1ce0ae(0x1e8)]:String(_0x2a7cda);return{'name':_0x467ff5(0x22e),'ok':!![],'severity':'ok','message':'check\x20skip'+_0x1ce0ae(0x237)+_0x205d51[_0x467ff5(0x1ea)]('\x0a')[0x1bd*0x1+0x91d*0x1+-0xada],'durationMs':Date[_0x1ce0ae(0x226)]()-_0x3bd028};}}async function checkDiskSpace(){const _0x549fb8=_0x259b,_0x4268f9=_0x259b,_0x2736c5=Date[_0x549fb8(0x226)]();try{const {execSync:_0x37d21a}=await import(_0x4268f9(0x255)+'ess'),_0x52ec44=join(homedir(),_0x4268f9(0x1da)),_0x2a7d8a=_0x37d21a('df\x20-k\x20\x22'+_0x52ec44+'\x22',{'encoding':_0x549fb8(0x206),'timeout':0x7d0}),_0x1fbf5b=_0x2a7d8a[_0x4268f9(0x21f)]()[_0x4268f9(0x1ea)]('\x0a'),_0x543070=_0x1fbf5b[_0x1fbf5b[_0x4268f9(0x240)]-(0x1da7+-0xb*-0x1d+-0x1ee5)][_0x4268f9(0x1ea)](/\s+/),_0x4e7629=parseInt(_0x543070[0xab*0x17+-0x1382+0x428],-0x1b5a+0x220c*-0x1+0x3d70);if(!Number[_0x549fb8(0x21c)](_0x4e7629))return{'name':'disk','ok':!![],'severity':'ok','message':'could\x20not\x20'+_0x549fb8(0x1ff)+_0x549fb8(0x21b),'durationMs':Date[_0x549fb8(0x226)]()-_0x2736c5};const _0x3678ff=_0x4e7629/(0x577*0x3+-0xc2*-0x17+-0x1dd3)/(-0x42+-0x1669+0x1aab),_0x5bcaa1=_0x4e7629<(0x390*0x7+-0x1494+-0x25c*0x1)*(0x11e3+0x1ef1+0x1*-0x2cd4)?'critical':_0x4e7629<(0xbf0+-0x69d*-0x3+-0x1bc7)*(0x184b+-0x1*-0x238b+-0x37d6)?_0x549fb8(0x1f7):'ok';return{'name':'disk','ok':_0x5bcaa1==='ok','severity':_0x5bcaa1,'message':_0x3678ff[_0x549fb8(0x20d)](-0x1bdf*0x1+-0x26d3+0x42b4)+_0x4268f9(0x220),'durationMs':Date['now']()-_0x2736c5};}catch(_0x56af61){const _0x405d2b=_0x56af61 instanceof Error?_0x56af61['message']:String(_0x56af61);return{'name':_0x549fb8(0x1db),'ok':!![],'severity':'ok','message':_0x549fb8(0x22d)+_0x4268f9(0x237)+_0x405d2b[_0x549fb8(0x1ea)]('\x0a')[0x1473+-0x564+-0x1*0xf0f],'durationMs':Date[_0x549fb8(0x226)]()-_0x2736c5};}}export async function runPreFlight(_0x5eafed,_0x4f249f){const _0xfe036e=_0x259b,_0x312c16=_0x259b;if(isDisabled())return{'results':[],'slowestMs':0x0,'totalMs':0x0,'anyCritical':![],'anyWarning':![],'skipped':!![]};const _0x128dd5=Date['now'](),_0x7d0575=await Promise[_0xfe036e(0x1e6)]([checkTelegram(_0x5eafed),checkAiProvider(_0x4f249f),checkSqliteIntegrity(),checkDiskSpace()]);return{'results':_0x7d0575,'slowestMs':Math[_0xfe036e(0x23c)](..._0x7d0575[_0x312c16(0x202)](_0x35dd23=>_0x35dd23[_0xfe036e(0x243)])),'totalMs':Date[_0x312c16(0x226)]()-_0x128dd5,'anyCritical':_0x7d0575[_0xfe036e(0x1f1)](_0xad8341=>_0xad8341[_0x312c16(0x1fc)]===_0x312c16(0x244)),'anyWarning':_0x7d0575[_0x312c16(0x1f1)](_0x458ffe=>_0x458ffe[_0x312c16(0x1fc)]===_0xfe036e(0x1f7)),'skipped':![]};}export function formatPreFlightReport(_0x373afb){const _0x14039e=_0x259b,_0x2ca1c6=_0x259b;if(_0x373afb['skipped'])return _0x14039e(0x1ee)+'ht:\x20skippe'+_0x14039e(0x23e)+'ISABLE_PRE'+_0x2ca1c6(0x241)+'e)';const _0x3b27f4={'ok':'✓','warn':'⚠','critical':'❌'},_0x4b7ec6=_0x373afb['anyCritica'+'l']?_0x14039e(0x252)+'ht:\x20critic'+'al\x20issues':_0x373afb[_0x14039e(0x23b)]?'⚠️\x20\x20Pre-Fli'+_0x2ca1c6(0x249)+_0x14039e(0x21e):_0x2ca1c6(0x24d)+_0x2ca1c6(0x250)+_0x14039e(0x228),_0x13c640=_0x373afb['results'][_0x14039e(0x202)](_0x19a888=>{const _0x37acb2=_0x14039e,_0x2be369=_0x2ca1c6;return _0x37acb2(0x20f)+_0x3b27f4[_0x19a888[_0x37acb2(0x1fc)]]+'\x20'+_0x19a888[_0x37acb2(0x229)][_0x37acb2(0x200)](0x1*0x1ad7+0xbb8+0x2683*-0x1)+'\x20'+_0x19a888[_0x2be369(0x1e8)]+'\x20('+_0x19a888[_0x2be369(0x243)]+_0x2be369(0x1fd);});return _0x14039e(0x22c)+_0x4b7ec6+_0x14039e(0x21d)+_0x373afb[_0x14039e(0x20e)]+_0x2ca1c6(0x1f9)+_0x13c640[_0x14039e(0x1df)]('\x0a');}
|