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
|
@@ -1,475 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Executor — Executes tool calls for non-SDK providers.
|
|
3
|
-
*
|
|
4
|
-
* Provides core agent capabilities (shell, file read/write, web fetch)
|
|
5
|
-
* to any OpenAI-compatible provider that supports function calling.
|
|
6
|
-
*
|
|
7
|
-
* This bridges the gap between Claude SDK (built-in tools) and other
|
|
8
|
-
* providers (Groq, NVIDIA, Gemini, etc.) — giving them all agent powers.
|
|
9
|
-
*/
|
|
10
|
-
import { execSync } from "child_process";
|
|
11
|
-
import fs from "fs";
|
|
12
|
-
import os from "os";
|
|
13
|
-
import { resolve, join as pathJoin } from "path";
|
|
14
|
-
import { isSelfRestartCommand, scheduleGracefulRestart } from "../services/restart.js";
|
|
15
|
-
import { checkExecAllowed } from "../services/exec-guard.js";
|
|
16
|
-
// ── Tool Definitions (OpenAI function calling format) ───────────────────────
|
|
17
|
-
export const AGENT_TOOLS = [
|
|
18
|
-
{
|
|
19
|
-
type: "function",
|
|
20
|
-
function: {
|
|
21
|
-
name: "run_shell",
|
|
22
|
-
description: "Execute a shell command and return the output. Use for: running CLI tools, checking system state, installing packages, processing files, git operations, etc. Timeout: 30 seconds.",
|
|
23
|
-
parameters: {
|
|
24
|
-
type: "object",
|
|
25
|
-
properties: {
|
|
26
|
-
command: {
|
|
27
|
-
type: "string",
|
|
28
|
-
description: "The shell command to execute (bash). Example: 'ls -la', 'which ffmpeg', 'curl wttr.in/Berlin'"
|
|
29
|
-
},
|
|
30
|
-
workingDir: {
|
|
31
|
-
type: "string",
|
|
32
|
-
description: "Working directory (optional, defaults to user's configured dir)"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
required: ["command"],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: "function",
|
|
41
|
-
function: {
|
|
42
|
-
name: "read_file",
|
|
43
|
-
description: "Read the contents of a file. Returns the text content. Use for: reading configs, code files, documents, logs, memory files, etc.",
|
|
44
|
-
parameters: {
|
|
45
|
-
type: "object",
|
|
46
|
-
properties: {
|
|
47
|
-
path: {
|
|
48
|
-
type: "string",
|
|
49
|
-
description: "Absolute or relative path to the file"
|
|
50
|
-
},
|
|
51
|
-
maxLines: {
|
|
52
|
-
type: "number",
|
|
53
|
-
description: "Maximum number of lines to read (optional, default: all)"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
required: ["path"],
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
type: "function",
|
|
62
|
-
function: {
|
|
63
|
-
name: "write_file",
|
|
64
|
-
description: "Write content to a file. Creates the file if it doesn't exist, overwrites if it does. Use for: creating files, saving results, writing memory, updating configs.",
|
|
65
|
-
parameters: {
|
|
66
|
-
type: "object",
|
|
67
|
-
properties: {
|
|
68
|
-
path: {
|
|
69
|
-
type: "string",
|
|
70
|
-
description: "Absolute or relative path to the file"
|
|
71
|
-
},
|
|
72
|
-
content: {
|
|
73
|
-
type: "string",
|
|
74
|
-
description: "Content to write"
|
|
75
|
-
},
|
|
76
|
-
append: {
|
|
77
|
-
type: "boolean",
|
|
78
|
-
description: "Append instead of overwrite (default: false)"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
required: ["path", "content"],
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
type: "function",
|
|
87
|
-
function: {
|
|
88
|
-
name: "web_fetch",
|
|
89
|
-
description: "Fetch a URL and return the content as text/markdown. Use for: reading web pages, APIs, documentation, search results.",
|
|
90
|
-
parameters: {
|
|
91
|
-
type: "object",
|
|
92
|
-
properties: {
|
|
93
|
-
url: {
|
|
94
|
-
type: "string",
|
|
95
|
-
description: "URL to fetch (http or https)"
|
|
96
|
-
},
|
|
97
|
-
maxChars: {
|
|
98
|
-
type: "number",
|
|
99
|
-
description: "Maximum characters to return (default: 10000)"
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
required: ["url"],
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
type: "function",
|
|
108
|
-
function: {
|
|
109
|
-
name: "web_search",
|
|
110
|
-
description: "Search the web and return results. Use for: looking up information, finding answers, research.",
|
|
111
|
-
parameters: {
|
|
112
|
-
type: "object",
|
|
113
|
-
properties: {
|
|
114
|
-
query: {
|
|
115
|
-
type: "string",
|
|
116
|
-
description: "Search query"
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
required: ["query"],
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
type: "function",
|
|
125
|
-
function: {
|
|
126
|
-
name: "list_directory",
|
|
127
|
-
description: "List files and directories at a given path. Returns names, types (file/dir), and sizes. Use for: exploring project structures, finding files, checking what exists.",
|
|
128
|
-
parameters: {
|
|
129
|
-
type: "object",
|
|
130
|
-
properties: {
|
|
131
|
-
path: {
|
|
132
|
-
type: "string",
|
|
133
|
-
description: "Directory path to list (default: current working directory)"
|
|
134
|
-
},
|
|
135
|
-
recursive: {
|
|
136
|
-
type: "boolean",
|
|
137
|
-
description: "List recursively (max 3 levels deep, default: false)"
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
required: [],
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
type: "function",
|
|
146
|
-
function: {
|
|
147
|
-
name: "python_execute",
|
|
148
|
-
description: "Execute a Python 3 script and return stdout/stderr. Use for: data processing, creating Excel/CSV files, complex calculations, JSON/XML transformation, image processing, PDF generation, chart creation, and any task that benefits from Python libraries (openpyxl, pandas, matplotlib, Pillow, etc.).",
|
|
149
|
-
parameters: {
|
|
150
|
-
type: "object",
|
|
151
|
-
properties: {
|
|
152
|
-
code: {
|
|
153
|
-
type: "string",
|
|
154
|
-
description: "Python 3 code to execute. Can use installed pip packages. Use print() for output."
|
|
155
|
-
},
|
|
156
|
-
workingDir: {
|
|
157
|
-
type: "string",
|
|
158
|
-
description: "Working directory for the script (optional)"
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
required: ["code"],
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
type: "function",
|
|
167
|
-
function: {
|
|
168
|
-
name: "edit_file",
|
|
169
|
-
description: "Make a precise edit to a file by replacing exact text. More surgical than write_file — preserves the rest of the file. Use for: fixing bugs, updating configs, changing specific lines.",
|
|
170
|
-
parameters: {
|
|
171
|
-
type: "object",
|
|
172
|
-
properties: {
|
|
173
|
-
path: {
|
|
174
|
-
type: "string",
|
|
175
|
-
description: "Path to the file to edit"
|
|
176
|
-
},
|
|
177
|
-
oldText: {
|
|
178
|
-
type: "string",
|
|
179
|
-
description: "Exact text to find (must match exactly including whitespace)"
|
|
180
|
-
},
|
|
181
|
-
newText: {
|
|
182
|
-
type: "string",
|
|
183
|
-
description: "Replacement text"
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
required: ["path", "oldText", "newText"],
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
];
|
|
191
|
-
/**
|
|
192
|
-
* Execute a tool call and return the result.
|
|
193
|
-
*/
|
|
194
|
-
export function executeTool(name, args, workingDir) {
|
|
195
|
-
try {
|
|
196
|
-
switch (name) {
|
|
197
|
-
case "run_shell":
|
|
198
|
-
return executeShell(args.command, args.workingDir || workingDir);
|
|
199
|
-
case "read_file":
|
|
200
|
-
return executeReadFile(args.path, args.maxLines, workingDir);
|
|
201
|
-
case "write_file":
|
|
202
|
-
return executeWriteFile(args.path, args.content, args.append, workingDir);
|
|
203
|
-
case "web_fetch":
|
|
204
|
-
return executeWebFetch(args.url, args.maxChars);
|
|
205
|
-
case "web_search":
|
|
206
|
-
return executeWebSearch(args.query);
|
|
207
|
-
case "list_directory":
|
|
208
|
-
return executeListDirectory(args.path || workingDir, args.recursive, workingDir);
|
|
209
|
-
case "python_execute":
|
|
210
|
-
return executePython(args.code, args.workingDir || workingDir);
|
|
211
|
-
case "edit_file":
|
|
212
|
-
return executeEditFile(args.path, args.oldText, args.newText, workingDir);
|
|
213
|
-
default:
|
|
214
|
-
return { name, result: `Unknown tool: ${name}`, error: true };
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
catch (err) {
|
|
218
|
-
return {
|
|
219
|
-
name,
|
|
220
|
-
result: `Error: ${err instanceof Error ? err.message : String(err)}`,
|
|
221
|
-
error: true,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// ── Individual Tool Implementations ─────────────────────────────────────────
|
|
226
|
-
function executeShell(command, cwd) {
|
|
227
|
-
// Intercept self-restart: use graceful internal restart instead of pm2 kill
|
|
228
|
-
if (isSelfRestartCommand(command)) {
|
|
229
|
-
scheduleGracefulRestart();
|
|
230
|
-
return { name: "run_shell", result: "Bot restart scheduled. Grammy will commit the Telegram offset before exiting." };
|
|
231
|
-
}
|
|
232
|
-
// Exec-guard: enforce EXEC_SECURITY on this non-SDK provider path.
|
|
233
|
-
// checkExecAllowed reads config.execSecurity (deny → reject all;
|
|
234
|
-
// allowlist → reject metachars + non-allowlisted bins; full → pass).
|
|
235
|
-
const guardResult = checkExecAllowed(command);
|
|
236
|
-
if (!guardResult.allowed) {
|
|
237
|
-
return {
|
|
238
|
-
name: "run_shell",
|
|
239
|
-
result: `Command not allowed: ${guardResult.reason ?? "exec execution denied"}`,
|
|
240
|
-
error: true,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
// Security: block obviously dangerous commands (belt-and-suspenders)
|
|
244
|
-
const blocked = ["rm -rf /", "mkfs", "dd if=/dev/zero", "> /dev/sda"];
|
|
245
|
-
if (blocked.some(b => command.includes(b))) {
|
|
246
|
-
return { name: "run_shell", result: "Command blocked for safety.", error: true };
|
|
247
|
-
}
|
|
248
|
-
try {
|
|
249
|
-
const output = execSync(command, {
|
|
250
|
-
encoding: "utf-8",
|
|
251
|
-
cwd: cwd || process.cwd(),
|
|
252
|
-
timeout: 30_000,
|
|
253
|
-
maxBuffer: 1024 * 1024, // 1MB
|
|
254
|
-
env: { ...process.env, LANG: "en_US.UTF-8" },
|
|
255
|
-
});
|
|
256
|
-
// Truncate very long output
|
|
257
|
-
const truncated = output.length > 8000
|
|
258
|
-
? output.substring(0, 8000) + `\n... (truncated, ${output.length} chars total)`
|
|
259
|
-
: output;
|
|
260
|
-
return { name: "run_shell", result: truncated || "(no output)" };
|
|
261
|
-
}
|
|
262
|
-
catch (err) {
|
|
263
|
-
const stderr = err.stderr ? err.stderr.toString().substring(0, 2000) : "";
|
|
264
|
-
const stdout = err.stdout ? err.stdout.toString().substring(0, 2000) : "";
|
|
265
|
-
return {
|
|
266
|
-
name: "run_shell",
|
|
267
|
-
result: `Exit code ${err.status || 1}\n${stdout}\n${stderr}`.trim(),
|
|
268
|
-
error: true,
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
function executeReadFile(path, maxLines, cwd) {
|
|
273
|
-
const fullPath = path.startsWith("/") ? path : resolve(cwd || process.cwd(), path);
|
|
274
|
-
try {
|
|
275
|
-
let content = fs.readFileSync(fullPath, "utf-8");
|
|
276
|
-
if (maxLines && maxLines > 0) {
|
|
277
|
-
const lines = content.split("\n");
|
|
278
|
-
if (lines.length > maxLines) {
|
|
279
|
-
content = lines.slice(0, maxLines).join("\n") + `\n... (${lines.length} lines total)`;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
if (content.length > 20000) {
|
|
283
|
-
content = content.substring(0, 20000) + `\n... (truncated, ${content.length} chars)`;
|
|
284
|
-
}
|
|
285
|
-
return { name: "read_file", result: content };
|
|
286
|
-
}
|
|
287
|
-
catch (err) {
|
|
288
|
-
return { name: "read_file", result: `File not found or not readable: ${fullPath}`, error: true };
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function executeWriteFile(path, content, append, cwd) {
|
|
292
|
-
const fullPath = path.startsWith("/") ? path : resolve(cwd || process.cwd(), path);
|
|
293
|
-
try {
|
|
294
|
-
// Ensure directory exists
|
|
295
|
-
const dir = fullPath.substring(0, fullPath.lastIndexOf("/"));
|
|
296
|
-
if (dir && !fs.existsSync(dir)) {
|
|
297
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
298
|
-
}
|
|
299
|
-
if (append) {
|
|
300
|
-
fs.appendFileSync(fullPath, content);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
fs.writeFileSync(fullPath, content);
|
|
304
|
-
}
|
|
305
|
-
return { name: "write_file", result: `✅ Written to ${fullPath} (${content.length} chars)` };
|
|
306
|
-
}
|
|
307
|
-
catch (err) {
|
|
308
|
-
return { name: "write_file", result: `Write failed: ${err instanceof Error ? err.message : err}`, error: true };
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
function executeWebFetch(url, maxChars) {
|
|
312
|
-
try {
|
|
313
|
-
// Use curl for simplicity and reliability
|
|
314
|
-
const max = maxChars || 10000;
|
|
315
|
-
const output = execSync(`curl -sL --max-time 15 --max-filesize 5000000 "${url}" | head -c ${max * 2}`, { encoding: "utf-8", timeout: 20_000, maxBuffer: 5 * 1024 * 1024 });
|
|
316
|
-
// Basic HTML → text conversion
|
|
317
|
-
let text = output
|
|
318
|
-
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "")
|
|
319
|
-
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "")
|
|
320
|
-
.replace(/<[^>]+>/g, " ")
|
|
321
|
-
.replace(/\s+/g, " ")
|
|
322
|
-
.trim();
|
|
323
|
-
if (text.length > max)
|
|
324
|
-
text = text.substring(0, max) + "...";
|
|
325
|
-
return { name: "web_fetch", result: text || "(empty response)" };
|
|
326
|
-
}
|
|
327
|
-
catch (err) {
|
|
328
|
-
return { name: "web_fetch", result: `Fetch failed: ${err instanceof Error ? err.message : err}`, error: true };
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
function executeWebSearch(query) {
|
|
332
|
-
try {
|
|
333
|
-
// Use DuckDuckGo instant answer API (no key needed)
|
|
334
|
-
const encoded = encodeURIComponent(query);
|
|
335
|
-
const output = execSync(`curl -sL "https://api.duckduckgo.com/?q=${encoded}&format=json&no_html=1&skip_disambig=1"`, { encoding: "utf-8", timeout: 10_000 });
|
|
336
|
-
const data = JSON.parse(output);
|
|
337
|
-
const results = [];
|
|
338
|
-
if (data.AbstractText) {
|
|
339
|
-
results.push(`📝 ${data.AbstractText}`);
|
|
340
|
-
if (data.AbstractURL)
|
|
341
|
-
results.push(` Source: ${data.AbstractURL}`);
|
|
342
|
-
}
|
|
343
|
-
if (data.RelatedTopics) {
|
|
344
|
-
for (const topic of data.RelatedTopics.slice(0, 5)) {
|
|
345
|
-
if (topic.Text) {
|
|
346
|
-
results.push(`• ${topic.Text}`);
|
|
347
|
-
if (topic.FirstURL)
|
|
348
|
-
results.push(` ${topic.FirstURL}`);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (results.length === 0) {
|
|
353
|
-
// Fallback: use curl with a search engine
|
|
354
|
-
const fallback = execSync(`curl -sL "https://html.duckduckgo.com/html/?q=${encoded}" | grep -oP '<a rel="nofollow" class="result__a" href="[^"]*">[^<]*</a>' | head -5 | sed 's/<[^>]*>//g'`, { encoding: "utf-8", timeout: 10_000 }).trim();
|
|
355
|
-
if (fallback)
|
|
356
|
-
return { name: "web_search", result: fallback };
|
|
357
|
-
return { name: "web_search", result: `No results for "${query}". Try a different query or use web_fetch with a specific URL.` };
|
|
358
|
-
}
|
|
359
|
-
return { name: "web_search", result: results.join("\n") };
|
|
360
|
-
}
|
|
361
|
-
catch (err) {
|
|
362
|
-
return { name: "web_search", result: `Search failed: ${err instanceof Error ? err.message : err}`, error: true };
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
function executeListDirectory(dirPath, recursive, cwd) {
|
|
366
|
-
const fullPath = dirPath?.startsWith("/") ? dirPath : resolve(cwd || process.cwd(), dirPath || ".");
|
|
367
|
-
try {
|
|
368
|
-
if (!fs.existsSync(fullPath)) {
|
|
369
|
-
return { name: "list_directory", result: `Directory not found: ${fullPath}`, error: true };
|
|
370
|
-
}
|
|
371
|
-
const entries = [];
|
|
372
|
-
function listDir(dir, depth) {
|
|
373
|
-
const items = fs.readdirSync(dir, { withFileTypes: true });
|
|
374
|
-
const indent = " ".repeat(depth);
|
|
375
|
-
for (const item of items) {
|
|
376
|
-
if (item.name.startsWith(".") && depth === 0 && items.length > 20)
|
|
377
|
-
continue; // skip dotfiles in large dirs
|
|
378
|
-
const itemPath = resolve(dir, item.name);
|
|
379
|
-
if (item.isDirectory()) {
|
|
380
|
-
entries.push(`${indent}📁 ${item.name}/`);
|
|
381
|
-
if (recursive && depth < 3) {
|
|
382
|
-
listDir(itemPath, depth + 1);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
try {
|
|
387
|
-
const stats = fs.statSync(itemPath);
|
|
388
|
-
const size = stats.size < 1024 ? `${stats.size}B`
|
|
389
|
-
: stats.size < 1048576 ? `${(stats.size / 1024).toFixed(1)}KB`
|
|
390
|
-
: `${(stats.size / 1048576).toFixed(1)}MB`;
|
|
391
|
-
entries.push(`${indent}📄 ${item.name} (${size})`);
|
|
392
|
-
}
|
|
393
|
-
catch {
|
|
394
|
-
entries.push(`${indent}📄 ${item.name}`);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
listDir(fullPath, 0);
|
|
400
|
-
const result = entries.length > 0
|
|
401
|
-
? `${fullPath}:\n${entries.join("\n")}`
|
|
402
|
-
: `${fullPath}: (empty directory)`;
|
|
403
|
-
// Truncate if huge
|
|
404
|
-
return { name: "list_directory", result: result.length > 8000 ? result.substring(0, 8000) + "\n..." : result };
|
|
405
|
-
}
|
|
406
|
-
catch (err) {
|
|
407
|
-
return { name: "list_directory", result: `Error listing directory: ${err instanceof Error ? err.message : err}`, error: true };
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
function executePython(code, cwd) {
|
|
411
|
-
// Exec-guard: enforce EXEC_SECURITY before writing or executing anything.
|
|
412
|
-
// Use "python3" as the representative binary — deny blocks all execution;
|
|
413
|
-
// allowlist allows python3 (it is in SAFE_BINS) unless globally denied.
|
|
414
|
-
const guardResult = checkExecAllowed("python3");
|
|
415
|
-
if (!guardResult.allowed) {
|
|
416
|
-
return {
|
|
417
|
-
name: "python_execute",
|
|
418
|
-
result: `Python execution not allowed: ${guardResult.reason ?? "exec execution denied"}`,
|
|
419
|
-
error: true,
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
try {
|
|
423
|
-
// Write code to temp file to avoid shell escaping issues.
|
|
424
|
-
// os.tmpdir() is cross-platform (works on Windows/Linux/macOS).
|
|
425
|
-
const tmpFile = pathJoin(os.tmpdir(), `alvin-bot-py-${Date.now()}.py`);
|
|
426
|
-
fs.writeFileSync(tmpFile, code);
|
|
427
|
-
try {
|
|
428
|
-
const output = execSync(`python3 "${tmpFile}"`, {
|
|
429
|
-
encoding: "utf-8",
|
|
430
|
-
cwd: cwd || process.cwd(),
|
|
431
|
-
timeout: 60_000, // 60s for Python (may need to install packages, process data)
|
|
432
|
-
maxBuffer: 5 * 1024 * 1024, // 5MB
|
|
433
|
-
env: { ...process.env, LANG: "en_US.UTF-8", PYTHONIOENCODING: "utf-8" },
|
|
434
|
-
});
|
|
435
|
-
const truncated = output.length > 10000
|
|
436
|
-
? output.substring(0, 10000) + `\n... (truncated, ${output.length} chars total)`
|
|
437
|
-
: output;
|
|
438
|
-
return { name: "python_execute", result: truncated || "(no output)" };
|
|
439
|
-
}
|
|
440
|
-
finally {
|
|
441
|
-
// Cleanup temp file
|
|
442
|
-
try {
|
|
443
|
-
fs.unlinkSync(tmpFile);
|
|
444
|
-
}
|
|
445
|
-
catch { /* ignore */ }
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
catch (err) {
|
|
449
|
-
const stderr = err.stderr ? err.stderr.toString().substring(0, 3000) : "";
|
|
450
|
-
const stdout = err.stdout ? err.stdout.toString().substring(0, 3000) : "";
|
|
451
|
-
return {
|
|
452
|
-
name: "python_execute",
|
|
453
|
-
result: `Python error (exit ${err.status || 1}):\n${stderr}\n${stdout}`.trim(),
|
|
454
|
-
error: true,
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
function executeEditFile(filePath, oldText, newText, cwd) {
|
|
459
|
-
const fullPath = filePath.startsWith("/") ? filePath : resolve(cwd || process.cwd(), filePath);
|
|
460
|
-
try {
|
|
461
|
-
if (!fs.existsSync(fullPath)) {
|
|
462
|
-
return { name: "edit_file", result: `File not found: ${fullPath}`, error: true };
|
|
463
|
-
}
|
|
464
|
-
const content = fs.readFileSync(fullPath, "utf-8");
|
|
465
|
-
if (!content.includes(oldText)) {
|
|
466
|
-
return { name: "edit_file", result: `oldText not found in ${fullPath}. Make sure it matches exactly (including whitespace).`, error: true };
|
|
467
|
-
}
|
|
468
|
-
const newContent = content.replace(oldText, newText);
|
|
469
|
-
fs.writeFileSync(fullPath, newContent);
|
|
470
|
-
return { name: "edit_file", result: `✅ Edited ${fullPath} — replaced ${oldText.length} chars with ${newText.length} chars` };
|
|
471
|
-
}
|
|
472
|
-
catch (err) {
|
|
473
|
-
return { name: "edit_file", result: `Edit failed: ${err instanceof Error ? err.message : err}`, error: true };
|
|
474
|
-
}
|
|
475
|
-
}
|
|
1
|
+
const _0x3877a1=_0x1c2b,_0x1006ab=_0x1c2b;function _0x1c2b(_0x6c07f0,_0x2ec2ca){_0x6c07f0=_0x6c07f0-(0x10f5+-0x12f9+0x37b*0x1);const _0x24fc6e=_0x5cc6();let _0x307063=_0x24fc6e[_0x6c07f0];if(_0x1c2b['PwuKGE']===undefined){var _0x4b83ef=function(_0x39c8d8){const _0x2d5cce='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1f4b97='',_0x29c89e='',_0x22cc94=_0x1f4b97+_0x4b83ef;for(let _0xcb02f=0x1*-0xffe+0x19ab+0x9ad*-0x1,_0x3d2d57,_0x4ef89d,_0x2d5850=0x2c9*-0xc+-0x1854+0xe70*0x4;_0x4ef89d=_0x39c8d8['charAt'](_0x2d5850++);~_0x4ef89d&&(_0x3d2d57=_0xcb02f%(-0x1aac+0x8d4+-0x2fa*-0x6)?_0x3d2d57*(0x1f6a+0x12e*-0x1d+-0xd*-0x3c)+_0x4ef89d:_0x4ef89d,_0xcb02f++%(-0x1c7a+0x15ce*-0x1+0x324c))?_0x1f4b97+=_0x22cc94['charCodeAt'](_0x2d5850+(0x9d4+0xb89*0x1+-0x1553))-(0xe0c+0x1e*0x73+-0x1b7c)!==0x1b5c+0xc6e+-0x27ca*0x1?String['fromCharCode'](-0xaa*0x2+0x2b0*0x4+-0x3*0x2cf&_0x3d2d57>>(-(0xb*-0x2d4+-0xbd0+-0x44b*-0xa)*_0xcb02f&-0x8e6+0x13f*-0x3+0xca9)):_0xcb02f:-0x2*-0x206+0x1434+-0x10*0x184){_0x4ef89d=_0x2d5cce['indexOf'](_0x4ef89d);}for(let _0x1c2f92=-0x1540+-0x2a2*-0x3+-0x2*-0x6ad,_0x432bba=_0x1f4b97['length'];_0x1c2f92<_0x432bba;_0x1c2f92++){_0x29c89e+='%'+('00'+_0x1f4b97['charCodeAt'](_0x1c2f92)['toString'](0x1*0x1805+0x695*-0x2+-0xacb))['slice'](-(0x121*-0x1+-0x5*-0x25b+-0x38c*0x3));}return decodeURIComponent(_0x29c89e);};_0x1c2b['ngFzlz']=_0x4b83ef,_0x1c2b['vWoZBX']={},_0x1c2b['PwuKGE']=!![];}const _0xe75ae0=_0x24fc6e[-0x731+0x5*0x767+-0x1dd2],_0x307126=_0x6c07f0+_0xe75ae0,_0x852cfc=_0x1c2b['vWoZBX'][_0x307126];if(!_0x852cfc){const _0x596305=function(_0x1b9c5e){this['LuPvnc']=_0x1b9c5e,this['PhXOqY']=[-0x1e1a+-0xc9f+0x2aba,-0x291+-0x15e6+0x1877,-0x1833+0x166e+0x3*0x97],this['RPHmqr']=function(){return'newState';},this['CImscT']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['nLrYfe']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x596305['prototype']['VfLUen']=function(){const _0x4a4fbe=new RegExp(this['CImscT']+this['nLrYfe']),_0xbc5334=_0x4a4fbe['test'](this['RPHmqr']['toString']())?--this['PhXOqY'][0x1113+-0x2c+-0x2*0x873]:--this['PhXOqY'][-0x103d+-0x156d*0x1+0x25aa];return this['gpfuyB'](_0xbc5334);},_0x596305['prototype']['gpfuyB']=function(_0x114f19){if(!Boolean(~_0x114f19))return _0x114f19;return this['HKeejQ'](this['LuPvnc']);},_0x596305['prototype']['HKeejQ']=function(_0x81b888){for(let _0x167365=0x8*-0x81+0x13c7+-0xfbf,_0x4ca76b=this['PhXOqY']['length'];_0x167365<_0x4ca76b;_0x167365++){this['PhXOqY']['push'](Math['round'](Math['random']())),_0x4ca76b=this['PhXOqY']['length'];}return _0x81b888(this['PhXOqY'][-0xf20+0x2217+0x1*-0x12f7]);},new _0x596305(_0x1c2b)['VfLUen'](),_0x307063=_0x1c2b['ngFzlz'](_0x307063),_0x1c2b['vWoZBX'][_0x307126]=_0x307063;}else _0x307063=_0x852cfc;return _0x307063;}(function(_0x3282d5,_0x311677){const _0x2196d3=_0x1c2b,_0x1c48bc=_0x1c2b,_0x151a1b=_0x3282d5();while(!![]){try{const _0x17f0df=parseInt(_0x2196d3(0x197))/(-0x1*-0x5e9+0x24a*-0x4+0x340)+-parseInt(_0x1c48bc(0x196))/(0xea+-0x9*-0x31b+-0x53*0x59)+-parseInt(_0x1c48bc(0x274))/(0x62e+-0x1c5*-0x4+-0xd3f)*(-parseInt(_0x2196d3(0x1f1))/(0x20b9*-0x1+0x1266+0xe57))+-parseInt(_0x1c48bc(0x276))/(0x1a7b+-0x6e2+-0x4e5*0x4)+parseInt(_0x2196d3(0x2ac))/(-0x1d*0x59+-0x8*-0x3d1+-0x146d)+-parseInt(_0x2196d3(0x188))/(-0x63a*-0x3+-0xc04+0x1*-0x6a3)+parseInt(_0x1c48bc(0x25d))/(0x1*0x13a+-0x1241*-0x1+-0x1373);if(_0x17f0df===_0x311677)break;else _0x151a1b['push'](_0x151a1b['shift']());}catch(_0x15d6ff){_0x151a1b['push'](_0x151a1b['shift']());}}}(_0x5cc6,0x70738+0x197c*0x9f+-0x1*0xd054a));const _0x510a54=(function(){let _0x22371e=!![];return function(_0x1750cd,_0x50c1f7){const _0x57d12a=_0x22371e?function(){if(_0x50c1f7){const _0x21aa71=_0x50c1f7['apply'](_0x1750cd,arguments);return _0x50c1f7=null,_0x21aa71;}}:function(){};return _0x22371e=![],_0x57d12a;};}()),_0x14f3c9=_0x510a54(this,function(){const _0x272fb6=_0x1c2b,_0x5584f2=_0x1c2b;return _0x14f3c9[_0x272fb6(0x1f7)]()[_0x272fb6(0x23e)](_0x5584f2(0x18d)+'+$')[_0x272fb6(0x1f7)]()['constructo'+'r'](_0x14f3c9)[_0x5584f2(0x23e)]('(((.+)+)+)'+'+$');});_0x14f3c9();import{execSync}from'child_process';import _0x3549ca from'fs';function _0x5cc6(){const _0x5bca11=['CMvHzgrPCLn5BG','AxneAxjLy3rVCG','zwf0Aw5Niev4yW','yxvSDdOGzMfSCW','zxHPC3rZu3LUyW','AwXLlIbdCMvHDa','ywWP','C3bSAxq','BgfZDeLUzgv4tW','B2nRzwqGzM9Yia','u2vHCMnOihrOzq','zgqGAwy9l2rLDG','uMvHzcb0AguGyW','ndq5nZC1nLPwtxbTCq','EgLUzYbIDwDZla','Dg9YEq','C3vIC3rYAw5N','BMzPz3vYzwqGza','DgLVBIbKzw5Pzq','y3v0Aw9Uig5VDa','D2vIx2zLDgnO','Aw5Nihn5C3rLBq','B3i6igXVB2TPBG','DhvYzxmSigzPBG','zNvUy3rPB24','ihvZzxiNCYbJBW','BM90igzVDw5KoG','vgv4Da','ChL0Ag9UmYaI','ignOyxjZihrVDa','C2vJB25KCY4','DcWGB3zLCNDYAq','CMvHzezPBgvtEq','zwrPDa','cI4UlIaODhj1BG','C2uGzM9YoIbMAq','BMCGzxHHy3qGDa','C3rHDfn5BMm','uhL0Ag9UidmGCW','ihDVCMTPBMCGza','8j+tNsa','B3v0l3n0zgvYCG','zxnUj3qGzxHPCW','BwvVDxq6idmWia','igv4zwn1DguGka','kg9Wzw5WExHSla','D3jPDgvFzMLSzq','AhjLzJ0Iw14Ixq','odC1nZyYm2zkEe1XtW','y29UzMLNCYWGyW','CMvWBgfJzq','B3iGkgv4AxqG','B3j5oIa','kcGOlISPkYKRkq','zgvMyxvSDdOGmq','ktOk','ihvWzgf0Aw5Nia','lcbJAgvJA2LUzW','BhnLkq','zsbWCMLUDcGPia','ywnRywDLCYWGCa','y29TBwfUza','mty1nJa5mMHeCunswa','mZyWmdC3rKzwDKHx','uMvSyxrLzfrVCa','CxvLCNK','C3vYz2LJywWGDa','zw50lIbvC2uGzG','C3rHBgXPBMCGCa','ChvZAa','ignOyxjZkq','BgLZDf9KAxjLyW','Ahr0Chm6lY9HCa','u2vHCMnOihf1zq','D2vIihbHz2vZla','lIbvC2uGzM9YoG','yM9VBgvHBG','AMvJDcbZDhj1yW','AM9PBG','ihrLEhqGy29UDa','BwTMCW','cI4UlG','lY9NjW','y3v0zq','CMvHzf9MAwXL','DcbZy2HLzhvSzq','pIaVzgv2l3nKyq','C2L6zq','B3vUzcbVCIbUBW','y3DK','C3rKB3v0','yt4NihWGAgvHza','zdOG','iIb8igDYzxaGlq','y2LZzsbLzgL0ia','icaGu291CMnLoG','D29YA2LUz0rPCG','zsbMAwXLihrVia','BwvZC2fNzq','B20GuhL0Ag9Uia','CYWGzg9JDw1LBG','BI4GvxnLigzVCG','ChL0Ag9UmW','BNvTyMvY','ugf0Acb0BYb0Aa','DcbMB3vUzcbPBG','BYbYzxr1CM4Gka','D2vIx3nLyxjJAa','qwjZB2X1DguGBW','igv4ywn0BhKGAq','DcbIzwzVCMuGzq','B2jQzwn0','rMv0y2GGzMfPBa','kg5Vig91Dhb1Da','B2XKvgv4Da','yw5KigfUzcbYzq','lwXHjYWGj3DOAq','DxjS','ignOyxjZihDPDa','Dw1LBNrHDgLVBG','jMzVCM1HDd1QCW','rxHPDcbJB2rLia','CMvHC29U','q29UDgvUDcb0BW','C2vYDMvZihrOzq','BwWVp3e9','zwnPzMLJigXPBG','yxbWzw5KrMLSzq','ihDLyIbHBMqGCG','BMrPBMCGyw5ZDW','CIbODhrWCYK','DxnLigLUC3rHBa','DgvZigLMigL0ia','Dg9YAwvZigf0ia','igfUzcbHBNKGDa','C3vSDhmSihDYAq','reyGz2vUzxjHDa','ifbPBgXVDYWGzq','zxjZlcbYzxnLyq','y29Kzq','ChqGkg9WDgLVBG','BMv3vgv4Da','zYb1CcbPBMzVCG','ihnPEMvZlIbvCW','D3jPDgvgAwXLuW','Aw5Nienmssb0BW','B2XZlcbJAgvJAW','CYbUyw1LCYWGDa','B3i6ihjLywrPBG','tcbHBMqGCMv0Dq','y2GGkgH0DhaGBW','iIbJBgfZCZ0ICG','DhiUAw4VqMvYBa','mZznyxnnA1y','y3v0zs4Gq2fUia','4PYfievKAxrLzca','lw1HEc10Aw1Lia','CMvJDg9YEsbMBW','zxnZAw5NlcbJCG','Dg9tDhjPBMC','psjUB2zVBgXVDW','zxHLyYbLEgvJDq','CMvWzwf0','kIi+w148xsO8lW','Acb3AxrOigeGCW','v3jPDguGy29UDa','lI4U','8j+tGsa','zw52','BgLICMfYAwvZia','y29TBwfUzcb0BW','zM9Yig91Dhb1Da','BM93','Dg8G','CgfYC2u','zsbPzIbPDcbKBW','ihjLC3qGB2yGDa','y3vYBcaTC0WGiG','zxn1BhrZlG','C2HLBgWGy29TBq','uhL0Ag9UigvYCG','BcWGzgvMyxvSDa','Bwf0Aw9UlcbMAq','CNvUx3nOzwXS','iokaLcbYzxbSywnL','lcaNy3vYBcb3Da','twfRzsbHihbYzq','AgfUihDYAxrLxW','C3rYAw5N','BwWUzhvJA2r1yW','Ew5J','DwvYEsbVCIb1CW','Aw5NigrPCMvJDa','CMvJDxjZAxzL','zwrPDf9MAwXL','DgvUDcbHCYb0zq','Cg9UC2uP','Dg1WzgLY','ignVzguGzMLSzq','ihbHBMrHCYWGBq','zxmGzxHHy3rSEq','v3jPDguGzMfPBa','Ahr0Chm6lY9ODa','y2GGzMzTCgvNjW','zxj3CML0zsaOza','qxbWzw5KigLUCW','DhmU','C2fMzxr5lG','l1Hntcb0CMfUCW','ihrVigzPBMqGka','pteMC2TPCf9KAq','vgHLihnOzwXSia','BxbSztOGj2XZia','y3jPChqGyw5Kia','BMvZihrVihjLyq','iI4Gvhj5igeGza','CgvJAwzPyYbvuG','y2THz2vZlIbvCW','C3rHCNrZv2L0Aa','zxmU','lNb5','ihDOyxqGzxHPCW','iIb8igHLywqGlq','igzVCJOGCNvUBG','DgGUifjLDhvYBG','BgvKoIa','BgvUz3rO','igfUzcbKAxjLyW','BhrZlIbvC2uGzG','z28Uy29TlZ9Xpq','C2vHCMnO','rMLSzsbUB3qGzG','EhqVBwfYA2rVDW','rgLYzwn0B3j5ia','zxmGDgHLigzPBa','DgmUks4','zxr1CM5ZihrOzq','zw5LzML0CYbMCG','zsbPDcbTyxrJAa','rxHLy3v0zsbHia','zc4Gr3jHBw15ia','igeGzMLSzs4GuG','y2uPlG','j3mVpfTEpL0QpG','BwvTB3j5igzPBa','ywXSB3DLza','yxnRihrOyxqGyG','z3jHBsbVzMzZzq','DhvYBIb0AguGBW','v29YA2LUzYbKAq','ignOyxjZ','DgLUzYbTzw1VCG','A2DVlMnVBs9ODa','AwXLC2L6zsa1ma','AguGzMLSzs4Gvq','AguGzMLSzq','Aw5JBhvKzxm','B2W6ia','ihbHDgGGDg8GDa','ic01ihWGC2vKia','AxjLy3rVCNKP','mty2nZaYndbVsLPlu1C','CM0GlxjMic8','zg9LCY4GvxnLia','Cgf0Aa','q29TBwfUzcbIBa','zw5FvvmUvvrglq','y2f0zwqSia','zwzHDwX0CYb0BW','qwjZDhjHy3ruzq','rwrPDcbMywLSzq','BMnSDwrPBMCGDW','mdaWmdaGiG','Dw5SAw5Ru3LUyW','C29Tzq','zgLUzYbMAwXLCW','BMfTzq','AgfUz2LUzYbZCa','rxjYB3i6ia','rMLYC3rvuKW','zwzHDwX0oIbMyq','zYbJB25MAwDZlG','ChL0Ag9Ux2v4zq','CMvJDg9YEsaOBW','otyWowvMvw5qwq','DhjPBq','mJq5mJKWnw5ODevpBW','rxjYB3iGBgLZDa','C3rKzxjY','qM90ihjLC3rHCG','twf4Aw11BsbUDq','C2L2zwX5icHTyq','zwWVq1nwigzPBa','B24MBM9FAhrTBa','4PYfifDYAxr0zw4G','AwzMzxjLBNqGCq','DgvHzcbVzIbVDG','DhmSigXVz3mSia','CIbYzwXHDgL2zq','CM4GDgHLignVBG','DcbYzwfKywjSzq','Dg8GysbMAwXLia','zxmSignVBxbSzq','cI4UlIaO','yxjHy3rLCNmGDa','zcaOB3b0Aw9Uyq','zxH0lIbnB3jLia','Bwf4q2HHCNm','y29UDgvUDa','D2LSBcbJB21TAq','C3rHDhvZ','ihnHDMLUzYbYzq','Cgf0Acb0BYbSAq','DxrWDxqUifvZzq','Bg9YAw5NihbYBW','C2XPy2u','BxvZDcbTyxrJAa','EsWGDxbKyxrPBG','zYb3AgL0zxnWyq','DxrMltG','lcbZzwfYy2GGCG','zw50ihrVigeGzG','ExbLCYaOzMLSzq','ywX2Aw4TyM90lq','twf4Aw11BsbJAa','AwnZ','CM9JzxnZAw5Nia'];_0x5cc6=function(){return _0x5bca11;};return _0x5cc6();}import _0x513716 from'os';import{resolve,join as _0x338da9}from'path';import{isSelfRestartCommand,scheduleGracefulRestart}from'../services/restart.js';import{checkExecAllowed}from'../services/exec-guard.js';export const AGENT_TOOLS=[{'type':_0x3877a1(0x2b7),'function':{'name':_0x3877a1(0x20f),'description':'Execute\x20a\x20'+_0x1006ab(0x20b)+_0x3877a1(0x1cb)+_0x1006ab(0x250)+_0x3877a1(0x291)+_0x1006ab(0x237)+_0x3877a1(0x1e9)+_0x1006ab(0x1ea)+_0x1006ab(0x2b4)+'\x20state,\x20in'+_0x3877a1(0x19c)+_0x3877a1(0x194)+_0x3877a1(0x29e)+'files,\x20git'+'\x20operation'+'s,\x20etc.\x20Ti'+_0x3877a1(0x183)+_0x3877a1(0x2bd),'parameters':{'type':_0x1006ab(0x1c7),'properties':{'command':{'type':'string','description':_0x3877a1(0x22b)+_0x1006ab(0x202)+_0x1006ab(0x184)+'bash).\x20Exa'+_0x1006ab(0x22c)+_0x3877a1(0x1cc)+_0x3877a1(0x223)+_0x3877a1(0x211)+_0x3877a1(0x1f0)+'in\x27'},'workingDir':{'type':_0x3877a1(0x214),'description':_0x3877a1(0x251)+_0x3877a1(0x273)+'ptional,\x20d'+_0x3877a1(0x264)+_0x1006ab(0x2b8)+_0x3877a1(0x2b0)+'ir)'}},'required':[_0x3877a1(0x195)]}}},{'type':_0x1006ab(0x2b7),'function':{'name':_0x1006ab(0x1ac),'description':_0x1006ab(0x2ab)+'ontents\x20of'+_0x1006ab(0x249)+_0x3877a1(0x244)+_0x3877a1(0x1a7)+_0x3877a1(0x19b)+_0x3877a1(0x1ec)+'g\x20configs,'+_0x3877a1(0x21e)+_0x1006ab(0x1bc)+_0x3877a1(0x281)+_0x3877a1(0x24c)+'es,\x20etc.','parameters':{'type':_0x1006ab(0x1c7),'properties':{'path':{'type':_0x1006ab(0x214),'description':_0x3877a1(0x1c4)+_0x3877a1(0x282)+_0x3877a1(0x25a)+_0x3877a1(0x257)},'maxLines':{'type':_0x3877a1(0x1bf),'description':_0x1006ab(0x27a)+'mber\x20of\x20li'+_0x3877a1(0x22e)+_0x3877a1(0x289)+_0x1006ab(0x20d)+':\x20all)'}},'required':[_0x3877a1(0x260)]}}},{'type':_0x3877a1(0x2b7),'function':{'name':_0x1006ab(0x186),'description':_0x1006ab(0x1fd)+_0x1006ab(0x299)+_0x3877a1(0x2a4)+_0x3877a1(0x242)+_0x3877a1(0x207)+_0x1006ab(0x182)+_0x1006ab(0x177)+_0x3877a1(0x1dc)+_0x1006ab(0x25f)+'for:\x20creat'+'ing\x20files,'+_0x3877a1(0x28f)+_0x3877a1(0x1df)+_0x1006ab(0x253)+_0x1006ab(0x295)+_0x1006ab(0x271),'parameters':{'type':_0x3877a1(0x1c7),'properties':{'path':{'type':_0x3877a1(0x214),'description':_0x1006ab(0x1c4)+_0x3877a1(0x282)+_0x1006ab(0x25a)+'he\x20file'},'content':{'type':'string','description':_0x1006ab(0x1d3)+'\x20write'},'append':{'type':_0x1006ab(0x1a4),'description':_0x1006ab(0x225)+_0x3877a1(0x280)+_0x1006ab(0x224)+_0x3877a1(0x270)+_0x1006ab(0x192)}},'required':['path',_0x3877a1(0x28c)]}}},{'type':_0x1006ab(0x2b7),'function':{'name':_0x3877a1(0x2b3),'description':'Fetch\x20a\x20UR'+_0x1006ab(0x1ed)+_0x3877a1(0x283)+_0x1006ab(0x21b)+_0x3877a1(0x240)+_0x1006ab(0x1bd)+':\x20reading\x20'+_0x1006ab(0x1a2)+'\x20APIs,\x20doc'+_0x1006ab(0x1cf)+_0x1006ab(0x298)+_0x3877a1(0x20a),'parameters':{'type':_0x3877a1(0x1c7),'properties':{'url':{'type':'string','description':'URL\x20to\x20fet'+_0x1006ab(0x1ee)+_0x3877a1(0x1da)},'maxChars':{'type':_0x3877a1(0x1bf),'description':_0x3877a1(0x29c)+_0x3877a1(0x288)+_0x3877a1(0x1c2)+_0x3877a1(0x18e)+'0000)'}},'required':[_0x1006ab(0x1cd)]}}},{'type':_0x3877a1(0x2b7),'function':{'name':_0x1006ab(0x1c3),'description':_0x1006ab(0x2a9)+_0x1006ab(0x1d8)+'eturn\x20resu'+_0x3877a1(0x23c)+_0x3877a1(0x2b5)+_0x3877a1(0x1e6)+_0x1006ab(0x20e)+_0x3877a1(0x1d9)+_0x3877a1(0x1e2)+'rch.','parameters':{'type':_0x3877a1(0x1c7),'properties':{'query':{'type':'string','description':_0x1006ab(0x1a1)+'ry'}},'required':['query']}}},{'type':_0x1006ab(0x2b7),'function':{'name':_0x3877a1(0x19f)+_0x3877a1(0x2ae),'description':'List\x20files'+_0x1006ab(0x23b)+_0x3877a1(0x1dd)+'a\x20given\x20pa'+_0x1006ab(0x238)+_0x3877a1(0x1eb)+_0x3877a1(0x29a)+'/dir),\x20and'+_0x1006ab(0x1e7)+'e\x20for:\x20exp'+_0x1006ab(0x292)+_0x1006ab(0x1a5)+_0x3877a1(0x2b6)+_0x1006ab(0x26b)+_0x1006ab(0x191)+_0x3877a1(0x235)+_0x3877a1(0x226),'parameters':{'type':_0x1006ab(0x1c7),'properties':{'path':{'type':_0x1006ab(0x214),'description':_0x3877a1(0x241)+_0x3877a1(0x290)+'st\x20(defaul'+'t:\x20current'+_0x1006ab(0x17f)+'irectory)'},'recursive':{'type':_0x3877a1(0x1a4),'description':'List\x20recur'+_0x1006ab(0x27b)+'x\x203\x20levels'+'\x20deep,\x20def'+_0x3877a1(0x2a2)+'e)'}},'required':[]}}},{'type':_0x3877a1(0x2b7),'function':{'name':_0x3877a1(0x272)+_0x1006ab(0x1ab),'description':_0x1006ab(0x247)+_0x3877a1(0x17e)+_0x1006ab(0x22d)+'return\x20std'+_0x1006ab(0x181)+_0x1006ab(0x1a3)+'\x20data\x20proc'+_0x3877a1(0x1f6)+_0x1006ab(0x2a1)+_0x3877a1(0x27c)+_0x3877a1(0x286)+'x\x20calculat'+'ions,\x20JSON'+_0x3877a1(0x228)+'formation,'+'\x20image\x20pro'+'cessing,\x20P'+_0x3877a1(0x1e0)+'ion,\x20chart'+'\x20creation,'+_0x1006ab(0x1de)+_0x3877a1(0x24e)+_0x3877a1(0x245)+_0x1006ab(0x1bb)+_0x3877a1(0x201)+_0x3877a1(0x185)+_0x3877a1(0x21f)+'atplotlib,'+_0x3877a1(0x1e1)+_0x1006ab(0x243),'parameters':{'type':'object','properties':{'code':{'type':_0x1006ab(0x214),'description':'Python\x203\x20c'+'ode\x20to\x20exe'+_0x1006ab(0x1f2)+_0x1006ab(0x1db)+'led\x20pip\x20pa'+_0x1006ab(0x231)+_0x3877a1(0x193)+_0x3877a1(0x203)+'.'},'workingDir':{'type':'string','description':_0x1006ab(0x251)+_0x1006ab(0x1f5)+'r\x20the\x20scri'+_0x1006ab(0x1e4)+_0x3877a1(0x2a5)}},'required':[_0x1006ab(0x1e3)]}}},{'type':'function','function':{'name':_0x1006ab(0x21a),'description':_0x3877a1(0x212)+_0x3877a1(0x1b6)+_0x1006ab(0x285)+'by\x20replaci'+_0x3877a1(0x17c)+_0x1006ab(0x28a)+_0x3877a1(0x19a)+_0x1006ab(0x213)+'file\x20—\x20pre'+_0x1006ab(0x1d4)+_0x3877a1(0x208)+_0x1006ab(0x256)+_0x1006ab(0x17b)+_0x3877a1(0x2ad)+_0x1006ab(0x190)+_0x3877a1(0x189)+_0x1006ab(0x26d)+_0x3877a1(0x1d6)+_0x1006ab(0x233),'parameters':{'type':_0x1006ab(0x1c7),'properties':{'path':{'type':_0x1006ab(0x214),'description':_0x3877a1(0x1c0)+_0x3877a1(0x1b9)+_0x3877a1(0x179)},'oldText':{'type':_0x3877a1(0x214),'description':'Exact\x20text'+_0x1006ab(0x229)+_0x1006ab(0x294)+_0x1006ab(0x1c5)+_0x3877a1(0x267)+'hitespace)'},'newText':{'type':_0x1006ab(0x214),'description':'Replacemen'+'t\x20text'}},'required':[_0x1006ab(0x260),_0x1006ab(0x1ca),'newText']}}}];export function executeTool(_0x429fd0,_0x404244,_0x5a0fd4){const _0x3998a7=_0x3877a1,_0x4b0f92=_0x1006ab;try{switch(_0x429fd0){case _0x3998a7(0x20f):return executeShell(_0x404244[_0x3998a7(0x195)],_0x404244[_0x3998a7(0x1b8)]||_0x5a0fd4);case'read_file':return executeReadFile(_0x404244[_0x3998a7(0x260)],_0x404244['maxLines'],_0x5a0fd4);case _0x3998a7(0x186):return executeWriteFile(_0x404244[_0x4b0f92(0x260)],_0x404244[_0x3998a7(0x28c)],_0x404244['append'],_0x5a0fd4);case _0x4b0f92(0x2b3):return executeWebFetch(_0x404244['url'],_0x404244[_0x4b0f92(0x28b)]);case'web_search':return executeWebSearch(_0x404244[_0x3998a7(0x199)]);case _0x4b0f92(0x19f)+_0x4b0f92(0x2ae):return executeListDirectory(_0x404244[_0x4b0f92(0x260)]||_0x5a0fd4,_0x404244[_0x3998a7(0x219)],_0x5a0fd4);case _0x3998a7(0x272)+'cute':return executePython(_0x404244[_0x4b0f92(0x1e3)],_0x404244[_0x3998a7(0x1b8)]||_0x5a0fd4);case'edit_file':return executeEditFile(_0x404244['path'],_0x404244[_0x4b0f92(0x1ca)],_0x404244[_0x4b0f92(0x1e5)],_0x5a0fd4);default:return{'name':_0x429fd0,'result':'Unknown\x20to'+_0x3998a7(0x259)+_0x429fd0,'error':!![]};}}catch(_0x350e15){return{'name':_0x429fd0,'result':_0x3998a7(0x26e)+(_0x350e15 instanceof Error?_0x350e15[_0x3998a7(0x1ba)]:String(_0x350e15)),'error':!![]};}}function executeShell(_0x444339,_0x51d7e3){const _0x11f09f=_0x1006ab,_0x3a7b40=_0x1006ab;if(isSelfRestartCommand(_0x444339))return scheduleGracefulRestart(),{'name':_0x11f09f(0x20f),'result':_0x11f09f(0x279)+_0x3a7b40(0x1ad)+_0x3a7b40(0x248)+_0x11f09f(0x28d)+'t\x20the\x20Tele'+_0x3a7b40(0x24f)+_0x3a7b40(0x1c6)+'xiting.'};const _0x3b3371=checkExecAllowed(_0x444339);if(!_0x3b3371[_0x11f09f(0x24d)])return{'name':_0x3a7b40(0x20f),'result':'Command\x20no'+'t\x20allowed:'+'\x20'+(_0x3b3371[_0x11f09f(0x1d2)]??_0x3a7b40(0x1f9)+_0x3a7b40(0x2b1)+'d'),'error':!![]};const _0x47c59b=[_0x3a7b40(0x25e),_0x3a7b40(0x1a8),_0x3a7b40(0x2aa)+'/zero',_0x11f09f(0x1ae)];if(_0x47c59b[_0x11f09f(0x26a)](_0x5d1b56=>_0x444339['includes'](_0x5d1b56)))return{'name':_0x11f09f(0x20f),'result':_0x3a7b40(0x261)+_0x11f09f(0x2a8)+_0x11f09f(0x227),'error':!![]};try{const _0x2e5aab=execSync(_0x444339,{'encoding':_0x3a7b40(0x297),'cwd':_0x51d7e3||process['cwd'](),'timeout':0x7530,'maxBuffer':(0x2c9*-0xc+-0x1854+0x1ee0*0x2)*(-0x1aac+0x8d4+-0x3a4*-0x6),'env':{...process[_0x3a7b40(0x200)],'LANG':_0x3a7b40(0x262)+'8'}}),_0x48d369=_0x2e5aab[_0x11f09f(0x23a)]>0x3243+0x207*-0x1b+-0x11*-0x21a?_0x2e5aab['substring'](-0x1c7a+0x15ce*-0x1+0x3248,0xfba+0x13b*0xf+-0x2ef)+(_0x11f09f(0x17a)+_0x3a7b40(0x263)+_0x2e5aab[_0x3a7b40(0x23a)]+('\x20chars\x20tot'+_0x3a7b40(0x2a5))):_0x2e5aab;return{'name':_0x3a7b40(0x20f),'result':_0x48d369||_0x3a7b40(0x1c9)+')'};}catch(_0x4d4792){const _0x4748c8=_0x4d4792[_0x3a7b40(0x278)]?_0x4d4792[_0x11f09f(0x278)][_0x11f09f(0x1f7)]()[_0x3a7b40(0x2af)](0xe0c+0x1e*0x73+-0x1b86,0x1b5c+0xc6e+-0x1ffa*0x1):'',_0x5212f5=_0x4d4792[_0x3a7b40(0x1b2)]?_0x4d4792[_0x11f09f(0x1b2)][_0x11f09f(0x1f7)]()['substring'](-0xaa*0x2+0x2b0*0x4+-0x9*0x10c,0xb*-0x2d4+-0xbd0+-0x2fc*-0x11):'';return{'name':_0x11f09f(0x20f),'result':(_0x11f09f(0x1d1)+(_0x4d4792[_0x11f09f(0x28e)]||-0x8e6+0x13f*-0x3+0xca4)+'\x0a'+_0x5212f5+'\x0a'+_0x4748c8)[_0x3a7b40(0x275)](),'error':!![]};}}function executeReadFile(_0x40d106,_0x1b0d00,_0x44f3fb){const _0x58e8af=_0x3877a1,_0x48c159=_0x3877a1,_0x4e3f40=_0x40d106[_0x58e8af(0x232)]('/')?_0x40d106:resolve(_0x44f3fb||process['cwd'](),_0x40d106);try{let _0x38a123=_0x3549ca[_0x58e8af(0x178)+'nc'](_0x4e3f40,_0x58e8af(0x297));if(_0x1b0d00&&_0x1b0d00>-0x2*-0x206+0x1434+-0x10*0x184){const _0x4c523f=_0x38a123[_0x58e8af(0x2a6)]('\x0a');_0x4c523f['length']>_0x1b0d00&&(_0x38a123=_0x4c523f['slice'](-0x1540+-0x2a2*-0x3+-0x2*-0x6ad,_0x1b0d00)[_0x48c159(0x1a6)]('\x0a')+(_0x48c159(0x287)+_0x4c523f[_0x58e8af(0x23a)]+('\x20lines\x20tot'+_0x48c159(0x2a5))));}return _0x38a123[_0x48c159(0x23a)]>0x1*0x6015+0x40d*-0xd+0x22b4&&(_0x38a123=_0x38a123[_0x58e8af(0x2af)](0x121*-0x1+-0x5*-0x25b+-0x553*0x2,-0x1cc3+0x7*0x1526+-0x2927)+(_0x48c159(0x17a)+'cated,\x20'+_0x38a123['length']+'\x20chars)')),{'name':_0x48c159(0x1ac),'result':_0x38a123};}catch(_0x5cc3ac){return{'name':_0x58e8af(0x1ac),'result':_0x58e8af(0x23f)+_0x48c159(0x1b0)+_0x58e8af(0x284)+':\x20'+_0x4e3f40,'error':!![]};}}function executeWriteFile(_0x69f0e8,_0x49a04e,_0x5b5e81,_0x320193){const _0x3ed4c2=_0x1006ab,_0xbf210e=_0x3877a1,_0x195a23=_0x69f0e8[_0x3ed4c2(0x232)]('/')?_0x69f0e8:resolve(_0x320193||process['cwd'](),_0x69f0e8);try{const _0x76ee7=_0x195a23[_0x3ed4c2(0x2af)](-0x1e1a+-0xc9f+0x2ab9,_0x195a23[_0x3ed4c2(0x2a7)+'f']('/'));return _0x76ee7&&!_0x3549ca[_0x3ed4c2(0x2a3)](_0x76ee7)&&_0x3549ca['mkdirSync'](_0x76ee7,{'recursive':!![]}),_0x5b5e81?_0x3549ca[_0x3ed4c2(0x1d7)+'Sync'](_0x195a23,_0x49a04e):_0x3549ca[_0xbf210e(0x1e8)+_0xbf210e(0x216)](_0x195a23,_0x49a04e),{'name':_0xbf210e(0x186),'result':_0xbf210e(0x27e)+_0xbf210e(0x205)+_0x195a23+'\x20('+_0x49a04e[_0xbf210e(0x23a)]+_0xbf210e(0x19e)};}catch(_0x1400e0){return{'name':_0xbf210e(0x186),'result':_0xbf210e(0x221)+'ed:\x20'+(_0x1400e0 instanceof Error?_0x1400e0[_0x3ed4c2(0x1ba)]:_0x1400e0),'error':!![]};}}function executeWebFetch(_0x813c57,_0x415e9a){const _0x2c6f4d=_0x1006ab,_0x44c256=_0x1006ab;try{const _0x398ec8=_0x415e9a||-0x523+-0x2bcc+0x57ff,_0x19ff5a=execSync('curl\x20-sL\x20-'+_0x2c6f4d(0x1f4)+'15\x20--max-f'+_0x44c256(0x255)+_0x2c6f4d(0x268)+_0x813c57+(_0x2c6f4d(0x236)+'c\x20')+_0x398ec8*(-0x1833+0x166e+0x7*0x41),{'encoding':'utf-8','timeout':0x4e20,'maxBuffer':(0x1113+-0x2c+-0x1*0x10e2)*(-0x103d+-0x156d*0x1+0x29aa)*(0x8*-0x81+0x13c7+-0xbbf)});let _0x42a258=_0x19ff5a['replace'](/<script[^>]*>[\s\S]*?<\/script>/gi,'')[_0x44c256(0x18a)](/<style[^>]*>[\s\S]*?<\/style>/gi,'')['replace'](/<[^>]+>/g,'\x20')['replace'](/\s+/g,'\x20')['trim']();if(_0x42a258[_0x44c256(0x23a)]>_0x398ec8)_0x42a258=_0x42a258[_0x2c6f4d(0x2af)](-0xf20+0x2217+0x1*-0x12f7,_0x398ec8)+_0x2c6f4d(0x1fe);return{'name':_0x2c6f4d(0x2b3),'result':_0x42a258||'(empty\x20res'+_0x44c256(0x21c)};}catch(_0x16ce3b){return{'name':_0x44c256(0x2b3),'result':_0x2c6f4d(0x1c8)+'ed:\x20'+(_0x16ce3b instanceof Error?_0x16ce3b[_0x44c256(0x1ba)]:_0x16ce3b),'error':!![]};}}function executeWebSearch(_0x32e87d){const _0x160906=_0x3877a1,_0x4660c9=_0x1006ab;try{const _0x4d8c31=encodeURIComponent(_0x32e87d),_0x49a0c6=execSync(_0x160906(0x209)+_0x160906(0x1a0)+'i.duckduck'+_0x4660c9(0x23d)+_0x4d8c31+(_0x160906(0x1d0)+_0x4660c9(0x27d)+_0x160906(0x22a)+'sambig=1\x22'),{'encoding':'utf-8','timeout':0x2710}),_0x3eb2ef=JSON[_0x4660c9(0x206)](_0x49a0c6),_0x1a273a=[];if(_0x3eb2ef[_0x4660c9(0x265)+'xt']){_0x1a273a[_0x160906(0x19d)](_0x4660c9(0x180)+_0x3eb2ef[_0x4660c9(0x265)+'xt']);if(_0x3eb2ef['AbstractUR'+'L'])_0x1a273a[_0x4660c9(0x19d)](_0x4660c9(0x1b7)+'\x20'+_0x3eb2ef['AbstractUR'+'L']);}if(_0x3eb2ef['RelatedTop'+_0x4660c9(0x29d)])for(const _0x3b51b2 of _0x3eb2ef[_0x160906(0x198)+_0x160906(0x29d)][_0x160906(0x293)](-0x218a+0xf*-0xd+0x224d,-0x1*0x2497+-0x2041+0x44dd)){if(_0x3b51b2[_0x4660c9(0x2ba)]){_0x1a273a[_0x160906(0x19d)]('•\x20'+_0x3b51b2[_0x4660c9(0x2ba)]);if(_0x3b51b2[_0x160906(0x26f)])_0x1a273a[_0x4660c9(0x19d)]('\x20\x20'+_0x3b51b2[_0x4660c9(0x26f)]);}}if(_0x1a273a['length']===0x9f*-0x11+-0x266c+0x30fb){const _0x3b8701=execSync(_0x160906(0x209)+_0x4660c9(0x222)+_0x4660c9(0x215)+_0x160906(0x254)+_0x160906(0x1d5)+_0x4d8c31+(_0x160906(0x1b5)+'oP\x20\x27<a\x20rel'+_0x160906(0x1f8)+_0x160906(0x1ef)+'esult__a\x22\x20'+_0x160906(0x187)+_0x160906(0x1fb)+_0x160906(0x1b3)+_0x160906(0x25b)+_0x4660c9(0x24b)+_0x160906(0x1aa)),{'encoding':_0x160906(0x297),'timeout':0x2710})['trim']();if(_0x3b8701)return{'name':_0x160906(0x1c3),'result':_0x3b8701};return{'name':'web_search','result':'No\x20results'+'\x20for\x20\x22'+_0x32e87d+(_0x4660c9(0x22f)+_0x160906(0x27f)+_0x4660c9(0x217)+'e\x20web_fetc'+_0x160906(0x1fc)+_0x160906(0x230)+'L.')};}return{'name':_0x160906(0x1c3),'result':_0x1a273a['join']('\x0a')};}catch(_0x12aa97){return{'name':_0x4660c9(0x1c3),'result':'Search\x20fai'+_0x160906(0x239)+(_0x12aa97 instanceof Error?_0x12aa97['message']:_0x12aa97),'error':!![]};}}function executeListDirectory(_0x398cf5,_0x2b12b1,_0x15c073){const _0x5aea56=_0x1006ab,_0x51c2fb=_0x1006ab,_0x13f560=_0x398cf5?.[_0x5aea56(0x232)]('/')?_0x398cf5:resolve(_0x15c073||process[_0x51c2fb(0x1b1)](),_0x398cf5||'.');try{if(!_0x3549ca[_0x5aea56(0x2a3)](_0x13f560))return{'name':'list_direc'+_0x5aea56(0x2ae),'result':_0x51c2fb(0x241)+_0x5aea56(0x2b9)+'\x20'+_0x13f560,'error':!![]};const _0xd82e9c=[];function _0x4c8e34(_0xd81af1,_0x2d1a8a){const _0x54b852=_0x5aea56,_0x54fd6f=_0x5aea56,_0x2c9413=_0x3549ca[_0x54b852(0x29f)+'c'](_0xd81af1,{'withFileTypes':!![]}),_0x28c154='\x20\x20'[_0x54b852(0x1fa)](_0x2d1a8a);for(const _0x1b7adc of _0x2c9413){if(_0x1b7adc[_0x54fd6f(0x26c)]['startsWith']('.')&&_0x2d1a8a===0xff6+-0x222a*-0x1+-0x3220&&_0x2c9413['length']>-0x2*0x1037+-0x14ae+0x3530)continue;const _0x5be6f6=resolve(_0xd81af1,_0x1b7adc[_0x54fd6f(0x26c)]);if(_0x1b7adc[_0x54fd6f(0x2a0)+'y']())_0xd82e9c['push'](_0x28c154+_0x54fd6f(0x1ff)+_0x1b7adc[_0x54b852(0x26c)]+'/'),_0x2b12b1&&_0x2d1a8a<-0x4*-0x594+0x3*-0x8da+0x79*0x9&&_0x4c8e34(_0x5be6f6,_0x2d1a8a+(0x1*0xc46+-0x1d24+-0x1*-0x10df));else try{const _0x5be3c5=_0x3549ca[_0x54fd6f(0x17d)](_0x5be6f6),_0x62f8be=_0x5be3c5['size']<-0x2f9*0x1+0x9*-0x2df+0x1068*0x2?_0x5be3c5[_0x54b852(0x1af)]+'B':_0x5be3c5['size']<0x1*-0x3714d+-0xac*0x2f25+-0x331e29*-0x1?(_0x5be3c5[_0x54fd6f(0x1af)]/(0x823*-0x2+0x1*-0x2290+-0x2*-0x1b6b))['toFixed'](0x1bf7*0x1+0x1c8f+-0x3885)+'KB':(_0x5be3c5[_0x54fd6f(0x1af)]/(0x1dec16+-0x1db496+-0x2*-0x7e440))['toFixed'](-0x1b77+0x7*0x305+0x655)+'MB';_0xd82e9c[_0x54b852(0x19d)](_0x28c154+'📄\x20'+_0x1b7adc['name']+'\x20('+_0x62f8be+')');}catch{_0xd82e9c[_0x54b852(0x19d)](_0x28c154+'📄\x20'+_0x1b7adc[_0x54b852(0x26c)]);}}}_0x4c8e34(_0x13f560,-0x174d+0x1d6d*-0x1+0x34ba);const _0x48b18b=_0xd82e9c[_0x5aea56(0x23a)]>-0x1406+0x13*0xfa+0x178?_0x13f560+':\x0a'+_0xd82e9c[_0x5aea56(0x1a6)]('\x0a'):_0x13f560+(':\x20(empty\x20d'+_0x5aea56(0x25c));return{'name':_0x51c2fb(0x19f)+_0x51c2fb(0x2ae),'result':_0x48b18b[_0x51c2fb(0x23a)]>-0x3380+-0x2*-0x1438+0x2a50?_0x48b18b[_0x51c2fb(0x2af)](0x1755+-0xc55*0x1+-0xb00,-0x31bd+0x269*0x1+-0x2*-0x274a)+_0x51c2fb(0x1a9):_0x48b18b};}catch(_0x3738a5){return{'name':'list_direc'+_0x51c2fb(0x2ae),'result':_0x5aea56(0x277)+_0x51c2fb(0x218)+_0x5aea56(0x18c)+(_0x3738a5 instanceof Error?_0x3738a5['message']:_0x3738a5),'error':!![]};}}function executePython(_0x1dc64f,_0x39ff9f){const _0x1866ec=_0x3877a1,_0x527689=_0x3877a1,_0x3080bc=checkExecAllowed(_0x1866ec(0x1be));if(!_0x3080bc['allowed'])return{'name':_0x1866ec(0x272)+_0x527689(0x1ab),'result':'Python\x20exe'+_0x527689(0x2b2)+'\x20allowed:\x20'+(_0x3080bc[_0x527689(0x1d2)]??'exec\x20execu'+_0x527689(0x2b1)+'d'),'error':!![]};try{const _0x2429b5=_0x338da9(_0x513716[_0x1866ec(0x21d)](),_0x1866ec(0x29b)+'py-'+Date[_0x527689(0x204)]()+_0x1866ec(0x234));_0x3549ca[_0x527689(0x1e8)+_0x527689(0x216)](_0x2429b5,_0x1dc64f);try{const _0x38927f=execSync(_0x527689(0x2bb)+_0x2429b5+'\x22',{'encoding':'utf-8','cwd':_0x39ff9f||process['cwd'](),'timeout':0xea60,'maxBuffer':(-0x19c4+-0x269a+0x4063)*(0x1a0+0x2ae*0x1+-0x4e)*(-0x1141+0x24b+0x12f6),'env':{...process[_0x1866ec(0x200)],'LANG':_0x527689(0x262)+'8','PYTHONIOENCODING':_0x1866ec(0x297)}}),_0x500861=_0x38927f['length']>0x1093+0x5b+-0x1*-0x1622?_0x38927f[_0x527689(0x2af)](0x7*-0x3fb+0x234a*-0x1+0x3f27,-0x3b60+0xd*0x53e+0x1e4a)+(_0x1866ec(0x17a)+_0x1866ec(0x263)+_0x38927f[_0x527689(0x23a)]+(_0x1866ec(0x2bc)+_0x1866ec(0x2a5))):_0x38927f;return{'name':_0x1866ec(0x272)+_0x527689(0x1ab),'result':_0x500861||_0x1866ec(0x1c9)+')'};}finally{try{_0x3549ca[_0x1866ec(0x269)](_0x2429b5);}catch{}}}catch(_0x3e9458){const _0xe1288f=_0x3e9458[_0x527689(0x278)]?_0x3e9458['stderr'][_0x527689(0x1f7)]()[_0x527689(0x2af)](-0x1*0x9fa+-0x2449*-0x1+-0xf*0x1c1,0xd15+0x329*-0x1+-0xa*-0x2e):'',_0x7fdf77=_0x3e9458[_0x1866ec(0x1b2)]?_0x3e9458[_0x1866ec(0x1b2)][_0x1866ec(0x1f7)]()[_0x1866ec(0x2af)](-0xdde*0x1+0x3b3+0xa2b*0x1,0x1*-0xae5+-0x4e*0x71+0x390b):'';return{'name':_0x1866ec(0x272)+_0x527689(0x1ab),'result':(_0x527689(0x20c)+_0x1866ec(0x18b)+(_0x3e9458[_0x527689(0x28e)]||-0x4e7+-0xb8*-0x13+-0x460*0x2)+_0x1866ec(0x18f)+_0xe1288f+'\x0a'+_0x7fdf77)[_0x527689(0x275)](),'error':!![]};}}function executeEditFile(_0x28a97e,_0x17f4d4,_0x32535b,_0x31d89a){const _0x48644d=_0x3877a1,_0x353d38=_0x3877a1,_0x1f6f7d=_0x28a97e[_0x48644d(0x232)]('/')?_0x28a97e:resolve(_0x31d89a||process['cwd'](),_0x28a97e);try{if(!_0x3549ca[_0x353d38(0x2a3)](_0x1f6f7d))return{'name':_0x48644d(0x21a),'result':_0x353d38(0x23f)+'ound:\x20'+_0x1f6f7d,'error':!![]};const _0x37d639=_0x3549ca[_0x353d38(0x178)+'nc'](_0x1f6f7d,_0x48644d(0x297));if(!_0x37d639[_0x48644d(0x258)](_0x17f4d4))return{'name':_0x353d38(0x21a),'result':'oldText\x20no'+_0x353d38(0x1c1)+'\x20'+_0x1f6f7d+('.\x20Make\x20sur'+_0x353d38(0x246)+_0x48644d(0x220)+'\x20(includin'+_0x353d38(0x296)+_0x353d38(0x24a)),'error':!![]};const _0x241e4=_0x37d639[_0x353d38(0x18a)](_0x17f4d4,_0x32535b);return _0x3549ca[_0x353d38(0x1e8)+'ync'](_0x1f6f7d,_0x241e4),{'name':_0x353d38(0x21a),'result':_0x48644d(0x1f3)+_0x1f6f7d+(_0x353d38(0x210)+'d\x20')+_0x17f4d4[_0x353d38(0x23a)]+(_0x48644d(0x1ce)+'h\x20')+_0x32535b[_0x48644d(0x23a)]+_0x48644d(0x252)};}catch(_0x2ec330){return{'name':_0x353d38(0x21a),'result':_0x353d38(0x266)+_0x353d38(0x1b4)+(_0x2ec330 instanceof Error?_0x2ec330[_0x48644d(0x1ba)]:_0x2ec330),'error':!![]};}}
|