donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
31 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageAiCacheEntryBuilder = void 0;
const CodeGenerator_1 = require("../../../codegen/CodeGenerator");
/**
* Utility for translating flow metadata into cache entries. By centralising the
* logic here, both the runtime (`PageAi`) and the code generator can build
* matching cache files without duplicating knowledge about the schema.
*/
class PageAiCacheEntryBuilder {
/**
* Produces a cache entry that mirrors the format persisted by the runtime.
*/
static fromMetadata(pageUrl, metadata, toolCallCache) {
return {
pageUrl,
instruction: metadata.overallObjective,
schema: metadata.resultJsonSchema,
allowedTools: metadata.allowedTools,
maxToolCalls: metadata.maxToolCalls,
envVars: metadata.envVars,
runSource: `async ({ page }) => {${toolCallCache
.map((toolCall) => {
return (0, CodeGenerator_1.convertProposedToolCallToPlaywrightCode)(toolCall);
})
.join('\n\n')}}`,
};
}
}
exports.PageAiCacheEntryBuilder = PageAiCacheEntryBuilder;
//# sourceMappingURL=cacheEntryBuilder.js.map