UNPKG

donobu

Version:

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

50 lines 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AgentsPersistenceSqlite = void 0; const DonobuAgentType_1 = require("../models/DonobuAgentType"); /** * A persistence implementation that stores agent-to-config mappings in SQLite. */ class AgentsPersistenceSqlite { constructor(db) { this.db = db; } static async create(db) { return new AgentsPersistenceSqlite(db); } async set(agent, gptConfigName) { const stmt = this.db.prepare(` INSERT OR REPLACE INTO agent_configs (agent, config_name) VALUES (?, ?) `); stmt.run(agent, gptConfigName); } async get(agent) { const stmt = this.db.prepare(` SELECT config_name FROM agent_configs WHERE agent = ? `); const row = stmt.get(agent); return row ? row.config_name : null; } async getAll() { const stmt = this.db.prepare(` SELECT agent, config_name FROM agent_configs `); const rows = stmt.all(); const result = new Map(); // Ensure all agents have an entry for (const agent of DonobuAgentType_1.DonobuAgent) { result.set(agent, null); } // Override with database values for (const row of rows) { if (DonobuAgentType_1.DonobuAgent.includes(row.agent)) { result.set(row.agent, row.config_name); } } return result; } } exports.AgentsPersistenceSqlite = AgentsPersistenceSqlite; //# sourceMappingURL=AgentsPersistenceSqlite.js.map