alvin-bot 5.6.2 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +1 -1
- package/dist/claude.js +1 -102
- package/dist/config.js +1 -96
- package/dist/engine.js +1 -90
- package/dist/find-claude-binary.js +1 -98
- package/dist/handlers/async-agent-chunk-handler.js +1 -50
- package/dist/handlers/background-bypass.js +1 -75
- package/dist/handlers/commands.js +1 -2336
- package/dist/handlers/cron-progress.js +1 -52
- package/dist/handlers/document.js +1 -194
- package/dist/handlers/message.js +1 -959
- package/dist/handlers/photo.js +1 -154
- package/dist/handlers/platform-message.js +1 -360
- package/dist/handlers/stuck-timer.js +1 -54
- package/dist/handlers/video.js +1 -237
- package/dist/handlers/voice.js +1 -148
- package/dist/i18n.js +1 -805
- package/dist/index.js +1 -697
- package/dist/init-data-dir.js +1 -98
- package/dist/middleware/auth.js +1 -233
- package/dist/migrate.js +1 -162
- package/dist/paths.js +1 -146
- package/dist/platforms/discord.js +1 -175
- package/dist/platforms/index.js +1 -130
- package/dist/platforms/signal.js +1 -205
- package/dist/platforms/slack-slash-parser.js +1 -32
- package/dist/platforms/slack.js +1 -501
- package/dist/platforms/telegram.js +1 -111
- package/dist/platforms/types.js +1 -8
- package/dist/platforms/whatsapp-auth-helpers.js +1 -53
- package/dist/platforms/whatsapp.js +1 -707
- package/dist/providers/claude-sdk-provider.js +1 -565
- package/dist/providers/codex-cli-provider.js +1 -134
- package/dist/providers/index.js +1 -7
- package/dist/providers/ollama-provider.js +1 -32
- package/dist/providers/openai-compatible.js +1 -406
- package/dist/providers/registry.js +1 -352
- package/dist/providers/runtime-header.js +1 -45
- package/dist/providers/tool-executor.js +1 -475
- package/dist/providers/types.js +1 -227
- package/dist/services/access.js +1 -144
- package/dist/services/allowed-users-gate.js +1 -56
- package/dist/services/alvin-dispatch.js +1 -130
- package/dist/services/alvin-mcp-tools.js +1 -104
- package/dist/services/asset-index.js +1 -224
- package/dist/services/async-agent-parser.js +1 -418
- package/dist/services/async-agent-watcher.js +1 -443
- package/dist/services/auto-diagnostic.js +1 -228
- package/dist/services/broadcast.js +1 -52
- package/dist/services/browser-manager.js +1 -562
- package/dist/services/browser-webfetch.js +1 -127
- package/dist/services/browser.js +1 -121
- package/dist/services/cdp-bootstrap.js +1 -357
- package/dist/services/compaction.js +1 -144
- package/dist/services/critical-notify.js +1 -203
- package/dist/services/cron-resolver.js +1 -58
- package/dist/services/cron-scheduling.js +1 -310
- package/dist/services/cron.js +1 -861
- package/dist/services/custom-tools.js +1 -317
- package/dist/services/delivery-queue.js +1 -173
- package/dist/services/delivery-registry.js +1 -21
- package/dist/services/disk-cleanup.js +1 -203
- package/dist/services/elevenlabs.js +1 -58
- package/dist/services/embeddings/auto-detect.js +1 -74
- package/dist/services/embeddings/fts5.js +1 -108
- package/dist/services/embeddings/gemini.js +1 -65
- package/dist/services/embeddings/index.js +1 -496
- package/dist/services/embeddings/ollama.js +1 -78
- package/dist/services/embeddings/openai.js +1 -49
- package/dist/services/embeddings/provider.js +1 -22
- package/dist/services/embeddings/vector-base.js +1 -113
- package/dist/services/embeddings-migration.js +1 -193
- package/dist/services/embeddings.js +1 -9
- package/dist/services/env-file.js +1 -50
- package/dist/services/exec-guard.js +1 -71
- package/dist/services/fallback-order.js +1 -154
- package/dist/services/file-permissions.js +1 -93
- package/dist/services/heartbeat-file.js +1 -65
- package/dist/services/heartbeat.js +1 -313
- package/dist/services/hooks.js +1 -44
- package/dist/services/imagegen.js +1 -72
- package/dist/services/language-detect.js +1 -154
- package/dist/services/markdown.js +1 -63
- package/dist/services/mcp.js +1 -263
- package/dist/services/memory-extractor.js +1 -178
- package/dist/services/memory-inject-mode.js +1 -43
- package/dist/services/memory-layers.js +1 -156
- package/dist/services/memory.js +1 -146
- package/dist/services/ollama-manager.js +1 -339
- package/dist/services/permissions-wizard.js +1 -291
- package/dist/services/personality.js +1 -376
- package/dist/services/plugins.js +1 -171
- package/dist/services/preflight.js +1 -292
- package/dist/services/process-manager.js +1 -291
- package/dist/services/release-highlights.js +1 -79
- package/dist/services/reminders.js +1 -97
- package/dist/services/restart.js +1 -48
- package/dist/services/security-audit.js +1 -74
- package/dist/services/self-diagnosis.js +1 -272
- package/dist/services/self-search.js +1 -129
- package/dist/services/session-persistence.js +1 -237
- package/dist/services/session.js +1 -282
- package/dist/services/skills.js +1 -290
- package/dist/services/ssrf-guard.js +1 -162
- package/dist/services/standing-orders.js +1 -29
- package/dist/services/steer-channel.js +1 -46
- package/dist/services/stop-controller.js +1 -52
- package/dist/services/subagent-dedup.js +1 -0
- package/dist/services/subagent-delivery.js +1 -452
- package/dist/services/subagent-stats.js +1 -123
- package/dist/services/subagents.js +1 -814
- package/dist/services/sudo.js +1 -329
- package/dist/services/telegram.js +1 -158
- package/dist/services/timing-safe-bearer.js +1 -51
- package/dist/services/tool-discovery.js +1 -214
- package/dist/services/trends.js +1 -580
- package/dist/services/updater.js +1 -291
- package/dist/services/usage-tracker.js +1 -144
- package/dist/services/users.js +1 -271
- package/dist/services/voice.js +1 -104
- package/dist/services/watchdog-brake.js +1 -154
- package/dist/services/watchdog.js +1 -311
- package/dist/services/workspaces.js +1 -276
- package/dist/tui/index.js +1 -667
- package/dist/util/console-formatter.js +1 -109
- package/dist/util/debounce.js +1 -24
- package/dist/util/telegram-error-filter.js +1 -62
- package/dist/version.js +1 -24
- package/dist/web/bind-strategy.js +1 -42
- package/dist/web/canvas.js +1 -30
- package/dist/web/doctor-api.js +1 -604
- package/dist/web/openai-compat.js +1 -252
- package/dist/web/server.js +1 -1831
- package/dist/web/setup-api.js +1 -1101
- package/package.json +5 -2
- package/dist/.metadata_never_index +0 -0
|
@@ -1,357 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP Bootstrap — spawns Chromium with remote-debugging-port=9222 independently.
|
|
3
|
-
*
|
|
4
|
-
* Avoids two problems that plague naive CDP setups:
|
|
5
|
-
*
|
|
6
|
-
* 1. **LaunchServices hijack** — invoking /Applications/Google Chrome.app while
|
|
7
|
-
* the user's Chrome is running silently redirects the call to the existing
|
|
8
|
-
* instance without applying --remote-debugging-port. Log symptom:
|
|
9
|
-
* "Wird in einer aktuellen Browsersitzung geöffnet." We avoid it by
|
|
10
|
-
* preferring Playwright's "Google Chrome for Testing" binary, which has a
|
|
11
|
-
* distinct bundle ID.
|
|
12
|
-
*
|
|
13
|
-
* 2. **Stale PID files** — a crashed Chromium leaves chrome-cdp.pid pointing at
|
|
14
|
-
* a dead process; subsequent starts conclude "already running" and fail
|
|
15
|
-
* silently. We verify liveness via both `ps` and a CDP /json/version probe.
|
|
16
|
-
*
|
|
17
|
-
* The module is idempotent: `ensureRunning()` is safe to call repeatedly; if
|
|
18
|
-
* CDP is already healthy it returns immediately.
|
|
19
|
-
*/
|
|
20
|
-
import { spawn } from "child_process";
|
|
21
|
-
import fs from "fs";
|
|
22
|
-
import path from "path";
|
|
23
|
-
import os from "os";
|
|
24
|
-
import http from "http";
|
|
25
|
-
import { CDP_PROFILE_DIR, CDP_SCREENSHOTS_DIR, CDP_PID_FILE, CDP_LOG_FILE, } from "../paths.js";
|
|
26
|
-
const CDP_PORT = 9222;
|
|
27
|
-
const CDP_VERSION_URL = `http://127.0.0.1:${CDP_PORT}/json/version`;
|
|
28
|
-
const START_TIMEOUT_MS = 15_000;
|
|
29
|
-
// ── Binary resolution ───────────────────────────────────────────────
|
|
30
|
-
/**
|
|
31
|
-
* Find Playwright's bundled Chromium. Prefers "Google Chrome for Testing"
|
|
32
|
-
* (distinct macOS bundle ID — no LaunchServices conflict with user Chrome),
|
|
33
|
-
* falls back to plain Chromium for older Playwright installs.
|
|
34
|
-
*
|
|
35
|
-
* Returns null if no bundled Chromium is present — callers should then fall
|
|
36
|
-
* back to a user-supplied binary or error out with guidance.
|
|
37
|
-
*/
|
|
38
|
-
export function findPlaywrightChromium() {
|
|
39
|
-
const pwRoot = path.join(os.homedir(), "Library", "Caches", "ms-playwright");
|
|
40
|
-
if (!fs.existsSync(pwRoot)) {
|
|
41
|
-
// Linux cache path
|
|
42
|
-
const linuxPwRoot = path.join(os.homedir(), ".cache", "ms-playwright");
|
|
43
|
-
if (fs.existsSync(linuxPwRoot))
|
|
44
|
-
return resolveFromPwRoot(linuxPwRoot);
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return resolveFromPwRoot(pwRoot);
|
|
48
|
-
}
|
|
49
|
-
function resolveFromPwRoot(pwRoot) {
|
|
50
|
-
let dirs;
|
|
51
|
-
try {
|
|
52
|
-
dirs = fs.readdirSync(pwRoot).filter((d) => /^chromium-\d+$/.test(d));
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
if (dirs.length === 0)
|
|
58
|
-
return null;
|
|
59
|
-
// Latest version by numeric suffix
|
|
60
|
-
dirs.sort((a, b) => {
|
|
61
|
-
const na = parseInt(a.replace("chromium-", ""), 10);
|
|
62
|
-
const nb = parseInt(b.replace("chromium-", ""), 10);
|
|
63
|
-
return nb - na;
|
|
64
|
-
});
|
|
65
|
-
// Platform-dependent layout; try all known variants
|
|
66
|
-
const candidates = [];
|
|
67
|
-
for (const dir of dirs) {
|
|
68
|
-
const root = path.join(pwRoot, dir);
|
|
69
|
-
for (const arch of ["chrome-mac-arm64", "chrome-mac", "chrome-linux", "chrome-win"]) {
|
|
70
|
-
for (const app of [
|
|
71
|
-
// macOS app bundles
|
|
72
|
-
"Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",
|
|
73
|
-
"Chromium.app/Contents/MacOS/Chromium",
|
|
74
|
-
// Linux / Windows raw binaries
|
|
75
|
-
"chrome",
|
|
76
|
-
"chrome.exe",
|
|
77
|
-
]) {
|
|
78
|
-
candidates.push(path.join(root, arch, app));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
for (const c of candidates) {
|
|
83
|
-
try {
|
|
84
|
-
const st = fs.statSync(c);
|
|
85
|
-
if (st.isFile())
|
|
86
|
-
return c;
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
// not present, keep searching
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Resolve the browser binary in preference order:
|
|
96
|
-
* 1. Playwright's Chromium (no conflict with user Chrome, preferred)
|
|
97
|
-
* 2. Existing user browser (may trigger LaunchServices hijack — last resort)
|
|
98
|
-
*/
|
|
99
|
-
export function resolveBrowserBinary() {
|
|
100
|
-
const pw = findPlaywrightChromium();
|
|
101
|
-
if (pw)
|
|
102
|
-
return { path: pw, origin: "playwright" };
|
|
103
|
-
// System Chrome fallback (macOS path). On Linux/Windows we return null and
|
|
104
|
-
// let callers surface a clear error.
|
|
105
|
-
const sysChrome = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
|
|
106
|
-
if (fs.existsSync(sysChrome))
|
|
107
|
-
return { path: sysChrome, origin: "system" };
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
// ── Liveness probes ─────────────────────────────────────────────────
|
|
111
|
-
function pidAlive(pid) {
|
|
112
|
-
try {
|
|
113
|
-
// signal 0 tests existence without actually signaling
|
|
114
|
-
process.kill(pid, 0);
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function readPidFile() {
|
|
122
|
-
try {
|
|
123
|
-
const raw = fs.readFileSync(CDP_PID_FILE, "utf8").trim();
|
|
124
|
-
const pid = parseInt(raw, 10);
|
|
125
|
-
return Number.isFinite(pid) ? pid : null;
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async function cdpReachable(timeoutMs = 2000) {
|
|
132
|
-
return new Promise((resolve) => {
|
|
133
|
-
const req = http.get(CDP_VERSION_URL, (res) => {
|
|
134
|
-
res.resume(); // drain
|
|
135
|
-
resolve(res.statusCode === 200);
|
|
136
|
-
});
|
|
137
|
-
req.on("error", () => resolve(false));
|
|
138
|
-
req.setTimeout(timeoutMs, () => {
|
|
139
|
-
req.destroy();
|
|
140
|
-
resolve(false);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
// ── Process control ─────────────────────────────────────────────────
|
|
145
|
-
let bootstrapLock = null;
|
|
146
|
-
/**
|
|
147
|
-
* Ensure CDP is running on port 9222. Idempotent and safe to call from
|
|
148
|
-
* multiple concurrent code paths — only one spawn happens at a time.
|
|
149
|
-
*/
|
|
150
|
-
export async function ensureRunning(opts = {}) {
|
|
151
|
-
const mode = opts.mode || "headless";
|
|
152
|
-
// Already running? Verify both ends (process + endpoint).
|
|
153
|
-
if (await cdpReachable()) {
|
|
154
|
-
return { running: true, pid: readPidFile() || undefined, endpoint: CDP_VERSION_URL };
|
|
155
|
-
}
|
|
156
|
-
// Serialize concurrent bootstrap attempts
|
|
157
|
-
if (bootstrapLock) {
|
|
158
|
-
await bootstrapLock;
|
|
159
|
-
if (await cdpReachable()) {
|
|
160
|
-
return { running: true, pid: readPidFile() || undefined, endpoint: CDP_VERSION_URL };
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
bootstrapLock = (async () => {
|
|
164
|
-
// Stale PID cleanup — a PID file pointing at a dead process blocks nothing
|
|
165
|
-
// but is confusing. Remove it before spawning.
|
|
166
|
-
const stalePid = readPidFile();
|
|
167
|
-
if (stalePid && !pidAlive(stalePid)) {
|
|
168
|
-
try {
|
|
169
|
-
fs.unlinkSync(CDP_PID_FILE);
|
|
170
|
-
}
|
|
171
|
-
catch { }
|
|
172
|
-
}
|
|
173
|
-
const binary = resolveBrowserBinary();
|
|
174
|
-
if (!binary) {
|
|
175
|
-
throw new Error("No Chromium binary found. Install Playwright's Chromium: " +
|
|
176
|
-
"cd ~/.alvin-bot && npx playwright install chromium");
|
|
177
|
-
}
|
|
178
|
-
// Ensure data dirs exist
|
|
179
|
-
for (const dir of [CDP_PROFILE_DIR, CDP_SCREENSHOTS_DIR, path.dirname(CDP_PID_FILE)]) {
|
|
180
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
181
|
-
}
|
|
182
|
-
const args = [
|
|
183
|
-
`--remote-debugging-port=${CDP_PORT}`,
|
|
184
|
-
`--user-data-dir=${CDP_PROFILE_DIR}`,
|
|
185
|
-
"--no-first-run",
|
|
186
|
-
"--no-default-browser-check",
|
|
187
|
-
"--disable-features=ChromeWhatsNewUI,PrivacySandboxSettings4",
|
|
188
|
-
];
|
|
189
|
-
if (mode === "headless") {
|
|
190
|
-
args.push("--headless=new", "--disable-gpu");
|
|
191
|
-
}
|
|
192
|
-
args.push("about:blank");
|
|
193
|
-
const logStream = fs.openSync(CDP_LOG_FILE, "w");
|
|
194
|
-
const child = spawn(binary.path, args, {
|
|
195
|
-
stdio: ["ignore", logStream, logStream],
|
|
196
|
-
detached: true,
|
|
197
|
-
});
|
|
198
|
-
child.unref();
|
|
199
|
-
// The child inherits its own copy of the fd. Close our copy so the parent
|
|
200
|
-
// process doesn't leak a file descriptor per Chromium bootstrap.
|
|
201
|
-
try {
|
|
202
|
-
fs.closeSync(logStream);
|
|
203
|
-
}
|
|
204
|
-
catch { /* already closed — fine */ }
|
|
205
|
-
if (!child.pid) {
|
|
206
|
-
throw new Error("Failed to spawn Chromium (no PID)");
|
|
207
|
-
}
|
|
208
|
-
fs.writeFileSync(CDP_PID_FILE, String(child.pid));
|
|
209
|
-
// Wait until CDP answers
|
|
210
|
-
const deadline = Date.now() + START_TIMEOUT_MS;
|
|
211
|
-
while (Date.now() < deadline) {
|
|
212
|
-
if (await cdpReachable())
|
|
213
|
-
return;
|
|
214
|
-
await new Promise((r) => setTimeout(r, 300));
|
|
215
|
-
}
|
|
216
|
-
// Did not come up — kill and surface a useful error
|
|
217
|
-
try {
|
|
218
|
-
process.kill(child.pid);
|
|
219
|
-
}
|
|
220
|
-
catch { }
|
|
221
|
-
try {
|
|
222
|
-
fs.unlinkSync(CDP_PID_FILE);
|
|
223
|
-
}
|
|
224
|
-
catch { }
|
|
225
|
-
const tail = readLogTail(20);
|
|
226
|
-
throw new Error(`CDP did not come up within ${START_TIMEOUT_MS}ms using ${binary.path}\n` +
|
|
227
|
-
`Log tail:\n${tail}`);
|
|
228
|
-
})();
|
|
229
|
-
try {
|
|
230
|
-
await bootstrapLock;
|
|
231
|
-
}
|
|
232
|
-
finally {
|
|
233
|
-
bootstrapLock = null;
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
running: true,
|
|
237
|
-
pid: readPidFile() || undefined,
|
|
238
|
-
binary: resolveBrowserBinary()?.path,
|
|
239
|
-
endpoint: CDP_VERSION_URL,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Stop the bot-managed Chromium. Does NOT touch the user's own Chrome.
|
|
244
|
-
*/
|
|
245
|
-
export async function stop() {
|
|
246
|
-
const pid = readPidFile();
|
|
247
|
-
if (pid && pidAlive(pid)) {
|
|
248
|
-
try {
|
|
249
|
-
process.kill(pid, "SIGTERM");
|
|
250
|
-
}
|
|
251
|
-
catch { }
|
|
252
|
-
// Give it a second to close gracefully, then force-kill
|
|
253
|
-
await new Promise((r) => setTimeout(r, 1000));
|
|
254
|
-
if (pidAlive(pid)) {
|
|
255
|
-
try {
|
|
256
|
-
process.kill(pid, "SIGKILL");
|
|
257
|
-
}
|
|
258
|
-
catch { }
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
try {
|
|
262
|
-
fs.unlinkSync(CDP_PID_FILE);
|
|
263
|
-
}
|
|
264
|
-
catch { }
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Report current status without starting anything.
|
|
268
|
-
*/
|
|
269
|
-
export async function status() {
|
|
270
|
-
const pid = readPidFile();
|
|
271
|
-
const endpoint = CDP_VERSION_URL;
|
|
272
|
-
const binary = resolveBrowserBinary()?.path;
|
|
273
|
-
if (pid && pidAlive(pid) && (await cdpReachable())) {
|
|
274
|
-
return { running: true, pid, binary, endpoint };
|
|
275
|
-
}
|
|
276
|
-
if (pid && !pidAlive(pid)) {
|
|
277
|
-
return { running: false, endpoint, reason: `stale PID ${pid} — process not running` };
|
|
278
|
-
}
|
|
279
|
-
if (pid && !(await cdpReachable())) {
|
|
280
|
-
return { running: false, pid, endpoint, reason: "PID alive but CDP endpoint unreachable" };
|
|
281
|
-
}
|
|
282
|
-
return { running: false, endpoint, reason: "not started" };
|
|
283
|
-
}
|
|
284
|
-
function readLogTail(lines) {
|
|
285
|
-
try {
|
|
286
|
-
const content = fs.readFileSync(CDP_LOG_FILE, "utf8");
|
|
287
|
-
return content.split("\n").slice(-lines).join("\n");
|
|
288
|
-
}
|
|
289
|
-
catch {
|
|
290
|
-
return "(no log file)";
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
export async function doctor() {
|
|
294
|
-
const checks = [];
|
|
295
|
-
// 1. Binary
|
|
296
|
-
const binary = resolveBrowserBinary();
|
|
297
|
-
if (binary) {
|
|
298
|
-
checks.push({
|
|
299
|
-
name: "Binary",
|
|
300
|
-
ok: true,
|
|
301
|
-
detail: binary.origin === "playwright"
|
|
302
|
-
? `Playwright Chromium — ${binary.path}`
|
|
303
|
-
: `System Chrome (fallback — risk of LaunchServices conflict) — ${binary.path}`,
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
checks.push({
|
|
308
|
-
name: "Binary",
|
|
309
|
-
ok: false,
|
|
310
|
-
detail: "No Chromium found. Run: npx playwright install chromium",
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
// 2. Port / endpoint
|
|
314
|
-
const reachable = await cdpReachable();
|
|
315
|
-
checks.push({
|
|
316
|
-
name: "CDP endpoint",
|
|
317
|
-
ok: reachable,
|
|
318
|
-
detail: reachable ? `${CDP_VERSION_URL} reachable` : `${CDP_VERSION_URL} not reachable`,
|
|
319
|
-
});
|
|
320
|
-
// 3. PID file
|
|
321
|
-
const pid = readPidFile();
|
|
322
|
-
if (pid === null) {
|
|
323
|
-
checks.push({ name: "PID file", ok: true, detail: "none (OK if CDP not running)" });
|
|
324
|
-
}
|
|
325
|
-
else if (pidAlive(pid)) {
|
|
326
|
-
checks.push({ name: "PID file", ok: true, detail: `PID ${pid} alive` });
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
checks.push({ name: "PID file", ok: false, detail: `stale PID ${pid} — delete ${CDP_PID_FILE}` });
|
|
330
|
-
}
|
|
331
|
-
// 4. Profile lock (only relevant on macOS / Linux)
|
|
332
|
-
const lockPath = path.join(CDP_PROFILE_DIR, "SingletonLock");
|
|
333
|
-
if (fs.existsSync(lockPath)) {
|
|
334
|
-
// Chromium creates SingletonLock while running; only flag if there's no
|
|
335
|
-
// live process associated with it.
|
|
336
|
-
const livePid = pid && pidAlive(pid);
|
|
337
|
-
checks.push({
|
|
338
|
-
name: "Profile lock",
|
|
339
|
-
ok: !!livePid,
|
|
340
|
-
detail: livePid
|
|
341
|
-
? "held by live process (OK)"
|
|
342
|
-
: `stale lock — delete ${lockPath}`,
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
checks.push({ name: "Profile lock", ok: true, detail: "clean" });
|
|
347
|
-
}
|
|
348
|
-
// 5. Log tail
|
|
349
|
-
if (fs.existsSync(CDP_LOG_FILE)) {
|
|
350
|
-
checks.push({
|
|
351
|
-
name: "Recent log",
|
|
352
|
-
ok: true,
|
|
353
|
-
detail: `last lines (${CDP_LOG_FILE}):\n${readLogTail(5)}`,
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
return { ok: checks.every((c) => c.ok), checks };
|
|
357
|
-
}
|
|
1
|
+
const _0x30a8ed=_0x1e4e,_0x5e783e=_0x1e4e;(function(_0x5450a0,_0x197045){const _0x240eb0=_0x1e4e,_0x479789=_0x1e4e,_0x381d79=_0x5450a0();while(!![]){try{const _0x1ab733=-parseInt(_0x240eb0(0x18f))/(-0x562*0x5+-0x23a7+0x1*0x3e92)*(-parseInt(_0x240eb0(0x1aa))/(-0x153f+0x51a*0x6+-0x95b))+parseInt(_0x479789(0x1d1))/(-0x1*-0x1fc9+-0xe4a+-0x117c)*(parseInt(_0x479789(0x1ca))/(-0x498+-0x67f+0x1*0xb1b))+-parseInt(_0x479789(0x1bb))/(-0x1b1+0xfb6+-0xe00)+parseInt(_0x479789(0x16b))/(0x135+-0x3*0x907+0x19e6)*(-parseInt(_0x479789(0x17f))/(-0x30f+0x2*-0x83+-0x20e*-0x2))+parseInt(_0x479789(0x18c))/(-0x70+0x376*0x8+-0x1b38)+parseInt(_0x479789(0x185))/(0x34b+0x1*0xb81+0xec3*-0x1)*(-parseInt(_0x240eb0(0x1bd))/(0x1*0x16cd+0xa*0x3c1+-0x3c4d))+-parseInt(_0x240eb0(0x19d))/(0x915+0x25d7+-0x2ee1);if(_0x1ab733===_0x197045)break;else _0x381d79['push'](_0x381d79['shift']());}catch(_0x50a2b9){_0x381d79['push'](_0x381d79['shift']());}}}(_0x13c6,0x112*0xa43+0x71366+-0x1*0x7cd8d));const _0x172ec9=(function(){let _0x3c087b=!![];return function(_0x22a498,_0x475505){const _0xea951a=_0x3c087b?function(){const _0x502049=_0x1e4e;if(_0x475505){const _0x4fea2b=_0x475505[_0x502049(0x155)](_0x22a498,arguments);return _0x475505=null,_0x4fea2b;}}:function(){};return _0x3c087b=![],_0xea951a;};}()),_0x5d1f36=_0x172ec9(this,function(){const _0x115e87=_0x1e4e,_0x236315=_0x1e4e;return _0x5d1f36[_0x115e87(0x1d6)]()['search']('(((.+)+)+)'+'+$')[_0x115e87(0x1d6)]()[_0x115e87(0x19e)+'r'](_0x5d1f36)['search'](_0x115e87(0x150)+'+$');});_0x5d1f36();import{spawn}from'child_process';import _0x32faad from'fs';import _0x13424e from'path';import _0x46c5ad from'os';import _0x4d5906 from'http';import{CDP_PROFILE_DIR,CDP_SCREENSHOTS_DIR,CDP_PID_FILE,CDP_LOG_FILE}from'../paths.js';const CDP_PORT=-0x2f0c+-0x1f6c*-0x1+0x33a6,CDP_VERSION_URL=_0x30a8ed(0x1cf)+_0x5e783e(0x15a)+CDP_PORT+(_0x30a8ed(0x1bf)+'ion'),START_TIMEOUT_MS=-0x29ee+0x5026+-0x4*-0x518;function _0x1e4e(_0x3ca13f,_0x54cd09){_0x3ca13f=_0x3ca13f-(0x1166*-0x1+-0x258e+0x3844);const _0x4c5bf7=_0x13c6();let _0x10dfaf=_0x4c5bf7[_0x3ca13f];if(_0x1e4e['GODIlB']===undefined){var _0x244e90=function(_0x16c6df){const _0x499769='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x446abf='',_0x264276='',_0x4ed3d0=_0x446abf+_0x244e90;for(let _0x4771b5=-0x2585+-0x1c71+0x41f6,_0x225dc8,_0x4498bf,_0x57d728=-0x1f11+-0x1*0x1504+-0x3415*-0x1;_0x4498bf=_0x16c6df['charAt'](_0x57d728++);~_0x4498bf&&(_0x225dc8=_0x4771b5%(-0xc*0x25f+-0xdfa+-0x2*-0x1539)?_0x225dc8*(0x1*-0xa54+0x5*0x52c+-0xf48)+_0x4498bf:_0x4498bf,_0x4771b5++%(0x7cd+-0x1*-0x1625+-0x1dee))?_0x446abf+=_0x4ed3d0['charCodeAt'](_0x57d728+(-0x1*0x19f3+-0xc90+0x47*0x8b))-(-0x4*-0x41c+-0xda*0x19+0x4e4)!==0x6*0x516+-0x6d0*0x5+0x38c?String['fromCharCode'](-0xa5b+0x1112+-0x5b8&_0x225dc8>>(-(0x1*0x9b8+0xbd5+-0x158b)*_0x4771b5&0x3*-0x3b9+-0x14*-0x1c6+-0x1847*0x1)):_0x4771b5:0x1f48+-0x4b8+-0x190*0x11){_0x4498bf=_0x499769['indexOf'](_0x4498bf);}for(let _0x239054=-0x701+-0x70e+0xe0f,_0x362372=_0x446abf['length'];_0x239054<_0x362372;_0x239054++){_0x264276+='%'+('00'+_0x446abf['charCodeAt'](_0x239054)['toString'](0x937+0x12*0x122+0x3*-0x9d9))['slice'](-(0x2e*0xf+-0x174b*0x1+-0x41f*-0x5));}return decodeURIComponent(_0x264276);};_0x1e4e['GsLIMn']=_0x244e90,_0x1e4e['qCmOeH']={},_0x1e4e['GODIlB']=!![];}const _0x3e898d=_0x4c5bf7[0x1a67+-0x2640+0xbd9],_0x27434d=_0x3ca13f+_0x3e898d,_0x49dfb7=_0x1e4e['qCmOeH'][_0x27434d];if(!_0x49dfb7){const _0x2b79b2=function(_0x22b91a){this['tgwVBa']=_0x22b91a,this['EUwtbZ']=[-0x90b*-0x2+-0x3*0xcd+-0xdf*0x12,0xb6f+0x8c*-0x2e+0xdb9,0x137*0x19+0x977+-0x1*0x27d6],this['FyfHDu']=function(){return'newState';},this['jtdixj']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['KKNrSS']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x2b79b2['prototype']['jGfnVu']=function(){const _0x32bb7f=new RegExp(this['jtdixj']+this['KKNrSS']),_0x577485=_0x32bb7f['test'](this['FyfHDu']['toString']())?--this['EUwtbZ'][0x18ac+-0x3*-0x4ec+-0x276f]:--this['EUwtbZ'][-0x1ce8+0x21d*-0x6+-0x2*-0x14cb];return this['FfhFww'](_0x577485);},_0x2b79b2['prototype']['FfhFww']=function(_0x161cd1){if(!Boolean(~_0x161cd1))return _0x161cd1;return this['jGhIUL'](this['tgwVBa']);},_0x2b79b2['prototype']['jGhIUL']=function(_0x798d1d){for(let _0x1a78a8=0x16ad+0x5*0x14+-0x1711,_0x55d90a=this['EUwtbZ']['length'];_0x1a78a8<_0x55d90a;_0x1a78a8++){this['EUwtbZ']['push'](Math['round'](Math['random']())),_0x55d90a=this['EUwtbZ']['length'];}return _0x798d1d(this['EUwtbZ'][-0x2477+0x1*-0x38f+0x2806]);},new _0x2b79b2(_0x1e4e)['jGfnVu'](),_0x10dfaf=_0x1e4e['GsLIMn'](_0x10dfaf),_0x1e4e['qCmOeH'][_0x27434d]=_0x10dfaf;}else _0x10dfaf=_0x49dfb7;return _0x10dfaf;}export function findPlaywrightChromium(){const _0x2014ba=_0x5e783e,_0x170873=_0x30a8ed,_0x100c44=_0x13424e[_0x2014ba(0x17a)](_0x46c5ad['homedir'](),_0x2014ba(0x1cc),_0x170873(0x15e),_0x170873(0x1a2)+_0x170873(0x166));if(!_0x32faad[_0x2014ba(0x152)](_0x100c44)){const _0x1f1dfb=_0x13424e[_0x170873(0x17a)](_0x46c5ad[_0x170873(0x1c5)](),'.cache',_0x2014ba(0x1a2)+_0x2014ba(0x166));if(_0x32faad[_0x170873(0x152)](_0x1f1dfb))return resolveFromPwRoot(_0x1f1dfb);return null;}return resolveFromPwRoot(_0x100c44);}function resolveFromPwRoot(_0x2fb47d){const _0x1561da=_0x30a8ed,_0x4ba002=_0x30a8ed;let _0x95821c;try{_0x95821c=_0x32faad[_0x1561da(0x1a6)+'c'](_0x2fb47d)[_0x1561da(0x15b)](_0x2cc1d4=>/^chromium-\d+$/['test'](_0x2cc1d4));}catch{return null;}if(_0x95821c[_0x4ba002(0x1ac)]===0x1*-0xa54+0x5*0x52c+-0xf88)return null;_0x95821c[_0x4ba002(0x181)]((_0x5150f7,_0x87f8db)=>{const _0x2f21de=_0x4ba002,_0x310f21=parseInt(_0x5150f7['replace'](_0x2f21de(0x162),''),0x7cd+-0x1*-0x1625+-0x1de8),_0x283d8e=parseInt(_0x87f8db['replace']('chromium-',''),-0x1*0x19f3+-0xc90+0x47*0x8b);return _0x283d8e-_0x310f21;});const _0x45c34a=[];for(const _0x4e48e3 of _0x95821c){const _0x161ce6=_0x13424e[_0x4ba002(0x17a)](_0x2fb47d,_0x4e48e3);for(const _0x3da4df of[_0x4ba002(0x159)+_0x1561da(0x154),_0x1561da(0x159),_0x4ba002(0x1d7)+'ux',_0x1561da(0x1a3)]){for(const _0x10fb97 of['Google\x20Chr'+_0x4ba002(0x17b)+_0x1561da(0x1b8)+_0x1561da(0x161)+_0x4ba002(0x19c)+_0x1561da(0x19a)+_0x1561da(0x1b0),_0x1561da(0x184)+_0x4ba002(0x175)+_0x4ba002(0x1db)+_0x4ba002(0x1cb),_0x4ba002(0x1b1),_0x4ba002(0x196)]){_0x45c34a[_0x1561da(0x1a7)](_0x13424e[_0x4ba002(0x17a)](_0x161ce6,_0x3da4df,_0x10fb97));}}}for(const _0x50e2ec of _0x45c34a){try{const _0x3fac43=_0x32faad[_0x4ba002(0x1d0)](_0x50e2ec);if(_0x3fac43['isFile']())return _0x50e2ec;}catch{}}return null;}export function resolveBrowserBinary(){const _0x12eeb4=_0x30a8ed,_0x5ed5ec=_0x5e783e,_0x4ade52=findPlaywrightChromium();if(_0x4ade52)return{'path':_0x4ade52,'origin':_0x12eeb4(0x1d8)};const _0x1c74e1=_0x5ed5ec(0x172)+_0x5ed5ec(0x16a)+'\x20Chrome.ap'+_0x12eeb4(0x1c1)+'/MacOS/Goo'+_0x12eeb4(0x1b3);if(_0x32faad[_0x12eeb4(0x152)](_0x1c74e1))return{'path':_0x1c74e1,'origin':_0x12eeb4(0x1dc)};return null;}function _0x13c6(){const _0x3887fe=['yxL3CMLNAhqGAq','BcbJAhjVBwL1Bq','ywnRiokaLcbYAxnR','ls1UBY1KzwzHDq','zMvHDhvYzxm9qW','D3jPDgvgAwXLuW','y2HYB21LlMv4zq','zxjYB3i','BM90ihn0yxj0zq','uhjVzMLSzsbSBW','zsbdAhjVBwuGzG','rMfPBgvKihrVia','ywnpuY9hB29NBa','mtKXmZC2ouP1wg1wwa','y29UC3rYDwn0BW','ls1Yzw1VDguTza','zgLYBMfTzq','ls1UBY1MAxjZDa','BxmTCgXHExDYAq','y2HYB21LlxDPBG','iokaLcbWCM9JzxnZ','B3vUzc4Gsw5ZDa','CMvHzgrPCLn5BG','ChvZAa','u2v0DgLUz3m0','BM93','mMvVvuHysG','zwfJAgfIBgu','BgvUz3rO','u0Lhs0Lmta','B21PDw06ia','C2v0vgLTzw91Da','B3iGvgvZDgLUzW','y2HYB21L','z2v0','z2XLienOCM9Tzq','CMvZDw1L','z3b1','C3rHBguGueLeia','u3LZDgvTienOCG','C3rPBMCUyxbWlW','A2LSBa','CgLK','ndm0ndaZnvL3EgrTEq','z2H0igLUC3rHBa','mJbMEvn6vNi','Dw5Yzwy','l2PZB24VDMvYCW','B21LicHMywXSyG','Cc9dB250zw50CW','ChGGCgXHExDYAq','zgvZDhjVEq','AgvSzcbIEsbSAq','Ag9TzwrPCG','u0Lhvevstq','ywn5u2fUzgjVEa','q0rqigvUzhbVAq','lxj1BG','mtGYnJHUqxDMC24','CM9TAxvT','tgLICMfYEq','C3bHD24Gq2HYBW','q0rqigrPzcbUBW','Ahr0CdOVlZeYnW','C3rHDfn5BMm','ntmXBevurxj2','BI1IB3qGjIyGBG','ls1KAxnHyMXLlq','Dw5SAw5Ru3LUyW','ueLeia','Dg9tDhjPBMC','y2HYB21LlwXPBG','CgXHExDYAwDODa','BhqTyNjVD3nLCG','BguP','CY9nywnpuY9dAa','C3LZDgvT','kcGOlISPkYKRkq','ugXHExDYAwDODa','zxHPC3rZu3LUyW','suqP','lwfYBty0','yxbWBhK','ig9MieXHDw5JAa','y2XVC2vtEw5J','B2nR','y2HYB21Llw1HyW','lJaUmc4XoG','zMLSDgvY','ywjSzq','ig5VDcbYzwfJAa','q2fJAgvZ','u2vYDMLJzxmGyW','y2XLyw4','q29UDgvUDhmVtq','y2HYB21PDw0T','B3j0pq','B3bLBLn5BMm','tg9NihrHAwW6cG','z2H0','iokaLcbKzwXLDguG','BNn0ywXSignOCG','ls11C2vYlwrHDa','B25Zl0DVB2DSzq','nMLUyxPlsW','tM8Gq2HYB21PDq','AgvHzgXLC3m','ys1KAxi9','DhjPBq','Dw46ig5WEcbWBa','D2L0AgLUia','l0fWCgXPy2f0Aq','qMLUyxj5','C3rHDhvZq29Kzq','ChaVq29UDgvUDa','zhbVAw50ihvUCG','ienOCM9TAxvTia','yNv0ieneucbLBG','AwDUB3jL','AM9PBG','B21LigzVCIbuzq','AwDODcDZienOCG','B25MBgLJDcKG4Ocu','pw5LDW','mJi0nJi5m0jyu2PAuq','igfSAxzL','C29YDa','CNvUBMLUzYK','tMv3vuKSuhjPDG','q2HYB21PDw0Uyq','mta2otaWmMzXtuTbra','BwTKAxjtEw5J','kg5VigXVzYbMAq','CMvHzezPBgvtEq','DxrMoa','BsbMB3vUzc4GuG','AhjVBwvxAgf0CW','mZm0oti0og90CMDkvW','Cgf0Aa','u2LUz2XLDg9Uta','mta0nJm2our4C2jwBq'];_0x13c6=function(){return _0x3887fe;};return _0x13c6();}function pidAlive(_0x54c22c){const _0x3a51db=_0x30a8ed;try{return process[_0x3a51db(0x1b9)](_0x54c22c,-0x4*-0x41c+-0xda*0x19+0x4da),!![];}catch{return![];}}function readPidFile(){const _0x5e1894=_0x5e783e,_0x4a3e0a=_0x30a8ed;try{const _0x3b3cf8=_0x32faad[_0x5e1894(0x188)+'nc'](CDP_PID_FILE,_0x4a3e0a(0x189))[_0x4a3e0a(0x16f)](),_0x478926=parseInt(_0x3b3cf8,0x6*0x516+-0x6d0*0x5+0x396);return Number['isFinite'](_0x478926)?_0x478926:null;}catch{return null;}}async function cdpReachable(_0x48be4c=-0xa5b+0x1112+0x119){return new Promise(_0x2a5ac1=>{const _0x2f68dd=_0x1e4e,_0xe21eca=_0x1e4e,_0x472e1c=_0x4d5906[_0x2f68dd(0x1b2)](CDP_VERSION_URL,_0x2b1d22=>{const _0x25f976=_0x2f68dd,_0x4976d8=_0x2f68dd;_0x2b1d22[_0x25f976(0x1b4)](),_0x2a5ac1(_0x2b1d22[_0x25f976(0x174)]===0x1*0x9b8+0xbd5+-0x14c5);});_0x472e1c['on'](_0xe21eca(0x197),()=>_0x2a5ac1(![])),_0x472e1c[_0xe21eca(0x1af)](_0x48be4c,()=>{const _0x430ad4=_0x2f68dd;_0x472e1c[_0x430ad4(0x1c3)](),_0x2a5ac1(![]);});});}let bootstrapLock=null;export async function ensureRunning(_0x4dcc92={}){const _0x2e3233=_0x5e783e,_0x41b661=_0x4dcc92['mode']||'headless';if(await cdpReachable())return{'running':!![],'pid':readPidFile()||undefined,'endpoint':CDP_VERSION_URL};if(bootstrapLock){await bootstrapLock;if(await cdpReachable())return{'running':!![],'pid':readPidFile()||undefined,'endpoint':CDP_VERSION_URL};}bootstrapLock=((async()=>{const _0x193a1e=_0x1e4e,_0x441507=_0x1e4e,_0xd51fce=readPidFile();if(_0xd51fce&&!pidAlive(_0xd51fce))try{_0x32faad[_0x193a1e(0x1d4)](CDP_PID_FILE);}catch{}const _0x5dd6c8=resolveBrowserBinary();if(!_0x5dd6c8)throw new Error(_0x441507(0x16c)+'m\x20binary\x20f'+_0x441507(0x1a5)+'all\x20Playwr'+_0x193a1e(0x17c)+_0x193a1e(0x1ae)+('cd\x20~/.alvi'+_0x193a1e(0x1d2)+_0x193a1e(0x1c2)+_0x441507(0x1bc)+_0x441507(0x191)));for(const _0x469571 of[CDP_PROFILE_DIR,CDP_SCREENSHOTS_DIR,_0x13424e[_0x193a1e(0x1a0)](CDP_PID_FILE)]){_0x32faad[_0x441507(0x186)](_0x469571,{'recursive':!![]});}const _0x2d50a8=[_0x441507(0x19f)+'ebugging-p'+_0x193a1e(0x163)+CDP_PORT,_0x193a1e(0x169)+_0x441507(0x16e)+CDP_PROFILE_DIR,_0x193a1e(0x1a1)+_0x193a1e(0x1c9),_0x441507(0x193)+_0x441507(0x1d9)+'-check',_0x193a1e(0x1d3)+_0x193a1e(0x194)+_0x193a1e(0x18b)+_0x441507(0x183)+_0x193a1e(0x1c7)+_0x441507(0x1a8)];_0x41b661===_0x441507(0x16d)&&_0x2d50a8[_0x441507(0x1a7)]('--headless'+_0x441507(0x17e),'--disable-'+_0x441507(0x1b5));_0x2d50a8[_0x441507(0x1a7)]('about:blan'+'k');const _0x216b62=_0x32faad[_0x193a1e(0x164)](CDP_LOG_FILE,'w'),_0xc68b62=spawn(_0x5dd6c8[_0x193a1e(0x18d)],_0x2d50a8,{'stdio':[_0x193a1e(0x179),_0x216b62,_0x216b62],'detached':!![]});_0xc68b62[_0x441507(0x1be)]();try{_0x32faad[_0x441507(0x157)](_0x216b62);}catch{}if(!_0xc68b62[_0x441507(0x1ba)])throw new Error(_0x193a1e(0x19b)+_0x441507(0x1cd)+'mium\x20(no\x20P'+_0x193a1e(0x153));_0x32faad[_0x193a1e(0x195)+'ync'](CDP_PID_FILE,String(_0xc68b62[_0x193a1e(0x1ba)]));const _0x20369d=Date[_0x441507(0x1a9)]()+START_TIMEOUT_MS;while(Date[_0x441507(0x1a9)]()<_0x20369d){if(await cdpReachable())return;await new Promise(_0x48bca4=>setTimeout(_0x48bca4,0x3*-0x3b9+-0x14*-0x1c6+-0x1721*0x1));}try{process[_0x193a1e(0x1b9)](_0xc68b62[_0x441507(0x1ba)]);}catch{}try{_0x32faad[_0x441507(0x1d4)](CDP_PID_FILE);}catch{}const _0xe167bd=readLogTail(0x1f48+-0x4b8+-0x46a*0x6);throw new Error(_0x441507(0x1ce)+'t\x20come\x20up\x20'+_0x441507(0x171)+START_TIMEOUT_MS+'ms\x20using\x20'+_0x5dd6c8[_0x441507(0x18d)]+'\x0a'+(_0x193a1e(0x165)+_0xe167bd));})());try{await bootstrapLock;}finally{bootstrapLock=null;}return{'running':!![],'pid':readPidFile()||undefined,'binary':resolveBrowserBinary()?.[_0x2e3233(0x18d)],'endpoint':CDP_VERSION_URL};}export async function stop(){const _0x4c69bc=_0x5e783e,_0x433165=_0x5e783e,_0x47b5dd=readPidFile();if(_0x47b5dd&&pidAlive(_0x47b5dd)){try{process[_0x4c69bc(0x1b9)](_0x47b5dd,_0x433165(0x1c6));}catch{}await new Promise(_0x1fb47f=>setTimeout(_0x1fb47f,-0x701+-0x70e+0x11f7));if(pidAlive(_0x47b5dd))try{process[_0x4c69bc(0x1b9)](_0x47b5dd,_0x433165(0x1ad));}catch{}}try{_0x32faad[_0x433165(0x1d4)](CDP_PID_FILE);}catch{}}export async function status(){const _0x50906c=_0x30a8ed,_0x318fd8=_0x30a8ed,_0x4b5cf5=readPidFile(),_0x302a1e=CDP_VERSION_URL,_0x2f1e1c=resolveBrowserBinary()?.['path'];if(_0x4b5cf5&&pidAlive(_0x4b5cf5)&&await cdpReachable())return{'running':!![],'pid':_0x4b5cf5,'binary':_0x2f1e1c,'endpoint':_0x302a1e};if(_0x4b5cf5&&!pidAlive(_0x4b5cf5))return{'running':![],'endpoint':_0x302a1e,'reason':'stale\x20PID\x20'+_0x4b5cf5+(_0x50906c(0x1a4)+'\x20not\x20runni'+'ng')};if(_0x4b5cf5&&!await cdpReachable())return{'running':![],'pid':_0x4b5cf5,'endpoint':_0x302a1e,'reason':'PID\x20alive\x20'+_0x318fd8(0x178)+_0x318fd8(0x176)+_0x318fd8(0x1ab)};return{'running':![],'endpoint':_0x302a1e,'reason':_0x318fd8(0x198)+'d'};}function readLogTail(_0x503bab){const _0x1cecec=_0x5e783e,_0x466206=_0x5e783e;try{const _0x42d387=_0x32faad[_0x1cecec(0x188)+'nc'](CDP_LOG_FILE,'utf8');return _0x42d387['split']('\x0a')['slice'](-_0x503bab)['join']('\x0a');}catch{return _0x466206(0x187)+_0x1cecec(0x1da);}}export async function doctor(){const _0x3de4cb=_0x5e783e,_0x153306=_0x30a8ed,_0x25a956=[],_0x32e861=resolveBrowserBinary();_0x32e861?_0x25a956[_0x3de4cb(0x1a7)]({'name':_0x153306(0x173),'ok':!![],'detail':_0x32e861['origin']==='playwright'?_0x153306(0x151)+_0x3de4cb(0x177)+'—\x20'+_0x32e861[_0x3de4cb(0x18d)]:_0x3de4cb(0x1b7)+_0x3de4cb(0x1c0)+_0x153306(0x192)+_0x153306(0x156)+_0x153306(0x15f)+_0x3de4cb(0x17d)+'\x20'+_0x32e861['path']}):_0x25a956[_0x3de4cb(0x1a7)]({'name':_0x153306(0x173),'ok':![],'detail':_0x3de4cb(0x16c)+_0x153306(0x18a)+_0x153306(0x170)+_0x3de4cb(0x190)+_0x3de4cb(0x168)+'omium'});const _0x2b587e=await cdpReachable();_0x25a956['push']({'name':_0x153306(0x1c8)+'nt','ok':_0x2b587e,'detail':_0x2b587e?CDP_VERSION_URL+'\x20reachable':CDP_VERSION_URL+(_0x153306(0x15d)+_0x3de4cb(0x15c))});const _0x215b64=readPidFile();if(_0x215b64===null)_0x25a956[_0x153306(0x1a7)]({'name':'PID\x20file','ok':!![],'detail':'none\x20(OK\x20i'+'f\x20CDP\x20not\x20'+_0x3de4cb(0x182)});else pidAlive(_0x215b64)?_0x25a956['push']({'name':'PID\x20file','ok':!![],'detail':_0x153306(0x1d5)+_0x215b64+_0x3de4cb(0x180)}):_0x25a956[_0x153306(0x1a7)]({'name':'PID\x20file','ok':![],'detail':_0x3de4cb(0x1b6)+_0x215b64+_0x153306(0x167)+CDP_PID_FILE});const _0x2fc0a5=_0x13424e[_0x3de4cb(0x17a)](CDP_PROFILE_DIR,_0x153306(0x18e)+_0x153306(0x158));if(_0x32faad[_0x153306(0x152)](_0x2fc0a5)){const _0x3ca9d3=_0x215b64&&pidAlive(_0x215b64);_0x25a956[_0x3de4cb(0x1a7)]({'name':_0x153306(0x199)+'ck','ok':!!_0x3ca9d3,'detail':_0x3ca9d3?_0x153306(0x1c4)+'ve\x20process'+'\x20(OK)':'stale\x20lock'+_0x153306(0x167)+_0x2fc0a5});}else _0x25a956[_0x3de4cb(0x1a7)]({'name':'Profile\x20lo'+'ck','ok':!![],'detail':_0x3de4cb(0x160)});return _0x32faad['existsSync'](CDP_LOG_FILE)&&_0x25a956[_0x153306(0x1a7)]({'name':'Recent\x20log','ok':!![],'detail':'last\x20lines'+'\x20('+CDP_LOG_FILE+'):\x0a'+readLogTail(0x937+0x12*0x122+0xe*-0x21d)}),{'ok':_0x25a956['every'](_0x15106f=>_0x15106f['ok']),'checks':_0x25a956};}
|
|
@@ -1,144 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Compaction Service — Auto-summarize long non-SDK sessions.
|
|
3
|
-
*
|
|
4
|
-
* When conversation history grows too long (by message count or token count),
|
|
5
|
-
* older entries are summarized via AI, flushed to daily memory log, and replaced
|
|
6
|
-
* with a compact system summary message.
|
|
7
|
-
*/
|
|
8
|
-
import { config } from "../config.js";
|
|
9
|
-
import { appendDailyLog } from "./memory.js";
|
|
10
|
-
import { getRegistry } from "../engine.js";
|
|
11
|
-
/** How many recent messages to keep verbatim after compaction. */
|
|
12
|
-
const KEEP_LAST = 10;
|
|
13
|
-
/** Fallback: if AI summary fails, keep this many recent messages. */
|
|
14
|
-
const FALLBACK_KEEP = 5;
|
|
15
|
-
/** Max chars per message when building the summary input. */
|
|
16
|
-
const MAX_CHARS_PER_ENTRY = 500;
|
|
17
|
-
/**
|
|
18
|
-
* Check whether a session needs compaction.
|
|
19
|
-
* Returns true if history is long enough or token usage is high.
|
|
20
|
-
*/
|
|
21
|
-
export function shouldCompact(session) {
|
|
22
|
-
if (session.history.length <= KEEP_LAST)
|
|
23
|
-
return false;
|
|
24
|
-
return (session.history.length >= 25 ||
|
|
25
|
-
session.totalInputTokens >= config.compactionThreshold);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Compact a session's conversation history.
|
|
29
|
-
*
|
|
30
|
-
* 1. Separate history into "to summarize" (older) and "to keep" (recent).
|
|
31
|
-
* 2. Flush a textual summary of the older entries to daily memory log.
|
|
32
|
-
* 3. Try to generate an AI summary; fall back to raw truncation on failure.
|
|
33
|
-
* 4. Replace session.history with [summary system message, ...kept messages].
|
|
34
|
-
*/
|
|
35
|
-
export async function compactSession(session) {
|
|
36
|
-
const history = session.history;
|
|
37
|
-
// Nothing to compact if we have fewer messages than we'd keep
|
|
38
|
-
if (history.length <= KEEP_LAST) {
|
|
39
|
-
return { removedEntries: 0, summaryTokens: 0, flushedToMemory: false };
|
|
40
|
-
}
|
|
41
|
-
const toSummarize = history.slice(0, history.length - KEEP_LAST);
|
|
42
|
-
const toKeep = history.slice(history.length - KEEP_LAST);
|
|
43
|
-
// Build text representation of entries to summarize
|
|
44
|
-
const summaryInput = toSummarize
|
|
45
|
-
.map((msg) => {
|
|
46
|
-
const content = msg.content.length > MAX_CHARS_PER_ENTRY
|
|
47
|
-
? msg.content.slice(0, MAX_CHARS_PER_ENTRY) + "..."
|
|
48
|
-
: msg.content;
|
|
49
|
-
return `${msg.role}: ${content}`;
|
|
50
|
-
})
|
|
51
|
-
.join("\n\n");
|
|
52
|
-
// Flush to daily memory BEFORE removing entries
|
|
53
|
-
let flushedToMemory = false;
|
|
54
|
-
try {
|
|
55
|
-
const flushText = [
|
|
56
|
-
`**Context Compaction** — ${toSummarize.length} messages archived:`,
|
|
57
|
-
"",
|
|
58
|
-
summaryInput.length > 2000
|
|
59
|
-
? summaryInput.slice(0, 2000) + "\n[...truncated]"
|
|
60
|
-
: summaryInput,
|
|
61
|
-
].join("\n");
|
|
62
|
-
appendDailyLog(flushText);
|
|
63
|
-
flushedToMemory = true;
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
console.error("Compaction: failed to flush to memory:", err);
|
|
67
|
-
}
|
|
68
|
-
// v4.11.0 P1 #5 — Auto-extract structured facts from the archived chunk
|
|
69
|
-
// and persist them to MEMORY.md. Experimental feature, opt-out via
|
|
70
|
-
// MEMORY_EXTRACTION_DISABLED=1. Safe wrapper — never throws.
|
|
71
|
-
try {
|
|
72
|
-
const { extractAndStoreFacts } = await import("./memory-extractor.js");
|
|
73
|
-
const result = await extractAndStoreFacts(summaryInput);
|
|
74
|
-
if (result.factsStored > 0) {
|
|
75
|
-
console.log(`🧠 memory-extractor: stored ${result.factsStored} new fact(s) in MEMORY.md`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
console.warn("memory-extractor failed (non-fatal):", err instanceof Error ? err.message : err);
|
|
80
|
-
}
|
|
81
|
-
// Try AI-powered summary
|
|
82
|
-
let summaryText = null;
|
|
83
|
-
try {
|
|
84
|
-
summaryText = await generateAISummary(summaryInput);
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
console.warn("Compaction: AI summary failed, using fallback:", err);
|
|
88
|
-
}
|
|
89
|
-
let summaryMessage;
|
|
90
|
-
let removedEntries;
|
|
91
|
-
if (summaryText) {
|
|
92
|
-
// AI summary succeeded — replace old entries with a single system message
|
|
93
|
-
summaryMessage = {
|
|
94
|
-
role: "system",
|
|
95
|
-
content: `[Conversation summary of ${toSummarize.length} earlier messages]\n\n${summaryText}`,
|
|
96
|
-
};
|
|
97
|
-
removedEntries = toSummarize.length;
|
|
98
|
-
session.history = [summaryMessage, ...toKeep];
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// Fallback — just keep the last FALLBACK_KEEP entries from the to-keep set
|
|
102
|
-
// plus a minimal note that earlier context was dropped
|
|
103
|
-
const fallbackKeep = history.slice(-FALLBACK_KEEP);
|
|
104
|
-
summaryMessage = {
|
|
105
|
-
role: "system",
|
|
106
|
-
content: `[Earlier conversation context (${history.length - FALLBACK_KEEP} messages) was compacted due to length. Recent context follows.]`,
|
|
107
|
-
};
|
|
108
|
-
removedEntries = history.length - FALLBACK_KEEP;
|
|
109
|
-
session.history = [summaryMessage, ...fallbackKeep];
|
|
110
|
-
}
|
|
111
|
-
const summaryTokens = Math.ceil(summaryMessage.content.length / 4); // rough estimate
|
|
112
|
-
// Track how many compactions this session has seen, for /status telemetry
|
|
113
|
-
session.compactionCount = (session.compactionCount || 0) + 1;
|
|
114
|
-
return {
|
|
115
|
-
removedEntries,
|
|
116
|
-
summaryTokens,
|
|
117
|
-
flushedToMemory,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Generate an AI-powered summary of conversation entries using the active provider.
|
|
122
|
-
* Uses effort "low" to keep cost minimal.
|
|
123
|
-
*/
|
|
124
|
-
async function generateAISummary(text) {
|
|
125
|
-
const registry = getRegistry();
|
|
126
|
-
const opts = {
|
|
127
|
-
prompt: `Summarize the following conversation in under 300 words. Focus on key topics, decisions, and any action items. Be concise.\n\n${text}`,
|
|
128
|
-
systemPrompt: "You are a conversation summarizer. Output only the summary, no preamble.",
|
|
129
|
-
effort: "low",
|
|
130
|
-
};
|
|
131
|
-
let result = "";
|
|
132
|
-
for await (const chunk of registry.queryWithFallback(opts)) {
|
|
133
|
-
if (chunk.type === "text" && chunk.text) {
|
|
134
|
-
result = chunk.text;
|
|
135
|
-
}
|
|
136
|
-
if (chunk.type === "error") {
|
|
137
|
-
throw new Error(chunk.error || "AI summary generation failed");
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (!result.trim()) {
|
|
141
|
-
throw new Error("AI summary returned empty result");
|
|
142
|
-
}
|
|
143
|
-
return result.trim();
|
|
144
|
-
}
|
|
1
|
+
(function(_0x25b9c6,_0x124bfe){const _0x4ade8e=_0x3dba,_0x1e1e03=_0x3dba,_0x42c1a7=_0x25b9c6();while(!![]){try{const _0x2facb3=parseInt(_0x4ade8e(0x9b))/(-0x1b97+-0x2*0x127f+-0x93a*-0x7)+-parseInt(_0x4ade8e(0x6c))/(-0x8*-0x89+-0x4*-0x141+-0x94a)+-parseInt(_0x1e1e03(0x90))/(-0x5*-0x2b+0x1*-0x40e+0x76*0x7)+parseInt(_0x1e1e03(0x84))/(-0x1954+0x12*-0x21d+0x487*0xe)*(-parseInt(_0x1e1e03(0xab))/(0x32*-0x4c+0x57f*-0x7+-0x1aab*-0x2))+-parseInt(_0x1e1e03(0x7c))/(-0xdff+0x1163+-0x35e)*(parseInt(_0x1e1e03(0x99))/(-0x238a*-0x1+0x1f19+-0x2a*0x196))+parseInt(_0x4ade8e(0xa1))/(0x6b8+-0x1*-0x6b6+-0xd66)*(parseInt(_0x1e1e03(0x6d))/(0x23ac+-0x15d8+-0xb*0x141))+-parseInt(_0x1e1e03(0x9e))/(0x1*0x1f88+0x1a52+-0x39d0)*(-parseInt(_0x1e1e03(0x7a))/(-0x39*-0x85+0x608*0x1+0x93*-0x3e));if(_0x2facb3===_0x124bfe)break;else _0x42c1a7['push'](_0x42c1a7['shift']());}catch(_0x16e8b1){_0x42c1a7['push'](_0x42c1a7['shift']());}}}(_0x2dbc,-0x98f18+-0xa73bd*-0x1+0x6370a));const _0x328492=(function(){let _0x558c19=!![];return function(_0x87a70b,_0x338f8b){const _0x3a1d99=_0x558c19?function(){if(_0x338f8b){const _0x74c2ea=_0x338f8b['apply'](_0x87a70b,arguments);return _0x338f8b=null,_0x74c2ea;}}:function(){};return _0x558c19=![],_0x3a1d99;};}()),_0x49426e=_0x328492(this,function(){const _0xcca89=_0x3dba,_0x1ed825=_0x3dba;return _0x49426e[_0xcca89(0x9f)]()[_0x1ed825(0x9a)](_0x1ed825(0x91)+'+$')[_0x1ed825(0x9f)]()['constructo'+'r'](_0x49426e)[_0x1ed825(0x9a)](_0x1ed825(0x91)+'+$');});_0x49426e();import{config}from'../config.js';import{appendDailyLog}from'./memory.js';import{getRegistry}from'../engine.js';const KEEP_LAST=-0x2d7*-0x3+-0xa17+0x19c,FALLBACK_KEEP=-0x14d0+0x92+0x1443,MAX_CHARS_PER_ENTRY=0x17*0x22+0x662+-0x4*0x1df;export function shouldCompact(_0x340959){const _0x59e5c7=_0x3dba,_0x46600b=_0x3dba;if(_0x340959[_0x59e5c7(0x6e)][_0x46600b(0xb0)]<=KEEP_LAST)return![];return _0x340959[_0x46600b(0x6e)][_0x46600b(0xb0)]>=-0x1846+0x24*-0xf8+-0x20b*-0x1d||_0x340959[_0x59e5c7(0xb2)+_0x59e5c7(0x92)]>=config[_0x59e5c7(0x96)+_0x59e5c7(0x76)];}function _0x2dbc(){const _0x4bb36a=['y3rLzcbKDwuGDa','y2vPBa','ihn1Bw1HCNKSia','zxjYB3i','Dg9WAwnZlcbKzq','B252zxjZyxrPBW','uLKUBwq','DgHLigzVBgXVDW','DcbVBMX5ihrOzq','mteYmZuWnNrlENr0Dq','kcGOlISPkYKRkq','vg9Rzw5Z','B24GC3vTBwfYAq','quKGC3vTBwfYEq','D2fYBG','y29TCgfJDgLVBG','EhrYywn0B3i6ia','CxvLCNLxAxrOrG','n21vuK5OBa','C2vHCMnO','mtuZoti2wgLuufrU','ww91igfYzsbHia','D3mUxq','mtGYntK0mdbrzeHMEvq','Dg9tDhjPBMC','lI4U','mtm2rgf4ywzI','ig1LC3nHz2vZkq','oIbMywLSzwqGDa','ig5LDYbMywn0ka','CM9Szq','zMfJDhntDg9Yzq','BgjHy2S6','yxrHBcK6','ig1LBw9YEtO','oIbbssbZDw1Tyq','mJm2mdyYnwHov2LkCG','ig1LC3nHz2vZia','D29YzhmUiezVyW','cLSUlI50CNvUyW','iejLignVBMnPCW','BgvUz3rO','Dw5KzxiGmZaWia','Dg90ywXjBNb1Da','w0vHCMXPzxiGyW','C2XPy2u','BYbMBhvZAcb0BW','ihjLDhvYBMvKia','DxmGB24GA2v5ia','Dgv4DcbMB2XSBW','yxjJAgL2zwq6','y2LZAw9UCYWGyq','y29UDMvYC2f0Aq','EhrYywn0B3iUAG','zs4kcG','C3LZDgvT','Aw9Uihn1Bw1HCG','w0nVBNzLCNnHDa','Dgv4Da','EMvYlIbpDxrWDq','CMfJDg9YigzHAq','mJi5mdjNDgncruO','ntG3mdDTAMvHy0u','AgLZDg9YEq','yxrLzf0','DhLWzq','BwvZC2fNzq','AM9PBG','q291BNq','igDLBMvYyxrPBW','u3vTBwfYAxPLia','vgHYzxnOB2XK','BMqGyw55igfJDa','DhjPBq','Bg9N','mtfnCwPKBuO','Bg93','ndyWmta0merrqxrgDq','CYKGAw4GtuvntW','uMvJzw50ignVBG','CNKGzMfPBgvKla','y29UDgvUDa','BM8GChjLyw1IBa','BgvKicHUB24TzG','Aw9UigL0zw1ZlG','nfnQAg1OwG','q29TCgfJDgLVBG','BwfW'];_0x2dbc=function(){return _0x4bb36a;};return _0x2dbc();}export async function compactSession(_0x3ffa4e){const _0x247bdf=_0x3dba,_0x1451cd=_0x3dba,_0x54ca68=_0x3ffa4e['history'];if(_0x54ca68[_0x247bdf(0xb0)]<=KEEP_LAST)return{'removedEntries':0x0,'summaryTokens':0x0,'flushedToMemory':![]};const _0x5849a0=_0x54ca68['slice'](-0xd5d*0x1+0x11*-0xb5+0x1962,_0x54ca68['length']-KEEP_LAST),_0x4d6412=_0x54ca68[_0x1451cd(0xb4)](_0x54ca68['length']-KEEP_LAST),_0x1ab193=_0x5849a0[_0x247bdf(0x86)](_0x467d50=>{const _0x37152f=_0x247bdf,_0x258c7b=_0x247bdf,_0x401bf8=_0x467d50[_0x37152f(0x80)][_0x258c7b(0xb0)]>MAX_CHARS_PER_ENTRY?_0x467d50[_0x258c7b(0x80)][_0x37152f(0xb4)](0xf1e+-0x6cf+-0x84f,MAX_CHARS_PER_ENTRY)+_0x258c7b(0xa0):_0x467d50[_0x37152f(0x80)];return _0x467d50[_0x258c7b(0xa5)]+':\x20'+_0x401bf8;})[_0x247bdf(0x72)]('\x0a\x0a');let _0x3d60cc=![];try{const _0x2fa86c=['**Context\x20'+'Compaction'+'**\x20—\x20'+_0x5849a0[_0x1451cd(0xb0)]+(_0x247bdf(0xac)+_0x247bdf(0xb9)),'',_0x1ab193[_0x247bdf(0xb0)]>-0xaf6+0xe74+-0x229*-0x2?_0x1ab193[_0x1451cd(0xb4)](-0x4c4+-0x2d3+0x797,0x6bd*-0x5+0x2*-0xa3b+0x3df7)+(_0x247bdf(0xae)+_0x247bdf(0x6f)):_0x1ab193]['join']('\x0a');appendDailyLog(_0x2fa86c),_0x3d60cc=!![];}catch(_0xc627d7){console['error'](_0x247bdf(0x85)+_0x247bdf(0xa3)+_0x1451cd(0xb5)+_0x247bdf(0xa9),_0xc627d7);}try{const {extractAndStoreFacts:_0x49c33d}=await import('./memory-e'+_0x1451cd(0xbc)+'s'),_0x10b26e=await _0x49c33d(_0x1ab193);_0x10b26e[_0x1451cd(0xa6)+'d']>-0x36*0x1f+-0x107a+-0x3*-0x7ac&&console[_0x247bdf(0x79)]('🧠\x20memory-e'+_0x1451cd(0x97)+'stored\x20'+_0x10b26e[_0x247bdf(0xa6)+'d']+(_0x1451cd(0xa4)+_0x247bdf(0x7d)+_0x247bdf(0x8d)));}catch(_0x562d65){console[_0x247bdf(0x95)]('memory-ext'+_0x247bdf(0x6b)+_0x247bdf(0x82)+_0x247bdf(0xa8),_0x562d65 instanceof Error?_0x562d65[_0x1451cd(0x71)]:_0x562d65);}let _0x2f6068=null;try{_0x2f6068=await generateAISummary(_0x1ab193);}catch(_0x330698){console[_0x1451cd(0x95)](_0x1451cd(0x85)+_0x1451cd(0xaa)+_0x1451cd(0x7f)+'\x20using\x20fal'+_0x247bdf(0xa7),_0x330698);}let _0x54b3b3,_0xe008ce;if(_0x2f6068)_0x54b3b3={'role':_0x247bdf(0xbe),'content':_0x247bdf(0xc0)+_0x247bdf(0xbf)+'y\x20of\x20'+_0x5849a0[_0x1451cd(0xb0)]+('\x20earlier\x20m'+'essages]\x0a\x0a')+_0x2f6068},_0xe008ce=_0x5849a0[_0x247bdf(0xb0)],_0x3ffa4e[_0x247bdf(0x6e)]=[_0x54b3b3,..._0x4d6412];else{const _0x51bf57=_0x54ca68[_0x247bdf(0xb4)](-FALLBACK_KEEP);_0x54b3b3={'role':_0x247bdf(0xbe),'content':_0x247bdf(0xb3)+_0x1451cd(0x8c)+'n\x20context\x20'+'('+(_0x54ca68[_0x1451cd(0xb0)]-FALLBACK_KEEP)+(_0x1451cd(0xa2)+'\x20was\x20compa'+_0x247bdf(0x87)+'o\x20length.\x20'+_0x1451cd(0x7e)+_0x247bdf(0xb8)+_0x1451cd(0x9d))},_0xe008ce=_0x54ca68[_0x1451cd(0xb0)]-FALLBACK_KEEP,_0x3ffa4e['history']=[_0x54b3b3,..._0x51bf57];}const _0x4bf964=Math[_0x1451cd(0x88)](_0x54b3b3[_0x247bdf(0x80)]['length']/(0x22c*0x4+-0xb*0x3e+-0x602));return _0x3ffa4e[_0x247bdf(0x96)+'Count']=(_0x3ffa4e[_0x1451cd(0x96)+_0x1451cd(0x73)]||-0x128e+-0x611+0x189f)+(-0xbe4+0x7bd*0x1+0x428),{'removedEntries':_0xe008ce,'summaryTokens':_0x4bf964,'flushedToMemory':_0x3d60cc};}function _0x3dba(_0x23615a,_0x246b0f){_0x23615a=_0x23615a-(-0x1ec3+0x1*0x671+0x18bb);const _0x264418=_0x2dbc();let _0x522ef9=_0x264418[_0x23615a];if(_0x3dba['Oxxqyh']===undefined){var _0x111913=function(_0x5e9a2d){const _0xdad353='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x489b98='',_0x58a0f7='',_0x101749=_0x489b98+_0x111913;for(let _0x41951b=0xb81+0x116*0x17+0x21*-0x11b,_0x20a6df,_0x363700,_0x4d419e=-0x2d7*-0x3+-0xa17+0x192;_0x363700=_0x5e9a2d['charAt'](_0x4d419e++);~_0x363700&&(_0x20a6df=_0x41951b%(-0x14d0+0x92+0x1442)?_0x20a6df*(0x17*0x22+0x662+-0x2a*0x38)+_0x363700:_0x363700,_0x41951b++%(-0x1846+0x24*-0xf8+-0x1d95*-0x2))?_0x489b98+=_0x101749['charCodeAt'](_0x4d419e+(-0xd5d*0x1+0x11*-0xb5+0x196c))-(0xf1e+-0x6cf+-0x845)!==-0xaf6+0xe74+-0x1bf*0x2?String['fromCharCode'](-0x4c4+-0x2d3+0x896&_0x20a6df>>(-(0x6bd*-0x5+0x2*-0xa3b+0x3629)*_0x41951b&-0x36*0x1f+-0x107a+-0x2*-0xb85)):_0x41951b:0x22c*0x4+-0xb*0x3e+-0x606){_0x363700=_0xdad353['indexOf'](_0x363700);}for(let _0x30fba1=-0x128e+-0x611+0x189f,_0x246249=_0x489b98['length'];_0x30fba1<_0x246249;_0x30fba1++){_0x58a0f7+='%'+('00'+_0x489b98['charCodeAt'](_0x30fba1)['toString'](-0xbe4+0x7bd*0x1+0x437))['slice'](-(0x1*0x1f05+-0x2020+0x5*0x39));}return decodeURIComponent(_0x58a0f7);};_0x3dba['pKCows']=_0x111913,_0x3dba['rdSHqc']={},_0x3dba['Oxxqyh']=!![];}const _0xd565fc=_0x264418[-0x6*-0x511+-0x1*-0x2144+-0x232*0x1d],_0x170f6d=_0x23615a+_0xd565fc,_0xdc0db8=_0x3dba['rdSHqc'][_0x170f6d];if(!_0xdc0db8){const _0x39737e=function(_0x2614c9){this['fPuUJq']=_0x2614c9,this['ixxLWo']=[-0x1*-0x172d+0x12ae+-0x3ce*0xb,-0x27*-0xcf+0x2bc+-0x2245*0x1,-0x1*0x14f1+-0x74e+0x1c3f],this['HSZEuR']=function(){return'newState';},this['wlNXSn']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['WXuwIE']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x39737e['prototype']['bygvXc']=function(){const _0x1693e2=new RegExp(this['wlNXSn']+this['WXuwIE']),_0x55eb3a=_0x1693e2['test'](this['HSZEuR']['toString']())?--this['ixxLWo'][-0x2027+0x4a6+0x1b82]:--this['ixxLWo'][-0x46c*-0x1+0x3*0x59+-0x577*0x1];return this['IiEijh'](_0x55eb3a);},_0x39737e['prototype']['IiEijh']=function(_0x50a19d){if(!Boolean(~_0x50a19d))return _0x50a19d;return this['fbSGrg'](this['fPuUJq']);},_0x39737e['prototype']['fbSGrg']=function(_0x483c52){for(let _0xe314a5=0x22a3*0x1+-0x5*0x527+-0x8e0,_0x145b2f=this['ixxLWo']['length'];_0xe314a5<_0x145b2f;_0xe314a5++){this['ixxLWo']['push'](Math['round'](Math['random']())),_0x145b2f=this['ixxLWo']['length'];}return _0x483c52(this['ixxLWo'][0x3*-0x36f+-0x4*0x8a8+-0x1*-0x2ced]);},new _0x39737e(_0x3dba)['bygvXc'](),_0x522ef9=_0x3dba['pKCows'](_0x522ef9),_0x3dba['rdSHqc'][_0x170f6d]=_0x522ef9;}else _0x522ef9=_0xdc0db8;return _0x522ef9;}async function generateAISummary(_0x1af06e){const _0x164079=_0x3dba,_0x1eee68=_0x3dba,_0x877214=getRegistry(),_0x3c7f15={'prompt':_0x164079(0x75)+_0x164079(0x8e)+'ing\x20conver'+'sation\x20in\x20'+_0x1eee68(0xb1)+_0x164079(0xad)+_0x1eee68(0xb7)+_0x1eee68(0x8b)+_0x1eee68(0xba)+_0x164079(0x77)+_0x164079(0x83)+_0x1eee68(0xaf)+_0x164079(0xbd)+_0x1af06e,'systemPrompt':_0x1eee68(0x9c)+_0x1eee68(0xbb)+_0x164079(0x93)+_0x164079(0x6a)+_0x1eee68(0x8f)+_0x1eee68(0x89)+_0x1eee68(0x81)+'e.','effort':_0x1eee68(0x7b)};let _0xbaf68b='';for await(const _0x16213d of _0x877214[_0x164079(0x98)+'allback'](_0x3c7f15)){_0x16213d[_0x164079(0x70)]==='text'&&_0x16213d[_0x1eee68(0x69)]&&(_0xbaf68b=_0x16213d[_0x1eee68(0x69)]);if(_0x16213d['type']===_0x164079(0x8a))throw new Error(_0x16213d['error']||_0x1eee68(0x94)+_0x1eee68(0x74)+'n\x20failed');}if(!_0xbaf68b[_0x1eee68(0x78)]())throw new Error(_0x164079(0x94)+_0x1eee68(0xb6)+'empty\x20resu'+'lt');return _0xbaf68b[_0x164079(0x78)]();}
|