feat: Enhance AI Workflow with Variable Contracts and Input Mapping

- Added ConfigSchema, InputSchema, OutputSchema, and DefaultInputs to AIWorkflowNodeSpecResponse.
- Implemented BuildAIWorkflowNodeSpecs to include variable contracts for start and send_reply nodes.
- Introduced applyAutoInputMappings to automatically map inputs based on node connections.
- Enhanced validation to check for required input mappings in workflows.
- Updated workflow editor to support variable selection for node inputs.
- Translated node names and labels to Chinese for better localization.
- Added tests for variable mapping and validation logic.
This commit is contained in:
mlogclub
2026-06-22 18:33:39 +08:00
parent 8a2c076691
commit d1f39ae57e
19 changed files with 1332 additions and 73 deletions
+32 -6
View File
@@ -1,5 +1,7 @@
package registry
import "agent-desk/internal/ai/workflow/dsl"
type NodeRiskLevel string
const (
@@ -8,13 +10,37 @@ const (
NodeRiskLevelHigh NodeRiskLevel = "high"
)
type VariableType string
const (
VariableTypeString VariableType = "string"
VariableTypeInteger VariableType = "integer"
VariableTypeBoolean VariableType = "boolean"
VariableTypeObject VariableType = "object"
VariableTypeStringArray VariableType = "array<string>"
VariableTypeIntegerArray VariableType = "array<int>"
VariableTypeObjectArray VariableType = "array<object>"
VariableTypeAny VariableType = "any"
)
type VariableSpec struct {
Name string `json:"name"`
Type VariableType `json:"type"`
Required bool `json:"required,omitempty"`
Description string `json:"description"`
}
type NodeSpec struct {
Type string `json:"type"`
Title string `json:"title"`
Description string `json:"description"`
RiskLevel NodeRiskLevel `json:"riskLevel"`
Interruptible bool `json:"interruptible"`
RequiresConfirmationPredecessor bool `json:"requiresConfirmationPredecessor"`
Type string `json:"type"`
Title string `json:"title"`
Description string `json:"description"`
RiskLevel NodeRiskLevel `json:"riskLevel"`
Interruptible bool `json:"interruptible"`
RequiresConfirmationPredecessor bool `json:"requiresConfirmationPredecessor"`
ConfigSchema any `json:"configSchema,omitempty"`
InputSchema []VariableSpec `json:"inputSchema,omitempty"`
OutputSchema []VariableSpec `json:"outputSchema,omitempty"`
DefaultInputs map[string]dsl.VariableSelector `json:"defaultInputs,omitempty"`
}
type Registry struct {