agent

package module
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 16 Imported by: 0

README

workflow-plugin-agent

AI agent primitives for workflow apps. An internal engine plugin providing:

  • agent.provider module — AI provider abstraction (mock, test, anthropic, openai, copilot)
  • step.agent_execute — autonomous agent loop (LLM call → tool execution → repeat)
  • step.provider_test — test connectivity to a configured AI provider
  • step.provider_models — list available models from a provider

Install

GOPRIVATE=github.com/GoCodeAlone/* go get github.com/GoCodeAlone/workflow-plugin-agent@latest

Usage

import agent "github.com/GoCodeAlone/workflow-plugin-agent"

engine := workflow.NewEngine(
    workflow.WithPlugin(agent.New()),
)

Documentation

Overview

Package agent is a workflow EnginePlugin that provides AI agent primitives: the agent.provider module type, the step.agent_execute pipeline step, and related utility steps.

Usage:

engine := workflow.NewEngine(workflow.WithPlugin(agent.New()))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModelPullStepFactory added in v0.5.3

func NewModelPullStepFactory() plugin.StepFactory

NewModelPullStepFactory returns the plugin.StepFactory for "step.model_pull". Exported for use by host plugins that embed agent capabilities without loading AgentPlugin as a standalone plugin.

func NewProviderModelsFactory

func NewProviderModelsFactory() plugin.StepFactory

NewProviderModelsFactory returns the plugin.StepFactory for "step.provider_models". Exported for use by host plugins that embed agent capabilities without loading AgentPlugin as a standalone plugin.

func NewProviderModuleFactory

func NewProviderModuleFactory() plugin.ModuleFactory

NewProviderModuleFactory returns the plugin.ModuleFactory for "agent.provider". This is exported so other plugins can embed the factory without loading the full AgentPlugin (which would cause duplicate step type registration conflicts).

func NewProviderTestFactory

func NewProviderTestFactory() plugin.StepFactory

NewProviderTestFactory returns the plugin.StepFactory for "step.provider_test". Exported for use by host plugins that embed agent capabilities without loading AgentPlugin as a standalone plugin.

func ProviderRegistryHook

func ProviderRegistryHook() plugin.WiringHook

ProviderRegistryHook returns the wiring hook that creates the agent-provider-registry. Exported for use by host plugins that embed agent capabilities without loading AgentPlugin as a standalone plugin.

Types

type AgentExecuteStep

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

AgentExecuteStep runs the autonomous agent loop for a single task.

func (*AgentExecuteStep) Execute

func (*AgentExecuteStep) Name

func (s *AgentExecuteStep) Name() string

type AgentPlugin

type AgentPlugin struct {
	plugin.BaseEnginePlugin
}

AgentPlugin implements plugin.EnginePlugin.

func New

func New() *AgentPlugin

New creates a new AgentPlugin ready to register with the workflow engine.

func (*AgentPlugin) Capabilities

func (p *AgentPlugin) Capabilities() []capability.Contract

Capabilities returns the capability contracts for this plugin.

func (*AgentPlugin) ModuleFactories

func (p *AgentPlugin) ModuleFactories() map[string]plugin.ModuleFactory

ModuleFactories returns the module factories registered by this plugin.

func (*AgentPlugin) ModuleSchemas

func (p *AgentPlugin) ModuleSchemas() []*schema.ModuleSchema

ModuleSchemas returns schema definitions for IDE completions and config validation.

func (*AgentPlugin) StepFactories

func (p *AgentPlugin) StepFactories() map[string]plugin.StepFactory

StepFactories returns the pipeline step factories registered by this plugin.

func (*AgentPlugin) WiringHooks

func (p *AgentPlugin) WiringHooks() []plugin.WiringHook

WiringHooks returns the post-init wiring hooks for this plugin.

type AgentSeed

type AgentSeed struct {
	ID           string `yaml:"id"`
	Name         string `yaml:"name"`
	Role         string `yaml:"role"`
	SystemPrompt string `yaml:"system_prompt"`
	Provider     string `yaml:"provider"`
	Model        string `yaml:"model"`
	TeamID       string `yaml:"team_id"`
	IsLead       bool   `yaml:"is_lead"`
}

AgentSeed holds the definition of an agent to seed into the database on startup.

type LLMProviderConfig

type LLMProviderConfig struct {
	ID         string `json:"id"`
	Alias      string `json:"alias"`
	Type       string `json:"type"`
	Model      string `json:"model"`
	SecretName string `json:"secret_name"`
	BaseURL    string `json:"base_url"`
	MaxTokens  int    `json:"max_tokens"`
	IsDefault  int    `json:"is_default"`
}

LLMProviderConfig represents a configured LLM provider stored in the database.

type ModelPullStep added in v0.5.3

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

ModelPullStep ensures a model is available before agent execution. For "ollama" source it pulls from an Ollama server; for "huggingface" it downloads from HuggingFace Hub.

func (*ModelPullStep) Execute added in v0.5.3

func (*ModelPullStep) Name added in v0.5.3

func (s *ModelPullStep) Name() string

type ProviderFactory

type ProviderFactory func(apiKey string, cfg LLMProviderConfig) (provider.Provider, error)

ProviderFactory creates a provider.Provider from an API key and config.

type ProviderModelsStep

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

ProviderModelsStep fetches available models from a provider's API.

func (*ProviderModelsStep) Execute

func (*ProviderModelsStep) Name

func (s *ProviderModelsStep) Name() string

type ProviderModule

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

ProviderModule wraps a provider.Provider as a modular.Module. It registers itself in the service registry so steps can look it up by name.

func (*ProviderModule) Agents

func (m *ProviderModule) Agents() []AgentSeed

Agents returns the agent seeds configured for this provider module.

func (*ProviderModule) Init

func (m *ProviderModule) Init(app modular.Application) error

Init registers this module as a named service.

func (*ProviderModule) Name

func (m *ProviderModule) Name() string

Name implements modular.Module.

func (*ProviderModule) Provider

func (m *ProviderModule) Provider() provider.Provider

Provider returns the underlying AI provider.

func (*ProviderModule) ProvidesServices

func (m *ProviderModule) ProvidesServices() []modular.ServiceProvider

ProvidesServices declares the provider service.

func (*ProviderModule) RequiresServices

func (m *ProviderModule) RequiresServices() []modular.ServiceDependency

RequiresServices declares no dependencies.

func (*ProviderModule) Start

func (m *ProviderModule) Start(_ context.Context) error

Start implements modular.Startable (no-op).

func (*ProviderModule) Stop

func (m *ProviderModule) Stop(_ context.Context) error

Stop implements modular.Stoppable (no-op).

func (*ProviderModule) TestHTTPSource

func (m *ProviderModule) TestHTTPSource() *provider.HTTPSource

TestHTTPSource returns the HTTPSource if the provider is a test provider in HTTP mode.

type ProviderRegistry

type ProviderRegistry struct {
	Factories map[string]ProviderFactory
	// contains filtered or unexported fields
}

ProviderRegistry manages AI provider lifecycle: factory creation, caching, and DB lookup.

func NewProviderRegistry

func NewProviderRegistry(db *sql.DB, secretsProvider secrets.Provider) *ProviderRegistry

NewProviderRegistry creates a new ProviderRegistry with built-in factories registered.

func (*ProviderRegistry) GetByAlias

func (r *ProviderRegistry) GetByAlias(ctx context.Context, alias string) (provider.Provider, error)

GetByAlias looks up a provider by its alias.

func (*ProviderRegistry) GetDefault

func (r *ProviderRegistry) GetDefault(ctx context.Context) (provider.Provider, error)

GetDefault finds the default provider (is_default=1).

func (*ProviderRegistry) InvalidateCache

func (r *ProviderRegistry) InvalidateCache()

InvalidateCache clears all cached providers.

func (*ProviderRegistry) InvalidateCacheAlias

func (r *ProviderRegistry) InvalidateCacheAlias(alias string)

InvalidateCacheAlias removes a specific cached provider by alias.

func (*ProviderRegistry) TestConnection

func (r *ProviderRegistry) TestConnection(ctx context.Context, alias string) (bool, string, time.Duration, error)

TestConnection sends a minimal test message to the provider.

type ProviderTestStep

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

ProviderTestStep tests connectivity to a configured AI provider.

func (*ProviderTestStep) Execute

func (*ProviderTestStep) Name

func (s *ProviderTestStep) Name() string

Directories

Path Synopsis
Package agent defines agent types and configuration.
Package agent defines agent types and configuration.
Package executor provides the core autonomous agent execution loop.
Package executor provides the core autonomous agent execution loop.
Package memory provides SQLite-backed persistent memory storage for agents.
Package memory provides SQLite-backed persistent memory storage for agents.
Package ratchetplugin is a workflow EnginePlugin that provides ratchet-specific module types, pipeline steps, and wiring hooks.
Package ratchetplugin is a workflow EnginePlugin that provides ratchet-specific module types, pipeline steps, and wiring hooks.
Package plugin defines the Ratchet tool plugin interface.
Package plugin defines the Ratchet tool plugin interface.
Package provider defines the AI provider interface for agent backends.
Package provider defines the AI provider interface for agent backends.
Package sdk provides reusable daemon-client infrastructure for agent CLI tools.
Package sdk provides reusable daemon-client infrastructure for agent CLI tools.
Package task defines the task model for agent work items.
Package task defines the task model for agent work items.
Package tools defines the Tool interface and Registry for agent tool execution.
Package tools defines the Tool interface and Registry for agent tool execution.

Jump to

Keyboard shortcuts

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