UNPKG

rawi

Version:

Rawi (راوي) is the developer-friendly AI CLI that brings the power of 12 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into

4 lines 3.57 kB
/* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 12 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into an intelligent development workspace. */ import{a as n}from"./chunk-GGXDDXXS.js";import{b as t}from"./chunk-Y7XFV3CR.js";import{v4 as u}from"uuid";var o=class{adapter;initialized=!1;initPromise=null;constructor(){this.adapter=new n,this.initPromise=this.adapter.ensureDatabaseInitialized().then(()=>{this.initialized=!0,t("Database manager initialization complete")}).catch(e=>{console.error("Failed to initialize database during construction:",e)})}async ensureInitialized(){if(!this.initialized){if(this.initPromise)try{await this.initPromise;return}catch{t("Initial initialization failed, trying again")}try{t("Explicitly initializing database"),await this.adapter.ensureDatabaseInitialized(),this.initialized=!0}catch(e){throw console.error("Failed to initialize database:",e),new Error("Database initialization failed")}}}async createSession(e,i){return await this.ensureInitialized(),this.adapter.createSession(e,i)}async getSession(e){return await this.ensureInitialized(),this.adapter.getSession(e)}async getSessions(e={}){return await this.ensureInitialized(),this.adapter.getSessions(e)}async deleteSession(e){return await this.ensureInitialized(),this.adapter.deleteSession(e)}async updateSessionTitle(e,i){return await this.ensureInitialized(),this.adapter.updateSessionTitle(e,i)}async addMessage(e,i,s,a,r,d,c,h){return await this.ensureInitialized(),this.adapter.addMessage(e,i,s,a,r,d,c,h)}async getMessages(e,i){return await this.ensureInitialized(),this.adapter.getMessages(e,i)}async searchMessages(e={}){return await this.ensureInitialized(),this.adapter.searchMessages(e)}async getStats(e){return await this.ensureInitialized(),this.adapter.getStats(e)}async close(){await this.adapter.close()}async getCurrentSession(e){try{await this.ensureInitialized();let i=await this.getSessions({profile:e,limit:1});return i.length>0?i[0].id:(t("No existing sessions found, creating a new one"),this.createSession(e))}catch(i){let s=i instanceof Error?i.message:"Unknown error";t("Error getting current session:",s);try{return t("Attempting to ensure database is initialized before creating new session"),await this.adapter.ensureDatabaseInitialized(),this.initialized=!0,t("Creating new session"),this.createSession(e)}catch(a){let r=a instanceof Error?a.message:"Unknown error";return console.error("Serious error: Cannot initialize database or create session normally:",r),t("Attempting emergency session creation"),this.createEmergencySession(e)}}}async deleteOldSessions(e,i){return await this.ensureInitialized(),this.adapter.deleteOldSessions(e,i)}async vacuum(){return await this.ensureInitialized(),this.adapter.vacuum()}async exportChatHistory(e={}){return await this.ensureInitialized(),this.adapter.exportChatHistory(e)}async createEmergencySession(e){try{return t("Creating emergency session without database checks"),this.adapter.createSession(e)}catch{let s=u();return t("Generated emergency session ID directly:",s),s}}};export{o as a}; /* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 12 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into an intelligent development workspace. */ //# sourceMappingURL=chunk-ABWXKSWH.js.map