Files
OmniRoute/packages/browser-pool/src/interfaces.ts
backryun 7ed8ada432 feat(providers): restore ChatGPT Web via clean-room browser transport (#12239)
Restores ChatGPT Web on a clean-room browser transport, merged on the operator's explicit decision.

Worth stating precisely, because this touches a provenance decision: the PR does not revert #11754. It narrows RETIRED_COMMON_CHATGPT_WEB_PROVIDER_IDS to the single GPL-derived alias cgpt-web and registers chatgpt-web as a separate clean-room id. The old implementation stays retired and blocked; the retirement machinery, its error code and its 410 contract are untouched. All four retirement suites agree with that distinction and pass unchanged.

The 44 protected agent-instruction surfaces this PR touches (AGENTS.md, llm.txt and its 42 mirrors, README) were verified rather than trusted: masking digits and comparing the removed and added line sets gives 264 lines on each side, identical — every change is a provider-count substitution, with no sentence added, removed or reworded.

Reconciled on merge: clean against the tip, with the two chat chokepoints this PR grows (src/sse/handlers/chat.ts +40, open-sse/handlers/chatCore.ts +30) recorded in the file-size baseline under an annotation. Verified that exactly those two caps move and nothing else, so the #12411 ratchet holds. The rebaseline is carried on this branch rather than left in a validation worktree — the propagation mistake that put the 2026-09-02 merge waves base-red in #12434.

Verified: 504/504 across the PR's 44 test files plus all four chatgpt-web retirement suites, check:provider-consistency OK (272 REGISTRY entries, 355 canonical providers), check-file-size OK, and every changed TypeScript file parses.

Thanks @backryun — separating the clean-room id from the retired alias, instead of reopening the old one, is what made this reviewable.
2026-09-02 10:31:41 -03:00

96 lines
3.0 KiB
TypeScript

/**
* interfaces.ts — Shared type definitions for @omniroute/browser-pool.
*
* These types are used by both the package entry and the core stubs.
* The core stubs re-export them so existing import paths remain stable.
*/
import type { BrowserContext, Page } from "playwright";
// ── Browser pool ───────────────────────────────────────
export interface BrowserPoolContextOptions {
cookieDomain: string;
cookieString?: string | null;
storageState?: import("playwright").BrowserContextOptions["storageState"];
warmupUrl?: string | null;
userAgent?: string;
locale?: string;
timezone?: string;
preferCloakbrowser?: boolean;
/** Time (ms) to wait for the warmup page to be ready. */
waitFor?: number;
}
export interface PooledContext {
id: string;
context: BrowserContext;
warmupPage: Page | null;
lastUsed: number;
isStealth: boolean;
}
export interface BrowserPoolMetrics {
browserLaunches: number;
browserLaunchFailures: number;
contextsCreated: number;
contextsReused: number;
contextsEvicted: number;
contextsReleased: number;
contextCreateFailures: number;
shutdowns: number;
lastShutdownReason: string | null;
}
// ── Browser-backed chat ────────────────────────────────
export interface BrowserBackedChatRequest {
/** Pool key — typically a provider id like "duckduckgo-web" or
* "claude-web", optionally suffixed by user/account id. */
poolKey: string;
/** Chat URL the page should submit to (captured via waitForResponse). */
chatUrl: string;
/** Chat page URL to navigate to before typing. */
chatPageUrl: string;
/** The text the user wants to send. */
userMessage: string;
/** Cookie string (raw) to inject into the browser context. */
cookieString?: string | null;
/** Cookie domain (used together with cookieString). */
cookieDomain?: string;
/** Domain for the page's fetch to identify the chat endpoint. */
chatUrlMatchDomain: string;
/** User-Agent string for the browser context. */
userAgent?: string;
/** Locale (BCP 47). Defaults to en-US. */
locale?: string;
/** IANA timezone. Defaults to America/New_York. */
timezone?: string;
/** Selector for the chat input. */
inputSelector: string;
/** Selector for the submit button (optional — falls back to Enter). */
submitButtonSelector?: string;
/** Wait after submit for SSE/JSON to arrive. Default 15 seconds. */
postSubmitWaitMs?: number;
/** Optional AbortSignal. Cancels navigation/submit. */
signal?: AbortSignal | null;
/** Reuse the same context across requests. Default true. */
reuseContext?: boolean;
}
export interface BrowserBackedChatTiming {
acquireContextMs: number;
navigateMs: number;
submitMs: number;
captureResponseMs: number;
totalMs: number;
}
export interface BrowserBackedChatResult {
status: number;
contentType: string | null;
body: Buffer;
isStealth: boolean;
timing: BrowserBackedChatTiming;
}