@hyperbrowser/agent
Version:
Hyperbrowsers Web Agent
52 lines (51 loc) • 2.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateCompleteActionWithOutputDefinition = exports.CompleteActionDefinition = exports.DEFAULT_ACTIONS = exports.ActionNotFoundError = void 0;
const go_to_url_1 = require("./go-to-url");
const click_element_1 = require("./click-element");
const input_text_1 = require("./input-text");
const complete_1 = require("./complete");
Object.defineProperty(exports, "CompleteActionDefinition", { enumerable: true, get: function () { return complete_1.CompleteActionDefinition; } });
const complete_with_output_schema_1 = require("./complete-with-output-schema");
Object.defineProperty(exports, "generateCompleteActionWithOutputDefinition", { enumerable: true, get: function () { return complete_with_output_schema_1.generateCompleteActionWithOutputDefinition; } });
const extract_1 = require("./extract");
const select_option_1 = require("./select-option");
const scroll_1 = require("./scroll");
const page_back_1 = require("./page-back");
const page_forward_1 = require("./page-forward");
const key_press_1 = require("./key-press");
const thinking_1 = require("./thinking");
const refresh_page_1 = require("./refresh-page");
const pdf_1 = require("./pdf");
/**
* Custom error class for when an action is not found in the registry
* This helps distinguish between general errors and specifically when an action type doesn't exist
*/
class ActionNotFoundError extends Error {
constructor(actionType) {
super(`Action type "${actionType}" not found in the action registry`);
this.name = "ActionNotFoundError";
// Maintains proper stack trace for where our error was thrown (only available on V8)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, ActionNotFoundError);
}
}
}
exports.ActionNotFoundError = ActionNotFoundError;
const DEFAULT_ACTIONS = [
go_to_url_1.GoToURLActionDefinition,
page_back_1.PageBackActionDefinition,
page_forward_1.PageForwardActionDefinition,
refresh_page_1.RefreshPageActionDefinition,
extract_1.ExtractActionDefinition,
click_element_1.ClickElementActionDefinition,
select_option_1.SelectOptionActionDefinition,
scroll_1.ScrollActionDefinition,
input_text_1.InputTextActionDefinition,
key_press_1.KeyPressActionDefinition,
thinking_1.ThinkingActionDefinition,
];
exports.DEFAULT_ACTIONS = DEFAULT_ACTIONS;
if (process.env.GEMINI_API_KEY) {
DEFAULT_ACTIONS.push(pdf_1.PDFActionDefinition);
}