compiler

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package compiler provides pure functions for generating and transforming AgentSpec data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotateToolCategories

func AnnotateToolCategories(tools []agentspec.ToolSpec)

AnnotateToolCategories sets the Category field on each tool based on known tool lists.

func ConfigToAgentSpec

func ConfigToAgentSpec(cfg *types.ForgeConfig) *agentspec.AgentSpec

ConfigToAgentSpec converts a ForgeConfig into an AgentSpec.

func CountToolCategories

func CountToolCategories(tools []agentspec.ToolSpec) map[string]int

CountToolCategories returns a map of category to count for the given tools.

func FilterDevTools

func FilterDevTools(tools []agentspec.ToolSpec) []agentspec.ToolSpec

FilterDevTools removes tools with category "dev" from the slice and returns the filtered result.

func InferBaseImage

func InferBaseImage(entrypoint []string) string

InferBaseImage returns a container base image based on the entrypoint command.

func MergePluginConfig

func MergePluginConfig(spec *agentspec.AgentSpec, pc *plugins.AgentConfig)

MergePluginConfig fills gaps in the spec with plugin-extracted values. forge.yaml values always take precedence.

func WrapperEntrypoint

func WrapperEntrypoint(file string) []string

WrapperEntrypoint returns the entrypoint command for a generated wrapper file.

Types

type NetworkPolicyData

type NetworkPolicyData struct {
	DenyAll bool
}

NetworkPolicyData holds network policy template data.

type TemplateRuntimeData

type TemplateRuntimeData struct {
	Image          string
	Port           int
	Entrypoint     string // Pre-formatted JSON array string, e.g. ["python", "agent.py"]
	Env            map[string]string
	DepsFile       string
	DepsInstallCmd string
	HealthCheck    string
	User           string
	ModelEnv       map[string]string
}

TemplateRuntimeData holds runtime-specific template data.

type TemplateSpecData

type TemplateSpecData struct {
	AgentID       string
	Version       string
	Runtime       *TemplateRuntimeData
	Registry      string
	NetworkPolicy *NetworkPolicyData

	// Container packaging extensions
	EgressProfile        string
	EgressMode           string
	ToolInterfaceVersion string
	SkillsCount          int
	HasSkills            bool
	DevBuild             bool
	ProdBuild            bool

	// Skill requirements
	RequiredEnvVars []string
	OptionalEnvVars []string
	RequiredBins    []string

	// SkillPipRequirements are container-relative requirements.txt paths
	// (e.g. "skills/pdf-tools/requirements.txt"); each becomes a
	// `pip install -r` step in the application stage (#405 D1).
	SkillPipRequirements []string

	// Framework
	ForgeFramework bool
	ForgeVersion   string // forge CLI version for GitHub release download (e.g. "v0.9.0")

	// Multi-stage build
	HasBinStage bool // true when a bins stage exists with installed binaries

	// Per-binary plumbing emitted in the application stage. See
	// forge-core/packaging.DockerfileFragments for the full design
	// (issue #149).
	BinCopies          []string // "COPY --from=<stage> /path /path" lines, one per binary.
	RuntimeAptPackages []string // runtime apt packages installed in the application stage (debian).
	RuntimeApkPackages []string // runtime apk packages installed in the application stage (alpine).
	PathExtensions     []string // PATH directories for non-standard binary locations.

	// KeepRuntimeCurl is true when curl is a declared runtime binary (present
	// in RuntimeAptPackages/RuntimeApkPackages). The forge-framework bootstrap
	// borrows curl to fetch the forge binary and then purges it; when a skill
	// legitimately requires curl at runtime, that purge would clobber it, so
	// the Dockerfile template skips the purge in that case.
	KeepRuntimeCurl bool
}

TemplateSpecData holds data used by Dockerfile and K8s templates.

func BuildTemplateDataFromContext

func BuildTemplateDataFromContext(spec *agentspec.AgentSpec, bc *pipeline.BuildContext) *TemplateSpecData

BuildTemplateDataFromContext creates template data from an AgentSpec and BuildContext.

func BuildTemplateDataFromSpec

func BuildTemplateDataFromSpec(spec *agentspec.AgentSpec) *TemplateSpecData

BuildTemplateDataFromSpec creates template data from an AgentSpec.

Jump to

Keyboard shortcuts

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