File size: 1,375 Bytes
b39afbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * Copyright (c) 2023 MERCENARIES.AI PTE. LTD.
 * All rights reserved.
 */

// ---------------------------------------------------------------------------------------------
// Integration for Chat APIS
// ---------------------------------------------------------------------------------------------

import { type IntegrationsManager } from 'omni-shared';
import { APIIntegration, type IAPIIntegrationConfig } from '../APIIntegration.js';
import {
  getChatHistoryHandler,
  getChatHistoryClientExport,
  appendToChatHandler,
  appendToChatExport,
  clearChatHistoryHandler,
  clearChatHistoryClientExport
} from '../Chat/handlers/chat.js';

interface IChatIntegrationConfig extends IAPIIntegrationConfig {}

class ChatIntegration extends APIIntegration {
  constructor(id: string, manager: IntegrationsManager, config: IChatIntegrationConfig) {
    super(id, manager, config || {});
  }

  async load() {
    this.handlers.set('chatHistory', getChatHistoryHandler);
    this.clientExports.set('chatHistory', getChatHistoryClientExport);

    this.handlers.set('append', appendToChatHandler);
    this.clientExports.set('append', appendToChatExport);

    this.handlers.set('clear', clearChatHistoryHandler);
    this.clientExports.set('clear', clearChatHistoryClientExport);
    return await super.load();
  }
}

export { ChatIntegration, type IChatIntegrationConfig };