workflow

package
v1.1.57 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusRunning  = "running"
	StatusDone     = "done"
	StatusError    = "error"
	StatusCanceled = "canceled"
)
View Source
const SkillName = "workflow-elisp"

Variables

This section is empty.

Functions

func EnsureProjectSkill

func EnsureProjectSkill(projectRoot string) (path string, created bool, err error)

EnsureProjectSkill creates the project-local workflow skill if it does not already exist. Existing SKILL.md or skill.md files are never overwritten so users can customize the workflow authoring instructions.

func NewLispEvaluator

func NewLispEvaluator() *elispvm.Evaluator

NewLispEvaluator creates an evaluator for workflow DSL execution.

Workflow-specific forms and functions such as workflow, phase, parallel, agent, result, and log must be registered by the workflow runner. The VM itself remains a generic Elisp subset implementation.

func RegisterTools

func RegisterTools(registry *tools.Registry, manager *internalagent.AgentManager, store Store)

RegisterTools registers workflow tools.

Types

type ActiveRegistry

type ActiveRegistry struct {
	// contains filtered or unexported fields
}

ActiveRegistry tracks workflow runs that can be canceled in this process.

func DefaultActiveRegistry

func DefaultActiveRegistry() *ActiveRegistry

func NewActiveRegistry

func NewActiveRegistry() *ActiveRegistry

func (*ActiveRegistry) Cancel

func (r *ActiveRegistry) Cancel(id string) bool

func (*ActiveRegistry) IsActive

func (r *ActiveRegistry) IsActive(id string) bool

func (*ActiveRegistry) Register

func (r *ActiveRegistry) Register(id string, cancel context.CancelFunc) error

func (*ActiveRegistry) Unregister

func (r *ActiveRegistry) Unregister(id string)

type AgentHost

type AgentHost struct {
	Manager       *internalagent.AgentManager
	ParentID      agentpkg.AgentID
	ParentMode    string
	ParentEventCh chan<- internalagent.Event
	ParentRunCtx  context.Context
}

AgentHost runs workflow tasks through the existing AgentManager.

func (*AgentHost) RunAgent

func (h *AgentHost) RunAgent(ctx context.Context, task AgentTask) (AgentResult, error)

type AgentResult

type AgentResult struct {
	Key         string    `json:"key"`
	Name        string    `json:"name"`
	Phase       string    `json:"phase,omitempty"`
	InstanceKey string    `json:"instanceKey,omitempty"`
	Status      string    `json:"status"`
	Result      string    `json:"result,omitempty"`
	Error       string    `json:"error,omitempty"`
	StartedAt   time.Time `json:"startedAt"`
	FinishedAt  time.Time `json:"finishedAt,omitempty"`
	Duration    string    `json:"duration,omitempty"`
}

AgentResult captures the completed worker-agent output.

type AgentTask

type AgentTask struct {
	Name              string   `json:"name"`
	Phase             string   `json:"phase,omitempty"`
	InstanceKey       string   `json:"instanceKey,omitempty"`
	Prompt            string   `json:"prompt"`
	Mode              string   `json:"mode,omitempty"`
	WorkDir           string   `json:"workDir,omitempty"`
	Tools             []string `json:"tools,omitempty"`
	MaxIterations     int      `json:"maxIterations,omitempty"`
	SystemPromptExtra string   `json:"systemPromptExtra,omitempty"`
}

AgentTask describes one workflow worker-agent invocation.

type CancelTool

type CancelTool struct {
	// contains filtered or unexported fields
}

func NewCancelTool

func NewCancelTool(active *ActiveRegistry) *CancelTool

func (*CancelTool) Description

func (t *CancelTool) Description() string

func (*CancelTool) Execute

func (t *CancelTool) Execute(ctx context.Context, params map[string]any) (tools.ToolResult, error)

func (*CancelTool) Name

func (t *CancelTool) Name() string

func (*CancelTool) Parameters

func (t *CancelTool) Parameters() json.RawMessage

func (*CancelTool) PromptGuidelines

func (t *CancelTool) PromptGuidelines() []string

func (*CancelTool) PromptSnippet

func (t *CancelTool) PromptSnippet() string

type FileStore

type FileStore struct {
	// contains filtered or unexported fields
}

FileStore persists workflow state as JSON files.

func NewFileStore

func NewFileStore(dir string) *FileStore

NewFileStore creates a file-backed workflow store rooted at dir.

func (*FileStore) List

func (s *FileStore) List(ctx context.Context) ([]RunState, error)

func (*FileStore) Load

func (s *FileStore) Load(ctx context.Context, id string) (*RunState, error)

func (*FileStore) Save

