* The kernel is the main entry point for the agentara application. * Lazy-creation singleton: the instance is created on first `getInstance()`.
| 24 | * Lazy-creation singleton: the instance is created on first `getInstance()`. |
| 25 | */ |
| 26 | class Kernel { |
| 27 | private _logger = createLogger("kernel"); |
| 28 | private _database!: DataConnection; |
| 29 | private _sessionManager!: SessionManager; |
| 30 | private _taskDispatcher!: TaskDispatcher; |
| 31 | private _messageGateway!: MultiChannelMessageGateway; |
| 32 | private _honoServer!: HonoServer; |
| 33 | |
| 34 | constructor() { |
| 35 | this._initDatabase(); |
| 36 | this._initSessionManager(); |
| 37 | this._initTaskDispatcher(); |
| 38 | this._initMessageGateway(); |
| 39 | this._initServer(); |
| 40 | } |
| 41 | |
| 42 | get database(): DataConnection { |
| 43 | return this._database; |
| 44 | } |
| 45 | |
| 46 | get sessionManager(): SessionManager { |
| 47 | return this._sessionManager; |
| 48 | } |
| 49 | |
| 50 | get taskDispatcher(): TaskDispatcher { |
| 51 | return this._taskDispatcher; |
| 52 | } |
| 53 | |
| 54 | get messageGateway(): MultiChannelMessageGateway { |
| 55 | return this._messageGateway; |
| 56 | } |
| 57 | |
| 58 | get honoServer(): HonoServer { |
| 59 | return this._honoServer; |
| 60 | } |
| 61 | |
| 62 | private _initDatabase(): void { |
| 63 | this._database = new DataConnection({ |
| 64 | ...taskingSchema, |
| 65 | ...sessioningSchema, |
| 66 | ...feishuMessagingSchema, |
| 67 | }); |
| 68 | } |
| 69 | |
| 70 | private _initSessionManager(): void { |
| 71 | this._sessionManager = new SessionManager(this._database.db); |
| 72 | } |
| 73 | |
| 74 | private _initServer(): void { |
| 75 | this._honoServer = new HonoServer(); |
| 76 | } |
| 77 | |
| 78 | private _initTaskDispatcher(): void { |
| 79 | this._taskDispatcher = new TaskDispatcher({ |
| 80 | db: this._database.db, |
| 81 | }); |
| 82 | this._taskDispatcher.route( |
| 83 | "inbound_message", |
nothing calls this directly
no test coverage detected