metaagent

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2026 Teradata

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitProgress

func EmitProgress(ctx context.Context, event *ProgressEvent)

EmitProgress is a helper to emit progress from context

func WithProgress

func WithProgress(ctx context.Context, pm *ProgressMultiplexer) context.Context

WithProgress adds a progress multiplexer to the context

Types

type AgentValidator

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

AgentValidator implements Validator

func NewValidator

func NewValidator(tracer observability.Tracer) *AgentValidator

NewValidator creates a new AgentValidator

func (*AgentValidator) Validate

func (v *AgentValidator) Validate(ctx context.Context, config string) (*ValidationResult, error)

Validate validates agent configuration YAML

type Analysis

type Analysis struct {
	Domain        DomainType      `json:"domain"`
	Capabilities  []Capability    `json:"capabilities"`
	DataSources   []DataSource    `json:"data_sources"`
	Complexity    ComplexityLevel `json:"complexity"`
	SuggestedName string          `json:"suggested_name"` // Suggested agent name based on requirements
}

Analysis contains structured requirements

type Analyzer

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

Analyzer implements RequirementAnalyzer using an LLM

func NewAnalyzer

func NewAnalyzer(llm agent.LLMProvider, tracer observability.Tracer) *Analyzer

NewAnalyzer creates a new Analyzer

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(ctx context.Context, requirements string) (*Analysis, error)

Analyze extracts structured information from natural language requirements

type AntiPattern

type AntiPattern struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Detection   string `yaml:"detection"`
	Example     string `yaml:"example,omitempty"`
}

AntiPattern represents a pattern to avoid

type Capability

type Capability struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Category    string `json:"category"`
	Priority    int    `json:"priority"`
}

Capability represents a specific capability needed by the agent

type ComplexityLevel

type ComplexityLevel string

ComplexityLevel represents the complexity of the agent requirements

const (
	ComplexityLow    ComplexityLevel = "low"
	ComplexityMedium ComplexityLevel = "medium"
	ComplexityHigh   ComplexityLevel = "high"
)

type ConfigGenerator

type ConfigGenerator interface {
	GenerateAgentConfig(ctx context.Context, analysis *Analysis) (string, error)
	GeneratePatternConfigs(ctx context.Context, patterns []string) (map[string]string, error)
	GenerateWorkflowConfig(ctx context.Context, workflow *WorkflowSpec) (string, error)
}

ConfigGenerator generates YAML configurations

type ConsoleProgressListener

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

ConsoleProgressListener listens to progress events and handles user interaction via console

func NewConsoleProgressListener

func NewConsoleProgressListener(logger *zap.Logger) *ConsoleProgressListener

NewConsoleProgressListener creates a new console progress listener

func (*ConsoleProgressListener) OnProgress

func (c *ConsoleProgressListener) OnProgress(event *ProgressEvent)

OnProgress handles progress events, specifically interactive questions

type DataSource

type DataSource struct {
	Type           string `json:"type"`
	ConnectionHint string `json:"connection_hint"`
}

DataSource represents a data source mentioned in requirements

type DomainType

type DomainType string

DomainType represents the primary domain of the agent

const (
	DomainSQL      DomainType = "sql"
	DomainREST     DomainType = "rest"
	DomainGraphQL  DomainType = "graphql"
	DomainFile     DomainType = "file"
	DomainDocument DomainType = "document"
	DomainMCP      DomainType = "mcp"
	DomainHybrid   DomainType = "hybrid"
)

type PatternSelector

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

PatternSelector selects relevant patterns based on agent capabilities

func NewPatternSelector

func NewPatternSelector(tracer observability.Tracer) *PatternSelector

NewPatternSelector creates a new pattern selector with built-in capability mapping

func (*PatternSelector) SelectPatterns

func (ps *PatternSelector) SelectPatterns(ctx context.Context, analysis *Analysis) ([]string, error)

SelectPatterns selects relevant patterns based on capabilities Returns list of pattern names (e.g., "sql/data_quality/data_profiling")

type ProgressCallback

type ProgressCallback func(*ProgressEvent)

ProgressCallback is a function that handles progress events

func (ProgressCallback) OnProgress

func (f ProgressCallback) OnProgress(event *ProgressEvent)

OnProgress implements ProgressListener for function callbacks

type ProgressEvent

type ProgressEvent struct {
	Type      ProgressEventType      `json:"type"`
	Timestamp time.Time              `json:"timestamp"`
	AgentName string                 `json:"agent_name,omitempty"`
	Message   string                 `json:"message"`
	Details   map[string]interface{} `json:"details,omitempty"`
	Error     string                 `json:"error,omitempty"`

	// For questions
	Question *Question `json:"question,omitempty"`
}

