@auto-browse/auto-browse
Version:
AI-powered browser automation
94 lines (93 loc) • 3.39 kB
TypeScript
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as playwright from 'playwright';
import { Tab } from './tab.js';
import type { ImageContent, TextContent } from '@modelcontextprotocol/sdk/types.js';
import type { ModalState, Tool } from './tools/tool.js';
import type { FullConfig } from './config.js';
import type { BrowserContextFactory } from './browserContextFactory.js';
export declare class Context {
readonly tools: Tool[];
readonly config: FullConfig;
private _browserContextPromise;
private _browserContextFactory;
private _tabs;
private _currentTab;
private _modalStates;
private _pendingAction;
private _downloads;
clientVersion: {
name: string;
version: string;
} | undefined;
private static instance;
constructor(tools?: Tool[], config?: FullConfig, browserContextFactory?: BrowserContextFactory);
static getInstance(tools?: Tool[], config?: FullConfig): Context;
clientSupportsImages(): boolean;
modalStates(): ModalState[];
setModalState(modalState: ModalState, inTab: Tab): void;
clearModalState(modalState: ModalState): void;
modalStatesMarkdown(): string[];
tabs(): Tab[];
currentTabOrDie(): Tab;
newTab(): Promise<Tab>;
selectTab(index: number): Promise<void>;
ensureTab(): Promise<Tab>;
listTabsMarkdown(): Promise<string>;
closeTab(index: number | undefined): Promise<string>;
run(tool: Tool, params: Record<string, unknown> | undefined): Promise<{
content?: (ImageContent | TextContent)[];
} | {
content: ({
[x: string]: unknown;
type: "image";
data: string;
mimeType: string;
_meta?: {
[x: string]: unknown;
} | undefined;
} | {
[x: string]: unknown;
type: "text";
text: string;
_meta?: {
[x: string]: unknown;
} | undefined;
} | {
type: string;
text: string;
})[];
}>;
waitForTimeout(time: number): Promise<void>;
private _raceAgainstModalDialogs;
private _javaScriptBlocked;
dialogShown(tab: Tab, dialog: playwright.Dialog): void;
downloadStarted(tab: Tab, download: playwright.Download): Promise<void>;
private _onPageCreated;
private _onPageClosed;
close(): Promise<void>;
private _setupRequestInterception;
private _ensureBrowserContext;
private _setupBrowserContext;
allFramesSnapshot(): Promise<string>;
refLocator(ref: string): playwright.Locator;
createPage(): Promise<playwright.Page>;
existingPage(): playwright.Page;
submitFileChooser(paths: string[]): Promise<void>;
hasFileChooser(): boolean;
clearFileChooser(): void;
}
export declare const context: Context;