From ce4c95e6ffe815ac6770022b204af3f636d6ab6a Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 13 Sep 2024 14:32:20 -0700 Subject: [PATCH 1/2] Support `@agent` custom skills --- server/utils/agents/ephemeral.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/server/utils/agents/ephemeral.js b/server/utils/agents/ephemeral.js index a523780b43c..257ab2a4c96 100644 --- a/server/utils/agents/ephemeral.js +++ b/server/utils/agents/ephemeral.js @@ -160,6 +160,27 @@ class EphemeralAgentHandler extends AgentHandler { continue; } + // Load imported plugin. This is marked by `@@` in the array of functions to load. + // and is the @@hubID of the plugin. + if (name.startsWith("@@")) { + const hubId = name.replace("@@", ""); + const valid = ImportedPlugin.validateImportedPluginHandler(hubId); + if (!valid) { + this.log( + `Imported plugin by hubId ${hubId} not found in plugin directory. Skipping inclusion to agent cluster.` + ); + continue; + } + + const plugin = ImportedPlugin.loadPluginByHubId(hubId); + const callOpts = plugin.parseCallOptions(); + this.aibitat.use(plugin.plugin(callOpts)); + this.log( + `Attached ${plugin.name} (${hubId}) imported plugin to Agent cluster` + ); + continue; + } + // Load single-stage plugin. if (!AgentPlugins.hasOwnProperty(name)) { this.log( @@ -192,6 +213,7 @@ class EphemeralAgentHandler extends AgentHandler { AgentPlugins.docSummarizer.name, AgentPlugins.webScraping.name, ...(await agentSkillsFromSystemSettings()), + ...(await ImportedPlugin.activeImportedPlugins()), ]; } @@ -257,6 +279,7 @@ class EphemeralAgentHandler extends AgentHandler { const EventEmitter = require("node:events"); const { writeResponseChunk } = require("../helpers/chat/responses"); +const ImportedPlugin = require("./imported"); /** * This is a special EventEmitter specifically used in the Aibitat agent handler From 95ab441ccb49f7828a10a1bb9bbf8a4e81bf89be Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 13 Sep 2024 14:33:56 -0700 Subject: [PATCH 2/2] move import --- server/utils/agents/ephemeral.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/utils/agents/ephemeral.js b/server/utils/agents/ephemeral.js index 257ab2a4c96..7b05b4adc83 100644 --- a/server/utils/agents/ephemeral.js +++ b/server/utils/agents/ephemeral.js @@ -1,5 +1,6 @@ const AIbitat = require("./aibitat"); const AgentPlugins = require("./aibitat/plugins"); +const ImportedPlugin = require("./imported"); const { httpSocket } = require("./aibitat/plugins/http-socket.js"); const { WorkspaceChats } = require("../../models/workspaceChats"); const { safeJsonParse } = require("../http"); @@ -279,7 +280,6 @@ class EphemeralAgentHandler extends AgentHandler { const EventEmitter = require("node:events"); const { writeResponseChunk } = require("../helpers/chat/responses"); -const ImportedPlugin = require("./imported"); /** * This is a special EventEmitter specifically used in the Aibitat agent handler