ProgressEvent represents a progress update during workflow execution

type ProgressEventType

type ProgressEventType string

ProgressEventType represents the type of progress event

const (
	// Weaver/Mender sub-agent events
	EventSubAgentStarted   ProgressEventType = "sub_agent_started"
	EventSubAgentCompleted ProgressEventType = "sub_agent_completed"
	EventSubAgentFailed    ProgressEventType = "sub_agent_failed"

	// Workflow orchestration events
	EventWorkflowStarted   ProgressEventType = "workflow_started"
	EventWorkflowCompleted ProgressEventType = "workflow_completed"
	EventAgentStarted      ProgressEventType = "agent_started"
	EventAgentCompleted    ProgressEventType = "agent_completed"
	EventAgentFailed       ProgressEventType = "agent_failed"

	// Interactive events
	EventQuestionAsked    ProgressEventType = "question_asked"
	EventQuestionAnswered ProgressEventType = "question_answered"

	// Validation events
	EventValidationStarted ProgressEventType = "validation_started"
	EventValidationPassed  ProgressEventType = "validation_passed"
	EventValidationFailed  ProgressEventType = "validation_failed"
)

type ProgressListener

type ProgressListener interface {
	OnProgress(event *ProgressEvent)
}

ProgressListener receives progress events

type ProgressMultiplexer

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

ProgressMultiplexer broadcasts events to multiple listeners. Thread-safe for concurrent use by multiple goroutines.

func FromContext

func FromContext(ctx context.Context) *ProgressMultiplexer

FromContext retrieves the progress multiplexer from context

func NewProgressMultiplexer

func NewProgressMultiplexer() *ProgressMultiplexer

NewProgressMultiplexer creates a new multiplexer

func (*ProgressMultiplexer) AddListener

func (pm *ProgressMultiplexer) AddListener(listener ProgressListener)

AddListener adds a progress listener. Safe for concurrent use.

func (*ProgressMultiplexer) Emit

func (pm *ProgressMultiplexer) Emit(event *ProgressEvent)

Emit broadcasts an event to all listeners. Safe for concurrent use - multiple goroutines can emit simultaneously.

func (*ProgressMultiplexer) EmitQuestion

func (pm *ProgressMultiplexer) EmitQuestion(question *Question)

EmitQuestion emits a question event and waits for answer

func (*ProgressMultiplexer) EmitSubAgentCompleted

func (pm *ProgressMultiplexer) EmitSubAgentCompleted(name, message string, details map[string]interface{})

EmitSubAgentCompleted emits a sub-agent completed event

func (*ProgressMultiplexer) EmitSubAgentFailed

func (pm *ProgressMultiplexer) EmitSubAgentFailed(name, message string, err error)

EmitSubAgentFailed emits a sub-agent failed event

func (*ProgressMultiplexer) EmitSubAgentStarted

func (pm *ProgressMultiplexer) EmitSubAgentStarted(name, message string)

EmitSubAgentStarted emits a sub-agent started event

func (*ProgressMultiplexer) EmitValidationFailed

func (pm *ProgressMultiplexer) EmitValidationFailed(score float64, issues int)

func (*ProgressMultiplexer) EmitValidationPassed

func (pm *ProgressMultiplexer) EmitValidationPassed(score float64)

func (*ProgressMultiplexer) EmitValidationStarted

func (pm *ProgressMultiplexer) EmitValidationStarted()

EmitValidation emits validation events

func (*ProgressMultiplexer) RemoveListener

func (pm *ProgressMultiplexer) RemoveListener(listener ProgressListener)

RemoveListener removes a progress listener. Safe for concurrent use.

type Question

type Question struct {
	ID      string        `json:"id"`
	Prompt  string        `json:"prompt"`
	Options []string      `json:"options,omitempty"` // Empty for free-form
	Context string        `json:"context,omitempty"` // Additional context
	Timeout time.Duration `json:"timeout,omitempty"` // Optional timeout for response (0 = use default)

	// Answer channel for synchronous question-answer flow
	// The emitter creates this channel, emits the question, and waits on it for the answer.
	// The UI layer (TUI/console) receives the question event and sends the answer via this channel.
	// Lifecycle: Created by emitter → used by UI → closed by UI after sending answer.
	// Buffer size of 1 prevents blocking if answer arrives before wait.
	AnswerChan chan string `json:"-"`
}

Question represents an interactive question to the user

type QuestionAnsweredMsg

type QuestionAnsweredMsg struct {
	QuestionID string
	Answer     string
}

QuestionAnsweredMsg is sent when the user answers a clarification question

type QuestionAskedMsg

type QuestionAskedMsg struct {
	Question *Question
}

