mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-07-04 11:37:57 +02:00
25 lines
731 B
Go
25 lines
731 B
Go
package workflow
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/cloudwego/eino/compose"
|
|
)
|
|
|
|
// compileAgentSubgraph wraps an Agent canvas node as an Eino subgraph (AddGraphNode best practice).
|
|
func compileAgentSubgraph(_ context.Context, node graphNode) (compose.AnyGraph, error) {
|
|
n := node
|
|
innerID := n.ID + "__agent"
|
|
g := compose.NewGraph[WorkflowNodeOutput, WorkflowNodeOutput]()
|
|
_ = g.AddLambdaNode(innerID, compose.InvokableLambda(func(runCtx context.Context, _ WorkflowNodeOutput) (WorkflowNodeOutput, error) {
|
|
return runWorkflowNodeLambda(runCtx, n)
|
|
}))
|
|
if err := g.AddEdge(compose.START, innerID); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := g.AddEdge(innerID, compose.END); err != nil {
|
|
return nil, err
|
|
}
|
|
return g, nil
|
|
}
|