feat: Implement AI Agent Workflow Binding functionality

- Added aiAgentWorkflowBindingRepository for managing workflow bindings associated with AI agents.
- Enhanced agentRevisionService to include workflow bindings in agent revisions.
- Updated aIAgentService to handle workflow bindings during agent creation and updates.
- Introduced ai_agent_workflow_binding_service for managing workflow binding logic.
- Created new API endpoints for fetching, creating, updating, and deleting AI workflows.
- Developed a new dashboard page for managing AI workflows.
- Updated frontend components to support workflow binding management in agent configuration.
- Added necessary tests for workflow binding functionality and updated existing tests for compatibility.
- Translated relevant UI texts and messages for workflow management.
This commit is contained in:
mlogclub
2026-07-25 15:24:49 +08:00
parent e4ad83dc20
commit 7b86fd1f09
21 changed files with 590 additions and 136 deletions
+54 -3
View File
@@ -241,7 +241,7 @@ export type AIAgent = {
knowledgeBaseIds: number[]
skillIds: number[]
skills: { id: number; name: string }[]
directTools: {
directTools: {
toolCode: string
serverCode: string
toolName: string
@@ -249,6 +249,7 @@ export type AIAgent = {
description: string
arguments?: Record<string, string>
}[]
workflowBindings: AIAgentWorkflowBinding[]
workflowVersionId: number
publishedRevisionId: number
workflowPublished: boolean
@@ -289,6 +290,27 @@ export type CreateAIAgentPayload = {
description: string
arguments?: Record<string, string>
}[]
workflowBindings: AIAgentWorkflowBindingInput[]
}
export type AIAgentWorkflowBinding = {
id: number
workflowId: number
workflowVersionId: number
workflowName: string
workflowVersion: number
toolName: string
triggerInstruction: string
priority: number
enabled: boolean
}
export type AIAgentWorkflowBindingInput = {
workflowVersionId: number
toolName: string
triggerInstruction: string
priority: number
enabled: boolean
}
export type UpdateAIAgentPayload = CreateAIAgentPayload & {
@@ -437,10 +459,12 @@ export type AIWorkflowValidationResult = {
export type CreateAIWorkflowPayload = {
name: string
description: string
agentId: number
agentId?: number
definition: AIWorkflowDefinition
}
export type UpdateAIWorkflowPayload = CreateAIWorkflowPayload & { id: number }
export type CreateAdminQuickReplyPayload = {
groupName: string
title: string
@@ -1013,6 +1037,26 @@ export function fetchAIAgentWorkflow(agentId: number) {
return request<AIWorkflow>(`/api/dashboard/ai-agent/${agentId}/workflow`)
}
export function fetchAIWorkflows(query?: Record<string, string | number | undefined>) {
return request<PageResult<AIWorkflow>>(`/api/dashboard/ai-workflow/list${toQueryString(query)}`)
}
export function fetchAIWorkflow(id: number) {
return request<AIWorkflow>(`/api/dashboard/ai-workflow/${id}`)
}
export function createAIWorkflow(payload: CreateAIWorkflowPayload) {
return request<AIWorkflow>("/api/dashboard/ai-workflow/create", { method: "POST", body: JSON.stringify(payload) })
}
export function updateAIWorkflow(payload: UpdateAIWorkflowPayload) {
return request<void>("/api/dashboard/ai-workflow/update", { method: "POST", body: JSON.stringify(payload) })
}
export function deleteAIWorkflow(id: number) {
return request<void>("/api/dashboard/ai-workflow/delete", { method: "POST", body: JSON.stringify({ id }) })
}
export function saveAIAgentWorkflow(payload: CreateAIWorkflowPayload) {
return request<AIWorkflow>("/api/dashboard/ai-agent/workflow/save", {
method: "POST",
@@ -1039,12 +1083,19 @@ export function fetchAIWorkflowVersions(query?: Record<string, string | number |
}
export function validateAIWorkflow(definition: AIWorkflowDefinition) {
return request<AIWorkflowValidationResult>("/api/dashboard/ai-agent/workflow/validate", {
return request<AIWorkflowValidationResult>("/api/dashboard/ai-workflow/validate", {
method: "POST",
body: JSON.stringify({ definition }),
})
}
export function publishAIWorkflow(workflowId: number, definition: AIWorkflowDefinition) {
return request<AIWorkflowVersion>("/api/dashboard/ai-workflow/publish", {
method: "POST",
body: JSON.stringify({ workflowId, definition }),
})
}
export function publishAIAgentWorkflow(agentId: number, definition: AIWorkflowDefinition) {
return request<AIWorkflowVersion>("/api/dashboard/ai-agent/workflow/publish", {
method: "POST",
+6
View File
@@ -193,6 +193,12 @@ export const dashboardNavSections: DashboardNavSectionConfig[] = [
icon: <MessageSquareMoreIcon />,
requiredPermission: "aiAgent.view",
},
{
titleKey: "nav.workflows",
url: "/dashboard/ai-workflows",
icon: <WorkflowIcon />,
requiredPermission: "aiAgent.view",
},
{
titleKey: "nav.skillDefinition",
url: "/dashboard/skill-definition",