Files
ai-agent/internal/ai/application/runtime/workflow_runtime.go
T
t 2bbf42b741 refactor(auth): delegate access control to be-system
Remove Agent Desk users, roles, login sessions, tokens, and local permission persistence. Expose the backend as an embeddable ai-agent module with host-provided subject lookup and operation authorization callbacks, and complete the frontend/backend repository split.
2026-08-21 00:41:07 +08:00

38 lines
1.1 KiB
Go

package runtime
import (
"encoding/json"
"code.tczkiot.com/wlw/ai-agent/internal/ai/workflow/dsl"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/errorsx"
"code.tczkiot.com/wlw/ai-agent/internal/repositories"
"github.com/mlogclub/simple/sqls"
)
type resolvedWorkflow struct {
Definition dsl.Definition
WorkflowID int64
VersionID int64
}
func resolveWorkflowVersion(workflowVersionID int64) (resolvedWorkflow, error) {
if workflowVersionID <= 0 {
return resolvedWorkflow{}, errorsx.InvalidParam("workflow version is required")
}
version := repositories.AIWorkflowVersionRepository.Get(sqls.DB(), workflowVersionID)
if version == nil || version.Status != enums.StatusOk {
return resolvedWorkflow{}, errorsx.InvalidParam("workflow version does not exist")
}
var def dsl.Definition
if err := json.Unmarshal([]byte(version.Definition), &def); err != nil {
return resolvedWorkflow{}, errorsx.InvalidParam("workflow definition is invalid")
}
return resolvedWorkflow{
Definition: def,
WorkflowID: version.WorkflowID,
VersionID: version.ID,
}, nil
}