core

package
v0.0.0-...-c693505 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 流水线状态常量
	StatusRunning   = "RUNNING"
	StatusFailed    = "FAILED"
	StatusSuccess   = "SUCCESS"
	StatusTerminate = "ABORTED"
	StatusPaused    = "PAUSED"
	StatusUnknown   = "UNKNOWN"
	StatusCancelled = "CANCELLED"
	StatusStopped   = "STOPPED"

	// 流水线事件常量
	EventPipelineInit                = "pipeline-init"
	EventPipelineStart               = "pipeline-start"
	EventPipelineFinish              = "pipeline-finish"
	EventPipelineExecutorPrepare     = "pipeline-executor-prepare"
	EventPipelineExecutorPrepareDone = "pipeline-executor-prepare-done"
	EventPipelineNodeStart           = "pipeline-node-start"
	EventPipelineNodeFinish          = "pipeline-node-finish"
	EventPipelineNodeFailed          = "pipeline-node-failed"
	EventPipelineCancelled           = "pipeline-cancelled"
	EventPipelineStatusUpdate        = "pipeline-status-update"
	EventPipelinePaused              = "pipeline-paused"
	EventPipelineResumed             = "pipeline-resumed"
	EventPipelineGraphModified       = "pipeline-graph-modified"
)

Variables

View Source
var (
	ErrInvalidGraph = errors.New("invalid graph")
	ErrHasCycle     = errors.New("has cycle")

	// 动态修改相关错误
	ErrPipelineRunning    = errors.New("pipeline is running, cannot modify")
	ErrNodeNotFound       = errors.New("node not found in graph")
	ErrEdgeNotFound       = errors.New("edge not found in graph")
	ErrNodeAlreadyRunning = errors.New("node is currently running, cannot remove")
	ErrInvalidState       = errors.New("invalid state for this operation")

	// 配置更新相关错误
	ErrImmutableField      = errors.New("immutable field cannot be updated")
	ErrNodeAlreadyExecuted = errors.New("node already executed, cannot remove or modify")
)

Functions

func GetValue

func GetValue(v interface{}) interface{}

GetValue 获取字段值 兼容简单值和 FieldItem

func NewUUID

func NewUUID() string

NewUUID 生成新的UUID(去除连字符格式)

Types

type AIConfig

type AIConfig struct {
	Intent      string   `yaml:"intent"`      // 核心意图描述
	Constraints []string `yaml:"constraints"` // 关键约束列表
	Template    string   `yaml:"template"`    // 模板标识
	GeneratedAt string   `yaml:"generatedAt"` // 生成时间
	Version     int      `yaml:"version"`     // 版本号
}

AIConfig AI配置结构

type ExecutorConfig

type ExecutorConfig struct {
	Type        string                 `yaml:"type"`
	Description string                 `yaml:"description,omitempty"` // 执行器使用场景描述
	Config      map[string]interface{} `yaml:"config"`
}

ExecutorConfig 执行器配置结构

type ExecutorRuntimeInfo

type ExecutorRuntimeInfo struct {
	Type       string                 `yaml:"type"`           // executor 类型: docker, k8s, local, ssh
	InstanceId string                 `yaml:"instanceId"`     // executor 实例ID (如容器ID/Pod名称)
	Status     string                 `yaml:"status"`         // executor 状态: PREPARED, RUNNING, DESTROYED
	Info       map[string]interface{} `yaml:"info,omitempty"` // 其��� executor 特定信息
}

ExecutorRuntimeInfo Executor运行时信息

type ExtractConfig

type ExtractConfig struct {
	// 提取类型:codec-block (默认) 或 regex
	Type string `yaml:"type"`

	// 正则表达式模式(当 type=regex 时使用)
	// key: 提取结果的键名
	// value: 正则表达式,必须包含一个捕获组
	Patterns map[string]string `yaml:"patterns,omitempty"`

	// 输出大小限制(字节),超过限制的输出将被截断
	// 0 表示无限制,默认为 1MB
	MaxOutputSize int `yaml:"maxOutputSize,omitempty"`
}

ExtractConfig 输出提取配置

type FieldItem

type FieldItem struct {
	Value       interface{} `yaml:"value"`       // 字段值
	Description string      `yaml:"description"` // 字段描述(AI 生成时的参考)
	SrcNode     string      `yaml:"srcNode"`     // 来源节点ID(初始化为空)
}

FieldItem 单个字段的完整定义 用于 Param 和 Metadata.Data 的每个字段

func ConvertToFieldItem

func ConvertToFieldItem(v interface{}) FieldItem

ConvertToFieldItem 将任意值转换为 FieldItem 支持向后兼容:简单值、完整格式、map 格式

func (*FieldItem) UnmarshalYAML

func (fi *FieldItem) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML 实现 yaml.Unmarshaler 接口 支持两种格式: 1. 简单值: key: value -> FieldItem{Value: value} 2. 完整格式: key: {value: xxx, description: yyy}

