UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

30 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RunInlineJavaScriptCodeTool = void 0; const Tool_1 = require("./Tool"); class RunInlineJavaScriptCodeTool extends Tool_1.Tool { constructor() { super(RunInlineJavaScriptCodeTool.NAME, `Run arbitrary JavaScript code inside of the current webpage. The entire DOM is available, ` + `as well as the overall environment of the webpage itself. The JS code must be of the form:\n` + '```\n' + '() => {\n' + ' // ...some code...\n' + ' return ...some result...\n' + '}\n' + '```', 'RunInlineJavaScriptCodeToolCoreParameters', 'RunInlineJavaScriptCodeToolGptParameters'); } async call(context, parameters) { const result = await context.page.evaluate(parameters.javaScriptCode); return { isSuccessful: true, forLlm: '' + JSON.stringify(result), metadata: null, }; } async callFromGpt(context, parameters) { return this.call(context, parameters); } } exports.RunInlineJavaScriptCodeTool = RunInlineJavaScriptCodeTool; RunInlineJavaScriptCodeTool.NAME = 'runInlineJavaScriptCode'; //# sourceMappingURL=RunInlineJavaScriptCodeTool.js.map