Documentation
¶
Index ¶
- Constants
- Variables
- func CronSchedules(definitionYAML string) ([]string, error)
- func DecodeDependsOnJSON(encoded string) ([]string, error)
- func DecodeOutputJSON(encoded string) (map[string]any, error)
- func DefinitionHasAINodes(def *Definition) bool
- func DefinitionTriggerTypes(def *Definition) []string
- func EncodeOutputJSON(values map[string]any) string
- func IsTerminalRunStatus(status string) bool
- func MarkRunOrphaned(ctx context.Context, repo Repository, runID string) error
- func ValidateDefinition(def *Definition) error
- type CreateDefinitionInput
- type CreateRunInput
- type Definition
- type DefinitionRecord
- type ExecutionContext
- type Executor
- type ExecutorContext
- type ExecutorRegistry
- type NodeDefinition
- type NodeRunRecord
- type NodeRunSeed
- type Parameter
- type PrepareRunInput
- type PreparedRun
- type Repository
- type RetryPolicy
- type RunRecord
- type RunResult
- type Runner
- type Service
- func (s *Service) CreateDefinition(ctx context.Context, input CreateDefinitionInput) (*DefinitionRecord, error)
- func (s *Service) GetDefinition(ctx context.Context, id string) (*DefinitionRecord, error)
- func (s *Service) ListCronEnabledDefinitions(ctx context.Context) ([]*DefinitionRecord, error)
- func (s *Service) ListDefinitions(ctx context.Context) ([]*DefinitionRecord, error)
- func (s *Service) PrepareRun(ctx context.Context, input PrepareRunInput) (*PreparedRun, error)
- func (s *Service) UpdateDefinition(ctx context.Context, id string, input UpdateDefinitionInput) (*DefinitionRecord, error)
- type Trigger
- type UpdateDefinitionInput
- type UpdateNodeRunInput
- type UpdateRunInput
Constants ¶
View Source
const ( TriggerManual = "manual" TriggerCron = "cron" OverlapPolicySkip = "skip" NodeTypeShell = "shell" NodeTypeHTTP = "http" NodeTypeLLM = "llm" NodeTypeAgent = "agent" NodeTypeDocker = "docker" NodeTypeSMTP = "smtp" NodeTypeCondition = "condition" NodeTypeManualGate = "manual_gate" NodeTypeSubworkflow = "subworkflow" RunStatusPending = "pending" RunStatusRunning = "running" RunStatusSucceeded = "succeeded" RunStatusFailed = "failed" RunStatusCancelled = "cancelled" RunStatusWaiting = "waiting" RunStatusManualGate = "manual_gate" NodeStatusPending = "pending" NodeStatusRunning = "running" NodeStatusSucceeded = "succeeded" NodeStatusFailed = "failed" NodeStatusSkipped = "skipped" NodeStatusCancelled = "cancelled" NodeStatusWaiting = "waiting" NodeStatusManualGate = "manual_gate" )
Variables ¶
View Source
var ErrOverlapSkipped = fmt.Errorf("workflow overlap policy skipped run")
View Source
var SupportedNodeTypes = []string{ NodeTypeShell, NodeTypeHTTP, NodeTypeLLM, NodeTypeAgent, NodeTypeDocker, NodeTypeSMTP, NodeTypeCondition, NodeTypeManualGate, NodeTypeSubworkflow, }
View Source
var SupportedTriggerTypes = []string{TriggerManual, TriggerCron}
View Source
var TerminalRunStatuses = []string{ RunStatusSucceeded, RunStatusFailed, RunStatusCancelled, RunStatusWaiting, RunStatusManualGate, }
View Source
var WorkflowExecuteSSHCommandForTesting = workflowExecuteSSHCommand
WorkflowExecuteSSHCommandForTesting allows tests in other packages to stub SSH execution.
Functions ¶
func CronSchedules ¶
func DecodeDependsOnJSON ¶
func DefinitionHasAINodes ¶
func DefinitionHasAINodes(def *Definition) bool
func DefinitionTriggerTypes ¶
func DefinitionTriggerTypes(def *Definition) []string
func EncodeOutputJSON ¶
func IsTerminalRunStatus ¶
func MarkRunOrphaned ¶
func MarkRunOrphaned(ctx context.Context, repo Repository, runID string) error
func ValidateDefinition ¶
func ValidateDefinition(def *Definition) error
Types ¶
type CreateDefinitionInput ¶
type CreateRunInput ¶
type Definition ¶
type Definition struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Params []Parameter `yaml:"params,omitempty" json:"params,omitempty"`
Triggers []Trigger `yaml:"triggers,omitempty" json:"triggers,omitempty"`
OverlapPolicy string `yaml:"overlap_policy,omitempty" json:"overlap_policy,omitempty"`
DefaultServerID string `yaml:"default_server_id,omitempty" json:"default_server_id,omitempty"`
Nodes []NodeDefinition `yaml:"nodes" json:"nodes"`
}
func ParseDefinition ¶
func ParseDefinition(definitionYAML string) (*Definition, error)
type DefinitionRecord ¶
type DefinitionRecord struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
IsEnabled bool `json:"is_enabled"`
DefinitionYAML string `json:"definition_yaml"`
DefaultServerID string `json:"default_server_id"`
TriggerTypesJSON string `json:"trigger_types_json"`
NodeCount int `json:"node_count"`
HasAINodes bool `json:"has_ai_nodes"`
CreatedBy string `json:"created_by"`
Created string `json:"created"`
Updated string `json:"updated"`
}
type ExecutionContext ¶
type ExecutionContext struct {
Run *RunRecord
Nodes []NodeDefinition
NodeRuns map[string]*NodeRunRecord
}
type Executor ¶
type Executor interface {
Execute(ctx context.Context, execCtx *ExecutorContext, nodeRun *NodeRunRecord, node NodeDefinition) (string, map[string]any, error)
}
type ExecutorContext ¶
type ExecutorContext struct {
App core.App
Definition *Definition
Run *RunRecord
NodeRuns map[string]*NodeRunRecord
Params map[string]any
Repo Repository
Resolver copilot.ProviderResolver
}
type ExecutorRegistry ¶
type ExecutorRegistry struct {
// contains filtered or unexported fields
}
func NewExecutorRegistry ¶
func NewExecutorRegistry(app core.App) *ExecutorRegistry
func (*ExecutorRegistry) Execute ¶
func (r *ExecutorRegistry) Execute(ctx context.Context, execCtx *ExecutorContext, nodeRun *NodeRunRecord, node NodeDefinition) (string, map[string]any, error)
func (*ExecutorRegistry) Register ¶
func (r *ExecutorRegistry) Register(nodeType string, executor Executor)
type NodeDefinition ¶
type NodeDefinition struct {
Key string `yaml:"key" json:"key"`
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Type string `yaml:"type" json:"type"`
DependsOn []string `yaml:"depends_on,omitempty" json:"depends_on,omitempty"`
TimeoutSec int `yaml:"timeout_sec,omitempty" json:"timeout_sec,omitempty"`
Retry RetryPolicy `yaml:"retry,omitempty" json:"retry,omitempty"`
Config map[string]any `yaml:"config,omitempty" json:"config,omitempty"`
}
func ReadyNodes ¶
func ReadyNodes(execCtx *ExecutionContext) []NodeDefinition
type NodeRunRecord ¶
type NodeRunRecord struct {
ID string `json:"id"`
WorkflowRunID string `json:"workflow_run_id"`
NodeKey string `json:"node_key"`
NodeType string `json:"node_type"`
DisplayName string `json:"display_name"`
DependsOnJSON string `json:"depends_on_json"`
Status string `json:"status"`
RetryCount int `json:"retry_count"`
OutputJSON string `json:"output_json"`
ErrorMessage string `json:"error_message"`
ExecutionLog string `json:"execution_log"`
ExecutionLogTruncated bool `json:"execution_log_truncated"`
StartedAt string `json:"started_at"`
EndedAt string `json:"ended_at"`
Created string `json:"created"`
Updated string `json:"updated"`
}
type NodeRunSeed ¶
type PrepareRunInput ¶
type PreparedRun ¶
type PreparedRun struct {
Definition *DefinitionRecord
Run *RunRecord
NodeRuns []*NodeRunRecord
}
type Repository ¶
type Repository interface {
ListDefinitions(ctx context.Context) ([]*DefinitionRecord, error)
GetDefinition(ctx context.Context, id string) (*DefinitionRecord, error)
CreateDefinition(ctx context.Context, input CreateDefinitionInput) (*DefinitionRecord, error)
UpdateDefinition(ctx context.Context, id string, input UpdateDefinitionInput) (*DefinitionRecord, error)
DeleteDefinition(ctx context.Context, id string) error
CreatePreparedRun(ctx context.Context, input CreateRunInput, nodes []NodeRunSeed) (*RunRecord, []*NodeRunRecord, error)
CreateRun(ctx context.Context, input CreateRunInput) (*RunRecord, error)
GetRun(ctx context.Context, id string) (*RunRecord, error)
UpdateRun(ctx context.Context, id string, input UpdateRunInput) (*RunRecord, error)
ListRunsByWorkflow(ctx context.Context, workflowID string) ([]*RunRecord, error)
CreateNodeRuns(ctx context.Context, workflowRunID string, nodes []NodeRunSeed) ([]*NodeRunRecord, error)
ListNodeRunsByRun(ctx context.Context, workflowRunID string) ([]*NodeRunRecord, error)
UpdateNodeRun(ctx context.Context, id string, input UpdateNodeRunInput) (*NodeRunRecord, error)
ListActiveRunsByWorkflow(ctx context.Context, workflowID string) ([]*RunRecord, error)
ListOrphanedRuns(ctx context.Context) ([]*RunRecord, error)
ListCronEnabledDefinitions(ctx context.Context) ([]*DefinitionRecord, error)
}
type RetryPolicy ¶
type RetryPolicy struct {
Limit int `yaml:"limit,omitempty" json:"limit,omitempty"`
}
type RunRecord ¶
type RunRecord struct {
ID string `json:"id"`
WorkflowID string `json:"workflow_id"`
DefinitionYAML string `json:"definition_yaml"`
Status string `json:"status"`
TriggerType string `json:"trigger_type"`
ExecutionOwnerID string `json:"execution_owner_id"`
RequestedBy string `json:"requested_by"`
RequestedByEmail string `json:"requested_by_email"`
ParamsJSON string `json:"params_json"`
ResolvedServerID string `json:"resolved_server_id"`
OverlapPolicy string `json:"overlap_policy"`
StartedAt string `json:"started_at"`
EndedAt string `json:"ended_at"`
ErrorMessage string `json:"error_message"`
Created string `json:"created"`
Updated string `json:"updated"`
}
type RunResult ¶
type RunResult struct {
Status string
Node *NodeRunRecord
}
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func NewRunner ¶
func NewRunner(repo Repository) *Runner
func (*Runner) LoadExecutionContext ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo Repository) *Service
func (*Service) CreateDefinition ¶
func (s *Service) CreateDefinition(ctx context.Context, input CreateDefinitionInput) (*DefinitionRecord, error)
func (*Service) GetDefinition ¶
func (*Service) ListCronEnabledDefinitions ¶
func (s *Service) ListCronEnabledDefinitions(ctx context.Context) ([]*DefinitionRecord, error)
func (*Service) ListDefinitions ¶
func (s *Service) ListDefinitions(ctx context.Context) ([]*DefinitionRecord, error)
func (*Service) PrepareRun ¶
func (s *Service) PrepareRun(ctx context.Context, input PrepareRunInput) (*PreparedRun, error)
func (*Service) UpdateDefinition ¶
func (s *Service) UpdateDefinition(ctx context.Context, id string, input UpdateDefinitionInput) (*DefinitionRecord, error)
type UpdateDefinitionInput ¶
type UpdateNodeRunInput ¶
Click to show internal directories.
Click to hide internal directories.