UNPKG

rawi

Version:

Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 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.58 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true});/* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 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 _chunkRFF4VG5Fcjs = require('./chunk-RFF4VG5F.cjs');var _chunkEZDARBSPcjs = require('./chunk-EZDARBSP.cjs');var g=class{#t;constructor(e){this.#t=e||new _chunkEZDARBSPcjs.a}async createSession(e,s={}){try{let{title:t,generateTitle:n,type:o="ask"}=s,r=t;return n&&!t&&(r=await this.#i(e)),await this.#t.createSession(e,r,o)}catch(t){throw new (0, _chunkRFF4VG5Fcjs.c)(`Failed to create session: ${t instanceof Error?t.message:"Unknown error"}`,t instanceof Error?t:void 0)}}async getSession(e,s){try{let t=await this.#t.getSession(e);if(!t)throw new (0, _chunkRFF4VG5Fcjs.a)(e,s||"unknown");if(s&&t.profile!==s)throw new (0, _chunkRFF4VG5Fcjs.b)(e,s,t.profile);return t}catch(t){throw t instanceof _chunkRFF4VG5Fcjs.a||t instanceof _chunkRFF4VG5Fcjs.b?t:new (0, _chunkRFF4VG5Fcjs.c)(`Failed to retrieve session: ${t instanceof Error?t.message:"Unknown error"}`,t instanceof Error?t:void 0)}}async listSessions(e={}){try{let{profile:s,limit:t=10,fromDate:n,toDate:o,type:r}=e;return(await this.#t.getSessions({profile:s,limit:t,fromDate:n,toDate:o,type:r})).map(i=>this.#e(i))}catch(s){throw new (0, _chunkRFF4VG5Fcjs.c)(`Failed to list sessions: ${s instanceof Error?s.message:"Unknown error"}`,s instanceof Error?s:void 0)}}async deleteSession(e,s={}){try{let{force:t=!1}=s;t||await this.getSession(e);let n=await this.#t.deleteSession(e);if(!n&&!t)throw new (0, _chunkRFF4VG5Fcjs.a)(e,"unknown");return n}catch(t){throw t instanceof _chunkRFF4VG5Fcjs.a||t instanceof _chunkRFF4VG5Fcjs.b?t:new (0, _chunkRFF4VG5Fcjs.c)(`Failed to delete session: ${t instanceof Error?t.message:"Unknown error"}`,t instanceof Error?t:void 0)}}async updateSessionTitle(e,s,t){try{await this.getSession(e,t);let n=await this.#t.updateSessionTitle(e,s);if(!n)throw new (0, _chunkRFF4VG5Fcjs.a)(e,t||"unknown");return n}catch(n){throw n instanceof _chunkRFF4VG5Fcjs.a||n instanceof _chunkRFF4VG5Fcjs.b?n:new (0, _chunkRFF4VG5Fcjs.c)(`Failed to update session title: ${n instanceof Error?n.message:"Unknown error"}`,n instanceof Error?n:void 0)}}async exportSessions(e,s={}){try{let{profile:t,sessions:n}=s,o,r={};if(n&&n.length>0){o=[];for(let i of n)try{let h=await this.getSession(i,t);o.push(h),r[i]=await this.#t.getMessages(i)}catch(h){if(!(h instanceof _chunkRFF4VG5Fcjs.a||h instanceof _chunkRFF4VG5Fcjs.b))throw h}}else{let i=await this.#t.exportChatHistory({profile:t});o=i.sessions,r=i.messages}let l=await this.#t.getStats(t);return{sessions:o,messages:r,stats:l}}catch(t){throw new (0, _chunkRFF4VG5Fcjs.c)(`Failed to export sessions: ${t instanceof Error?t.message:"Unknown error"}`,t instanceof Error?t:void 0)}}async getSessionStats(e){try{let s=await this.#t.getStats(e),t=await this.#t.getSessions({profile:e,limit:1e3});return{messageCount:s.totalMessages,createdAt:t.length>0?t[t.length-1].createdAt:"",updatedAt:t.length>0?t[0].updatedAt:"",duration:this.#n(t),providers:this.#o(),models:this.#r()}}catch(s){throw new (0, _chunkRFF4VG5Fcjs.c)(`Failed to get session statistics: ${s instanceof Error?s.message:"Unknown error"}`,s instanceof Error?s:void 0)}}async selectSession(){throw new Error("Session selection must be implemented in CLI layer")}#e(e){let s=new Date,t=new Date(e.updatedAt),n=s.getTime()-t.getTime();return{id:e.id,title:e.title||"Untitled Chat",profile:e.profile,createdAt:e.createdAt,updatedAt:e.updatedAt,messageCount:e.messageCount,lastActivity:e.updatedAt,age:this.#s(n)}}#s(e){let s=Math.floor(e/1e3),t=Math.floor(s/60),n=Math.floor(t/60),o=Math.floor(n/24);return o>0?`${o}d ago`:n>0?`${n}h ago`:t>0?`${t}m ago`:`${s}s ago`}#n(e){if(e.length===0)return"0";let s=new Date(e[e.length-1].createdAt),t=new Date(e[0].createdAt);return`${Math.floor((t.getTime()-s.getTime())/(1e3*60*60*24))} days`}#o(){return[]}#r(){return[]}async#i(e){return`Chat Session ${(await this.#t.getSessions({profile:e,limit:1e3})).length+1}`}};exports.a = g; /* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 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-IBIBJOYA.cjs.map