QuestionAskedMsg is sent when the agent asks a clarification question

type ROM

type ROM struct {
	Identity      string                 `yaml:"identity"`
	Version       string                 `yaml:"version"`
	Purpose       string                 `yaml:"purpose"`
	Domain        string                 `yaml:"domain,omitempty"`
	Capabilities  []string               `yaml:"capabilities,omitempty"`
	Patterns      []string               `yaml:"patterns,omitempty"`
	Guidelines    map[string][]string    `yaml:"guidelines,omitempty"`
	AntiPatterns  []AntiPattern          `yaml:"anti_patterns,omitempty"`
	BestPractices []string               `yaml:"best_practices,omitempty"`
	Metadata      map[string]string      `yaml:"metadata,omitempty"`
	KnowledgeBase map[string]interface{} `yaml:"knowledge_base,omitempty"`
}

ROM represents the structured ROM content

type ROMBuilder

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

ROMBuilder builds Read-Only Memory (ROM) content for agents ROM is static documentation that never changes during agent session

func NewROMBuilder

func NewROMBuilder(tracer observability.Tracer) *ROMBuilder

NewROMBuilder creates a new ROM builder

func (*ROMBuilder) BuildAgentROM

func (rb *ROMBuilder) BuildAgentROM(analysis *Analysis, selectedPatterns []string, backendPath string) (string, error)

BuildAgentROM loads backend-specific ROM content (markdown format) Returns the appropriate ROM file for the backend (e.g., TD.rom for Teradata) This avoids nested YAML parsing issues by using plain markdown

func (*ROMBuilder) BuildMetaAgentROM

func (rb *ROMBuilder) BuildMetaAgentROM() (string, error)

BuildMetaAgentROM builds ROM for the meta-agent itself This ROM contains knowledge about how to generate other agents

func (*ROMBuilder) LoadBackendROM

func (rb *ROMBuilder) LoadBackendROM(backendPath string) string

LoadBackendROM loads backend-specific ROM content based on backend path

type RequirementAnalyzer

type RequirementAnalyzer interface {
	Analyze(ctx context.Context, requirements string) (*Analysis, error)
}

RequirementAnalyzer extracts structured information from natural language

type StageSpec

type StageSpec struct {
	Name string
	Type string
}

StageSpec represents a stage in a workflow

type SubAgentProgressMsg

type SubAgentProgressMsg struct {
	AgentName string
	Type      ProgressEventType
	Message   string
	Error     string
	Details   map[string]interface{}
}

SubAgentProgressMsg is sent when a sub-agent reports progress

type TUIProgressListener

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

TUIProgressListener listens to progress events and sends them to the TUI via Bubbletea messages

func NewTUIProgressListener

func NewTUIProgressListener(logger *zap.Logger, program *tea.Program) *TUIProgressListener

NewTUIProgressListener creates a new TUI progress listener

func (*TUIProgressListener) OnProgress

func (t *TUIProgressListener) OnProgress(event *ProgressEvent)

OnProgress handles progress events by converting them to Bubbletea messages

type ValidationError

type ValidationError struct {
	Field      string
	Message    string
	Type       string // Type of error: "syntax_error", "required_field", "invalid_value", "anti_pattern", "format_error", "security_risk"
	Line       int    // Line number in the prompt where error occurred (0 if not applicable)
	Suggestion string // Suggestion for fixing the error
}

ValidationError represents a validation error

type ValidationProgressMsg

type ValidationProgressMsg struct {
	Type    ProgressEventType
	Message string
	Score   float64
	Issues  int
}

ValidationProgressMsg is sent when validation starts/completes/fails

type ValidationResult

type ValidationResult struct {
	Valid    bool
	Errors   []ValidationError
	Warnings []ValidationWarning
}

ValidationResult contains validation results

type ValidationWarning

type ValidationWarning struct {
	Field      string
	Message    string
	Suggestion string // Suggestion for addressing the warning (optional)
}

ValidationWarning represents a validation warning

type Validator

type Validator interface {
	Validate(ctx context.Context, config string) (*ValidationResult, error)
}

Validator validates generated configurations

type WorkflowSpec

type WorkflowSpec struct {
	Type     string            // Workflow type: debate, swarm, pipeline, etc.
	Pattern  interface{}       // Generated workflow pattern proto (can be *loomv1.WorkflowPattern or specific pattern type)
	YAML     string            // Kubernetes-style YAML representation
	Metadata map[string]string // Additional context and metadata
	Stages   []StageSpec       // Pipeline stages (for pipeline workflows)
}

WorkflowSpec represents a generated workflow specification. It includes the workflow pattern, YAML representation, and metadata for tracking.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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