func (s *FileStore) Save(ctx context.Context, state *RunState) error

type Host

type Host interface {
	RunAgent(ctx context.Context, task AgentTask) (AgentResult, error)
}

Host runs workflow worker-agent tasks.

type LintTool

type LintTool struct{}

func NewLintTool

func NewLintTool() *LintTool

func (*LintTool) Description

func (t *LintTool) Description() string

func (*LintTool) Execute

func (t *LintTool) Execute(ctx context.Context, params map[string]any) (tools.ToolResult, error)

func (*LintTool) Name

func (t *LintTool) Name() string

func (*LintTool) Parameters

func (t *LintTool) Parameters() json.RawMessage

func (*LintTool) PromptGuidelines

func (t *LintTool) PromptGuidelines() []string

func (*LintTool) PromptSnippet

func (t *LintTool) PromptSnippet() string

type PhaseState

type PhaseState struct {
	Name       string    `json:"name"`
	Status     string    `json:"status"`
	StartedAt  time.Time `json:"startedAt"`
	FinishedAt time.Time `json:"finishedAt,omitempty"`
	Tasks      []string  `json:"tasks,omitempty"`
	Error      string    `json:"error,omitempty"`
}

PhaseState captures runtime state for a workflow phase.

type ProgressEvent

type ProgressEvent struct {
	RunID   string
	Name    string
	Phase   string
	Task    string
	Status  string
	Message string
	Time    time.Time
}

ProgressEvent captures a lightweight workflow lifecycle update.

type RunState

type RunState struct {
	ID         string                 `json:"id"`
	Name       string                 `json:"name"`
	Status     string                 `json:"status"`
	StartedAt  time.Time              `json:"startedAt"`
	UpdatedAt  time.Time              `json:"updatedAt"`
	FinishedAt time.Time              `json:"finishedAt,omitempty"`
	Phases     []PhaseState           `json:"phases,omitempty"`
	Results    map[string]AgentResult `json:"results,omitempty"`
	Logs       []WorkflowLog          `json:"logs,omitempty"`
	Error      string                 `json:"error,omitempty"`
}

RunState is the persisted workflow run state.

type RunTool

type RunTool struct {
	// contains filtered or unexported fields
}

func NewRunTool

func NewRunTool(manager *internalagent.AgentManager, store Store) *RunTool

func NewRunToolWithActive

func NewRunToolWithActive(manager *internalagent.AgentManager, store Store, active *ActiveRegistry) *RunTool

func (*RunTool) Description

func (t *RunTool) Description() string

func (*RunTool) Execute

func (t *RunTool) Execute(ctx context.Context, params map[string]any) (tools.ToolResult, error)

func (*RunTool) ExecutionTimeout

func (t *RunTool) ExecutionTimeout(params map[string]any) (time.Duration, bool)

func (*RunTool) Name

func (t *RunTool) Name() string

func (*RunTool) Parameters

func (t *RunTool) Parameters() json.RawMessage

func (*RunTool) PromptGuidelines

func (t *RunTool) PromptGuidelines() []string

func (*RunTool) PromptSnippet

func (t *RunTool) PromptSnippet() string

type Runner

type Runner struct {
	Host        Host
	Store       Store
	Active      *ActiveRegistry
	Concurrency int
	Now         func() time.Time
	Progress    func(ProgressEvent)
}

Runner evaluates Elisp workflow DSL and delegates agent tasks to a Host.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, source string) (*RunState, error)

Run evaluates a workflow source string.

type StatusTool

type StatusTool struct {
	// contains filtered or unexported fields
}

func NewStatusTool

func NewStatusTool(store Store) *StatusTool

func (*StatusTool) Description

func (t *StatusTool) Description() string

func (*StatusTool) Execute

func (t *StatusTool) Execute(ctx context.Context, params map[string]any) (tools.ToolResult, error)

func (*StatusTool) Name

func (t *StatusTool) Name() string

func (*StatusTool) Parameters

func (t *StatusTool) Parameters() json.RawMessage

func (*StatusTool) PromptGuidelines

func (t *StatusTool) PromptGuidelines() []string

func (*StatusTool) PromptSnippet

func (t *StatusTool) PromptSnippet() string

type Store

type Store interface {
	Save(ctx context.Context, state *RunState) error
	Load(ctx context.Context, id string) (*RunState, error)
	List(ctx context.Context) ([]RunState, error)
}

Store persists workflow run state.

func DefaultStore

func DefaultStore() Store

type WorkflowLog

type WorkflowLog struct {
	Time    time.Time `json:"time"`
	Message string    `json:"message"`
}

WorkflowLog is a timestamped log entry emitted by workflow DSL.

Jump to

Keyboard shortcuts

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