11import { PluginType , fs } from '@janhq/core'
22import { ConversationalPlugin } from '@janhq/core/lib/plugins'
33import { Conversation } from '@janhq/core/lib/types'
4-
4+ import { join } from 'path'
55/**
66 * JSONConversationalPlugin is a ConversationalPlugin implementation that provides
77 * functionality for managing conversations.
@@ -65,10 +65,10 @@ export default class JSONConversationalPlugin implements ConversationalPlugin {
6565 */
6666 saveConversation ( conversation : Conversation ) : Promise < void > {
6767 return fs
68- . mkdir ( ` conversations/ ${ conversation . _id } ` )
68+ . mkdir ( join ( ' conversations' , conversation . _id ) )
6969 . then ( ( ) =>
7070 fs . writeFile (
71- ` conversations/ ${ conversation . _id } / ${ conversation . _id } .json`,
71+ join ( ' conversations' , conversation . _id , ` ${ conversation . _id } .json`) ,
7272 JSON . stringify ( conversation )
7373 )
7474 )
@@ -79,7 +79,7 @@ export default class JSONConversationalPlugin implements ConversationalPlugin {
7979 * @param conversationId The ID of the conversation to delete.
8080 */
8181 deleteConversation ( conversationId : string ) : Promise < void > {
82- return fs . rmdir ( ` conversations/ ${ conversationId } ` )
82+ return fs . rmdir ( join ( ' conversations' , conversationId ) )
8383 }
8484
8585 /**
@@ -88,7 +88,7 @@ export default class JSONConversationalPlugin implements ConversationalPlugin {
8888 * @returns data of the conversation
8989 */
9090 private async readConvo ( convoId : string ) : Promise < any > {
91- return fs . readFile ( ` conversations/ ${ convoId } / ${ convoId } .json`)
91+ return fs . readFile ( join ( ' conversations' , convoId , ` ${ convoId } .json`) )
9292 }
9393
9494 /**
0 commit comments