diff --git a/packages/shared/nodeSpec/src/nodeSpec.json b/packages/shared/nodeSpec/src/nodeSpec.json index ce5a59427e..57f3b9f8be 100644 --- a/packages/shared/nodeSpec/src/nodeSpec.json +++ b/packages/shared/nodeSpec/src/nodeSpec.json @@ -1259,6 +1259,80 @@ ], "configuration": [] }, + { + "type": "queries/events/eventHistory", + "category": "Flow", + "label": "Event History", + "inputs": [ + { + "name": "flow", + "valueType": "flow" + }, + { + "name": "entries", + "valueType": "integer", + "defaultValue": 10 + } + ], + "outputs": [ + { + "name": "flow", + "valueType": "flow" + }, + { + "name": "events", + "valueType": "array" + }, + { + "name": "strings", + "valueType": "array" + } + ], + "configuration": [ + { + "name": "hiddenProperties", + "valueType": "array", + "defaultValue": [ + "hiddenProperties", + "eventState", + "availableEvents" + ] + }, + { + "name": "eventState", + "valueType": "array", + "defaultValue": [ + "sender", + "agentId" + ] + }, + { + "name": "eventStateProperties", + "valueType": "array", + "defaultValue": [ + "connector", + "client", + "channel", + "sender", + "agentId" + ] + }, + { + "name": "availableEvents", + "valueType": "array", + "defaultValue": [ + "messageReceived", + "messageSend", + "messageStream" + ] + }, + { + "name": "selectedEvents", + "valueType": "array", + "defaultValue": [] + } + ] + }, { "type": "logic/string", "category": "None", diff --git a/plugins/core/src/lib/corePlugin.ts b/plugins/core/src/lib/corePlugin.ts index 76286dd639..488e4a642d 100644 --- a/plugins/core/src/lib/corePlugin.ts +++ b/plugins/core/src/lib/corePlugin.ts @@ -40,13 +40,9 @@ import { corePluginName, coreRemovedNodes, } from './constants' -import { - ON_ERROR, - ON_MESSAGE, - SEND_MESSAGE, - STREAM_MESSAGE, -} from 'communication' +import { EventTypes, ON_ERROR } from 'communication' import { delay } from './nodes/time/delay' +import { queryEventHistory } from './nodes/events/eventHistory' /** * CorePlugin handles all generic events and has its own nodes, dependencies, and values. @@ -85,6 +81,7 @@ export class CorePlugin extends CoreEventsPlugin< searchKnowledge, searchManyKnowledge, delay, + queryEventHistory, ] values = [] coreLLMService: CoreLLMService @@ -120,7 +117,7 @@ export class CorePlugin extends CoreEventsPlugin< defineEvents() { // Define events here this.registerEvent({ - eventName: ON_MESSAGE, + eventName: EventTypes.ON_MESSAGE, displayName: 'Message Received', }) } @@ -131,12 +128,12 @@ export class CorePlugin extends CoreEventsPlugin< defineActions() { // Define actions here this.registerAction({ - actionName: SEND_MESSAGE, + actionName: EventTypes.SEND_MESSAGE, displayName: 'Send Message', handler: this.handleSendMessage.bind(this), }) this.registerAction({ - actionName: STREAM_MESSAGE, + actionName: EventTypes.STREAM_MESSAGE, displayName: 'Stream Message', handler: this.handleSendMessage.bind(this), }) @@ -150,7 +147,10 @@ export class CorePlugin extends CoreEventsPlugin< async initializeFunctionalities() { await this.getLLMCredentials() - this.centralEventBus.on(ON_MESSAGE, this.handleOnMessage.bind(this)) + this.centralEventBus.on( + EventTypes.ON_MESSAGE, + this.handleOnMessage.bind(this) + ) this.client.onMessage(this.handleOnMessage.bind(this)) } @@ -235,8 +235,8 @@ export class CorePlugin extends CoreEventsPlugin< } handleOnMessage(payload: EventPayload) { - const event = this.formatMessageEvent(ON_MESSAGE, payload) - this.emitEvent(ON_MESSAGE, event) + const event = this.formatMessageEvent(EventTypes.ON_MESSAGE, payload) + this.emitEvent(EventTypes.ON_MESSAGE, event) } handleSendMessage(actionPayload: ActionPayload) {