@auto-browse/auto-browse
Version:
AI-powered browser automation
30 lines (29 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.browser_wait = void 0;
const tools_1 = require("@langchain/core/tools");
const zod_1 = require("zod");
/**
* Schema for waiting with descriptions for the AI model
*/
const waitSchema = zod_1.z.object({
time: zod_1.z.number().describe("The time to wait in seconds"),
});
exports.browser_wait = (0, tools_1.tool)(async ({ time }) => {
try {
console.log(`[Wait Tool] Starting operation:`, { time });
// Cap wait time to 10 seconds like in common.ts
const waitTime = Math.min(10000, time * 1000);
await new Promise((f) => setTimeout(f, waitTime));
return `Waited for ${time} seconds`;
}
catch (error) {
const errorMessage = `Failed to wait: ${error instanceof Error ? error.message : "Unknown error"}`;
console.error(`[Wait Tool] Error:`, errorMessage);
return errorMessage;
}
}, {
name: "wait",
description: "Wait for a specified time in seconds",
schema: waitSchema,
});