feat: publish xianyu hunter hermes skill package

This commit is contained in:
2026-05-06 19:26:45 +08:00
commit 6384156097
59 changed files with 9627 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
import { chromium } from 'playwright';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const USER_DATA_DIR = path.join(__dirname, '..', 'browser-data');
let _context = null;
let _launching = null;
export async function getBrowserContext() {
if (_context) return _context;
if (_launching) return _launching;
_launching = chromium.launchPersistentContext(USER_DATA_DIR, {
headless: false,
viewport: { width: 1366, height: 900 },
locale: 'zh-CN',
args: [
'--disable-blink-features=AutomationControlled',
'--no-first-run',
],
});
_context = await _launching;
_launching = null;
_context.on('close', () => { _context = null; });
return _context;
}
export async function newPage() {
const ctx = await getBrowserContext();
return ctx.newPage();
}
export async function getOpenPagesInfo() {
const ctx = _context;
if (!ctx) return { browserOpen: false, pages: [] };
const pages = await Promise.all(ctx.pages().map(async (page, index) => ({
index,
url: page.url(),
title: await page.title().catch(() => ''),
})));
return { browserOpen: true, pages };
}
export async function closeBrowser() {
if (_context) {
await _context.close().catch(() => {});
_context = null;
}
}