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 4.16 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;/* 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. */ var _chunkZDWNVWWBcjs = require('./chunk-ZDWNVWWB.cjs');var _chunk5GCADSBNcjs = require('./chunk-5GCADSBN.cjs');var _uuid = require('uuid');var o= (_class =class{__init() {this.initialized=!1}__init2() {this.initPromise=null}constructor(){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);this.adapter=new _chunkZDWNVWWBcjs.a,this.initPromise=this.adapter.ensureDatabaseInitialized().then(()=>{this.initialized=!0,_chunk5GCADSBNcjs.b.call(void 0, "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 (e2){_chunk5GCADSBNcjs.b.call(void 0, "Initial initialization failed, trying again")}try{_chunk5GCADSBNcjs.b.call(void 0, "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:(_chunk5GCADSBNcjs.b.call(void 0, "No existing sessions found, creating a new one"),this.createSession(e))}catch(i){let s=i instanceof Error?i.message:"Unknown error";_chunk5GCADSBNcjs.b.call(void 0, "Error getting current session:",s);try{return _chunk5GCADSBNcjs.b.call(void 0, "Attempting to ensure database is initialized before creating new session"),await this.adapter.ensureDatabaseInitialized(),this.initialized=!0,_chunk5GCADSBNcjs.b.call(void 0, "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),_chunk5GCADSBNcjs.b.call(void 0, "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 _chunk5GCADSBNcjs.b.call(void 0, "Creating emergency session without database checks"),this.adapter.createSession(e)}catch (e3){let s=_uuid.v4.call(void 0, );return _chunk5GCADSBNcjs.b.call(void 0, "Generated emergency session ID directly:",s),s}}}, _class);exports.a = o; /* 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-MF4BUNPN.cjs.map