smooth-operator-agent-tools
Version:
Node.js client library for Smooth Operator Agent Tools - a toolkit for programmers developing Computer Use Agents on Windows systems
117 lines • 3.84 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChromeApi = void 0;
/**
* API endpoints for Chrome browser operations
*/
class ChromeApi {
/**
* Creates a new instance of the ChromeApi
* @param client The SmoothOperatorClient instance
*/
constructor(client) {
this.client = client;
}
/**
* Opens Chrome browser (Playwright-managed instance)
* @param url Optional URL to navigate to immediately
* @param strategy Optional strategy for opening Chrome
* @returns SimpleResponse indicating success or failure
*/
async openChrome(url, strategy) {
return this.client.post('/tools-api/system/open-chrome', { url, strategy });
}
/**
* Gets detailed analysis of current Chrome tab including interactive elements
* @returns ChromeTabDetails with CSS selectors for key elements
*/
async explainCurrentTab() {
return this.client.post('/tools-api/chrome/current-tab/explain', {});
}
/**
* Navigate to a URL in the current Chrome tab
* @param url URL to navigate to
* @returns Action response
*/
async navigate(url) {
return this.client.post('/tools-api/chrome/navigate', { url });
}
/**
* Reload the current Chrome tab
* @returns Action response
*/
async reload() {
return this.client.post('/tools-api/chrome/reload', {});
}
/**
* Open a new Chrome tab
* @param url Optional URL to navigate to
* @returns Action response
*/
async newTab(url) {
return this.client.post('/tools-api/chrome/new-tab', { url });
}
/**
* Clicks element in Chrome tab using CSS selector
* @param selector CSS selector from explainCurrentTab
* @returns Action response with success status
*/
async clickElement(selector) {
return this.client.post('/tools-api/chrome/click-element', { selector });
}
/**
* Navigate back in the current Chrome tab
* @returns Action response
*/
async goBack() {
return this.client.post('/tools-api/chrome/go-back', {});
}
/**
* Simulate input in an element in the current Chrome tab
* @param selector CSS selector of the element to input text into
* @param text Text to input
* @returns Action response
*/
async simulateInput(selector, text) {
return this.client.post('/tools-api/chrome/simulate-input', { selector, text });
}
/**
* Get the DOM of the current Chrome tab
* @returns Action response with DOM content
*/
async getDom() {
return this.client.post('/tools-api/chrome/get-dom', {});
}
/**
* Get the text content of the current Chrome tab
* @returns Action response with text content
*/
async getText() {
return this.client.post('/tools-api/chrome/get-text', {});
}
/**
* Executes JavaScript in Chrome tab and returns result
* @param script JavaScript code to run
* @returns ChromeScriptResponse with execution result
*/
async executeScript(script) {
return this.client.post('/tools-api/chrome/execute-script', { script });
}
/**
* Generate and execute JavaScript based on a description
* @param taskDescription Description of what the JavaScript should do
* @returns ChromeScriptResponse with execution result
*/
async generateAndExecuteScript(taskDescription) {
return this.client.post('/tools-api/chrome/generate-and-execute-script', { taskDescription });
}
/**
* Returns a string representation of the ChromeApi class.
* @returns The string "ChromeApi".
*/
toString() {
return 'ChromeApi';
}
}
exports.ChromeApi = ChromeApi;
//# sourceMappingURL=chrome-api.js.map
;