This commit is contained in:
@@ -256,7 +256,7 @@ export { getSessionManager };
|
||||
// 2. Task Session (kind='task'): タスクごとに分離された noVNC session。
|
||||
// BrowseWeb / InteractiveBrowse が ctx.taskId をキーに取得・再利用する。
|
||||
// タスク visibility に基づき認可される。LRU 退避 + idle GC 対象。
|
||||
// 3. Headless 共有 (skip mode): config の captchaSolve != 'novnc' の場合、
|
||||
// 3. Headless 共有 (headless mode): config の displayMode != 'novnc' の場合、
|
||||
// または noVNC が立ち上げられない fallback 経路で使う single Browser。
|
||||
|
||||
let _headlessBrowser: Browser | null = null;
|
||||
@@ -298,7 +298,7 @@ async function getHeadlessBrowser(): Promise<Browser> {
|
||||
*/
|
||||
export async function getCaptchaPoolBrowser(): Promise<Browser> {
|
||||
const config = loadConfig();
|
||||
if (config.browser?.captchaSolve === 'novnc') {
|
||||
if (config.browser?.displayMode === 'novnc') {
|
||||
const sm = getSessionManager();
|
||||
if (sm) {
|
||||
try {
|
||||
@@ -325,7 +325,7 @@ export async function getCaptchaPoolBrowser(): Promise<Browser> {
|
||||
*/
|
||||
export async function getTaskSessionBrowser(ctx: ToolContext): Promise<Browser> {
|
||||
const config = loadConfig();
|
||||
if (config.browser?.captchaSolve === 'novnc' && ctx.taskId) {
|
||||
if (config.browser?.displayMode === 'novnc' && ctx.taskId) {
|
||||
const sm = getSessionManager();
|
||||
if (sm) {
|
||||
try {
|
||||
@@ -557,7 +557,7 @@ async function getJobContext(
|
||||
ctx: ToolContext,
|
||||
): Promise<BrowserContext> {
|
||||
const config = loadConfig();
|
||||
if (config.browser?.captchaSolve === 'novnc' && ctx.taskId) {
|
||||
if (config.browser?.displayMode === 'novnc' && ctx.taskId) {
|
||||
const sm = getSessionManager();
|
||||
if (sm) {
|
||||
try {
|
||||
|
||||
@@ -532,13 +532,12 @@ async function searchViaBrowser(
|
||||
query: string,
|
||||
limit: number,
|
||||
pageTimeout: number,
|
||||
captchaSolve: 'skip' | 'novnc' = 'skip',
|
||||
useNovnc: boolean = false,
|
||||
maxCaptchaPages: number = 5,
|
||||
): Promise<{ results: SearchResult[]; captcha: boolean }> {
|
||||
const url = engine.buildUrl(query, limit);
|
||||
logger.debug(`[WebSearch] ${engine.name} browser search: url=${url}`);
|
||||
|
||||
const useNovnc = captchaSolve === 'novnc';
|
||||
// WebSearch は CAPTCHA Pool の Browser を共有して使う。これにより admin が
|
||||
// 一度 CAPTCHA を解けば Cookie が persistentContexts に残り、別タスクの
|
||||
// WebSearch も同じ Cookie で続行できる (タスク隔離が必要な BrowseWeb と
|
||||
@@ -640,7 +639,7 @@ async function executeWebSearch(
|
||||
|
||||
const { loadConfig } = await import('../../config.js');
|
||||
const appConfig = loadConfig();
|
||||
const captchaSolve = appConfig.browser?.captchaSolve ?? 'skip';
|
||||
const useNovnc = (appConfig.browser?.displayMode ?? 'headless') === 'novnc';
|
||||
const maxCaptchaPages = appConfig.browser?.maxCaptchaPages ?? 5;
|
||||
|
||||
// --- ブラウザ検索: Google → Brave → Yahoo の順に試行 ---
|
||||
@@ -652,7 +651,7 @@ async function executeWebSearch(
|
||||
const methodName = engine.name.toLowerCase();
|
||||
|
||||
try {
|
||||
const { results, captcha } = await searchViaBrowser(engine, query, limit, pageTimeout, captchaSolve, maxCaptchaPages);
|
||||
const { results, captcha } = await searchViaBrowser(engine, query, limit, pageTimeout, useNovnc, maxCaptchaPages);
|
||||
|
||||
if (captcha) {
|
||||
lastBrowserError = `${engine.name} が CAPTCHA を要求しました`;
|
||||
@@ -673,7 +672,7 @@ async function executeWebSearch(
|
||||
resultCount: results.length, outcome: 'success', fallback: isFallback,
|
||||
});
|
||||
// 検索が通った = Pool は CAPTCHA を抜けている。フラグを下ろす
|
||||
if (captchaSolve === 'novnc') markPoolCaptchaPending(false);
|
||||
if (useNovnc) markPoolCaptchaPending(false);
|
||||
return { output: formatted, isError: false };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user