diff --git a/server/utils/agentFlows/index.js b/server/utils/agentFlows/index.js index 590dd3ccf9f..af0e19ebfe9 100644 --- a/server/utils/agentFlows/index.js +++ b/server/utils/agentFlows/index.js @@ -5,6 +5,15 @@ const { FlowExecutor } = require("./executor"); const { normalizePath } = require("../files"); const { safeJsonParse } = require("../http"); +/** + * @typedef {Object} LoadedFlow + * @property {string} name - The name of the flow + * @property {string} uuid - The UUID of the flow + * @property {Object} config - The flow configuration details + * @property {string} config.description - The description of the flow + * @property {Array<{type: string, config: Object, [key: string]: any}>} config.steps - The steps of the flow. Each step has at least a type and config + */ + class AgentFlows { static flowsDir = process.env.STORAGE_DIR ? path.join(process.env.STORAGE_DIR, "plugins", "agent-flows") @@ -55,7 +64,7 @@ class AgentFlows { /** * Load a flow configuration by UUID * @param {string} uuid - The UUID of the flow to load - * @returns {Object|null} Flow configuration or null if not found + * @returns {LoadedFlow|null} Flow configuration or null if not found */ static loadFlow(uuid) { try { @@ -179,11 +188,13 @@ class AgentFlows { description: `Execute agent flow: ${flow.name}`, plugin: (_runtimeArgs = {}) => ({ name: `flow_${uuid}`, - description: flow.description || `Execute agent flow: ${flow.name}`, + description: + flow.config.description || `Execute agent flow: ${flow.name}`, setup: (aibitat) => { aibitat.function({ name: `flow_${uuid}`, - description: flow.description || `Execute agent flow: ${flow.name}`, + description: + flow.config.description || `Execute agent flow: ${flow.name}`, parameters: { type: "object", properties: variables.reduce((acc, v) => {