type HTTPMetadataConfig

type HTTPMetadataConfig struct {
	URL     string            `yaml:"url"`
	Method  string            `yaml:"method"`
	Headers map[string]string `yaml:"headers"`
	Timeout string            `yaml:"timeout"`
}

HTTPMetadataConfig HTTP元数据配置

type InputRequestInfo

type InputRequestInfo struct {
	StepName string `yaml:"stepName"` // 请求输入的步骤名称
	Prompt   string `yaml:"prompt"`   // 显示给用户的提示信息
	Type     string `yaml:"type"`     // 输入类型: text/password/confirm
}

InputRequestInfo 输入请求信息

type LoggingConfig

type LoggingConfig struct {
	Description string            `yaml:"description,omitempty"` // 日志配置用途描述
	Endpoint    string            `yaml:"endpoint"`
	Headers     map[string]string `yaml:"headers"`
	Timeout     string            `yaml:"timeout"`
	Retry       int               `yaml:"retry"`
}

LoggingConfig 日志配置结构

type MetadataConfig

type MetadataConfig struct {
	Type        string                 `yaml:"type"`
	Description string                 `yaml:"description,omitempty"` // 描述 metadata 的用途
	Data        map[string]interface{} `yaml:"data"`
}

MetadataConfig 元数据配置结构

type NodeConfig

type NodeConfig struct {
	Id          string                 `yaml:"id,omitempty"`          // 节点ID (UUID,无连字符)
	Name        string                 `yaml:"name,omitempty"`        // 节点显示名称
	Description string                 `yaml:"description,omitempty"` // 节点业务功能描述
	Executor    string                 `yaml:"executor"`
	Image       string                 `yaml:"image"`
	Steps       []Step                 `yaml:"steps"`
	Config      map[string]interface{} `yaml:"config,omitempty"`
	Extract     *ExtractConfig         `yaml:"extract,omitempty"` // 提取配置
	Runtime     *NodeRuntimeStatus     `yaml:"runtime,omitempty"` // 运行时状态 (可选)
}

NodeConfig 节点配置结构

type NodeRuntimeStatus

type NodeRuntimeStatus struct {
	Id           string                 `yaml:"id"`                     // 节点UUID
	Status       string                 `yaml:"status"`                 // 节点状态
	StartTime    string                 `yaml:"startTime,omitempty"`    // 开始时间
	EndTime      string                 `yaml:"endTime,omitempty"`      // 结束时间
	Steps        []StepRuntimeStatus    `yaml:"steps"`                  // 步骤状态列表
	Executor     *ExecutorRuntimeInfo   `yaml:"executor,omitempty"`     // Executor 信息
	Custom       map[string]interface{} `yaml:"custom,omitempty"`       // 自定义扩展字段
	InputChan    chan []byte            `yaml:"-"`                      // 交互式输入通道(不序列化到YAML)
	InputRequest *InputRequestInfo      `yaml:"inputRequest,omitempty"` // 当前输入请求信息(PAUSED状态时有效)
}

NodeRuntimeStatus 节点运行时状态

type PipelineConfig

type PipelineConfig struct {
	Version           string                    `yaml:"Version"`
	Name              string                    `yaml:"Name"`
	Metadate          MetadataConfig            `yaml:"Metadate"`
	AI                AIConfig                  `yaml:"AI"`
	Param             map[string]interface{}    `yaml:"Param"`
	Executors         map[string]ExecutorConfig `yaml:"Executors"`
	Logging           LoggingConfig             `yaml:"Logging"`
	Graph             string                    `yaml:"Graph"`
	Nodes             map[string]NodeConfig     `yaml:"Nodes"`
	MaxLoopIterations int                       `yaml:"MaxLoopIterations"` // 循环图最大迭代次数(默认 100)
}

PipelineConfig 流水线配置结构

type RedisMetadataConfig

type RedisMetadataConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	DB       int    `yaml:"db"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

RedisMetadataConfig Redis元数据配置

type Step

type Step struct {
	Id          string `yaml:"id,omitempty"` // 步骤ID (UUID,无连字符)
	Name        string `yaml:"name"`
	Description string `yaml:"description,omitempty"` // 步骤具体职责描述
	Run         string `yaml:"run"`
}

Step 步骤配置结构

type StepRuntimeStatus

type StepRuntimeStatus struct {
	Id        string `yaml:"id"`                  // 步骤UUID
	Name      string `yaml:"name"`                // 步骤名称
	Status    string `yaml:"status"`              // 状态: PENDING, RUNNING, SUCCESS, FAILED, CANCELLED
	StartTime string `yaml:"startTime,omitempty"` // 开始时间 (RFC3339)
	EndTime   string `yaml:"endTime,omitempty"`   // 结束时间 (RFC3339)
	Error     string `yaml:"error,omitempty"`     // 错误信息
	Output    string `yaml:"output,omitempty"`    // 步骤输出摘要
}

StepRuntimeStatus 步骤运行时状态

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL