Skip to content

Commit

Permalink
Support @agent custom skills (#2280)
Browse files Browse the repository at this point in the history
* Support `@agent` custom skills

* move import
  • Loading branch information
timothycarambat authored Sep 13, 2024
1 parent 297b8aa commit b557a28
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions server/utils/agents/ephemeral.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -160,6 +161,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(
Expand Down Expand Up @@ -192,6 +214,7 @@ class EphemeralAgentHandler extends AgentHandler {
AgentPlugins.docSummarizer.name,
AgentPlugins.webScraping.name,
...(await agentSkillsFromSystemSettings()),
...(await ImportedPlugin.activeImportedPlugins()),
];
}

Expand Down

0 comments on commit b557a28

Please sign in to comment.