fix(go-agent): add VariableAssigner input form (#16902)

## Summary

- Add the runtime input form for VariableAssigner components
- Allow the component input-form endpoint to resolve VariableAssigner
nodes

## Testing

- `bash build.sh --test ./internal/agent/component/...`
This commit is contained in:
Hz_
2026-07-15 10:47:49 +08:00
committed by GitHub
parent 5cf95d2c0f
commit 276941f7b4
2 changed files with 27 additions and 0 deletions

View File

@@ -129,6 +129,16 @@ func NewVariableAssignerComponent(params map[string]any) (Component, error) {
// Name returns the registered component name.
func (v *VariableAssignerComponent) Name() string { return v.name }
// GetInputForm returns the runtime input form consumed by the Agent UI.
func (v *VariableAssignerComponent) GetInputForm() map[string]any {
return map[string]any{
"items": map[string]any{
"type": "line",
"name": "Items",
},
}
}
// Invoke walks the param.variables list, evaluates each tuple against
// the canvas state, and writes the result back unless the operator
// returned an "ERROR:..." sentinel. The list of refs that were

View File

@@ -245,3 +245,20 @@ func TestVariableAssigner_Registered(t *testing.T) {
t.Errorf("Name()=%q, want VariableAssigner", c.Name())
}
}
func TestVariableAssignerGetInputForm(t *testing.T) {
c, err := New("VariableAssigner", map[string]any{
"variables": []map[string]any{},
})
if err != nil {
t.Fatalf("New(VariableAssigner): %v", err)
}
getter, ok := c.(interface{ GetInputForm() map[string]any })
if !ok {
t.Fatal("VariableAssigner component does not expose GetInputForm")
}
items, ok := getter.GetInputForm()["items"].(map[string]any)
if !ok || items["type"] != "line" || items["name"] != "Items" {
t.Errorf("GetInputForm()[items] = %#v", items)
}
}