Documentation
¶
Overview ¶
Package prompt provides template-based prompt management and assembly.
This package implements a registry system for loading, caching, and assembling prompt templates via repository interfaces:
- Fragment-based prompt composition
- Variable substitution with required/optional vars
- Model-specific overrides (template modifications only)
- Tool allowlist integration
- Version tracking and content hashing
The Registry uses the repository pattern to load prompt configs, avoiding direct file I/O. It resolves fragment references, performs template variable substitution, and generates AssembledPrompt objects ready for LLM execution.
Architecture ¶
For system architecture and design patterns, see:
- Runtime pipeline: https://promptkit.altairalabs.ai/architecture/runtime-pipeline/
- System overview: https://promptkit.altairalabs.ai/architecture/system-overview/
Usage ¶
Create a registry with a repository (config-first pattern):
repo := memory.NewRepository()
registry := prompt.NewRegistryWithRepository(repo)
assembled := registry.LoadWithVars("task_type", vars, "gpt-4")
See package github.com/AltairaLabs/PromptKit/sdk/v2 for higher-level APIs.
Index ¶
- Constants
- Variables
- func CallProviderKey(p *Pack, promptTask, stepProvider string) string
- func DescribeGovernance(g *Governance) string
- func DescribeUnsatisfied(reqs []ResolvedRequirement) string
- func ExtractVariablesFromTemplate(template string) []string
- func GetDefaultPipelineConfig() *packspec.PipelineConfig
- func GetUsedVars(vars map[string]string) []stringdeprecated
- func IsNamedProviderKey(key string) bool
- func IsPlainFragmentValue(value string) bool
- func NeedsDefaultProvider(p *Pack) bool
- func SetMetadataChangelog(m *Metadata, entries []ChangelogEntry)
- func SetMetadataPerformance(m *Metadata, p *PerformanceMetrics)
- func SkillPath(s *SkillSourceConfig) string
- func SupportsMediaType(config *MediaConfig, mediaType string) bool
- func ValidateMediaConfig(config *MediaConfig) error
- type AgentDef
- type AgentsConfig
- type AssembledPrompt
- type AudioConfig
- type CallParams
- type CallSite
- type ChangelogEntry
- type CompilationInfo
- type CompileOption
- type Config
- type ConfigDirResolver
- type CostEstimate
- type DocumentConfig
- type ExampleContentPart
- type ExampleMedia
- type FileWriter
- type Fragment
- type FragmentLoader
- type FragmentRef
- type FragmentRepository
- type FragmentResolver
- type Governance
- type GovernanceValidationResult
- type ImageConfig
- type Info
- type Loader
- type MediaConfig
- type Metadata
- type MetadataBuilder
- func (mb *MetadataBuilder) AddChangelogEntry(version, author, description string)
- func (mb *MetadataBuilder) BuildCompilationInfo(compilerVersion string) *CompilationInfo
- func (mb *MetadataBuilder) BuildMetadata(domain, language string, tags []string, testResults []TestResultSummary) *Metadata
- func (mb *MetadataBuilder) SetDomain(domain string)
- func (mb *MetadataBuilder) SetLanguage(language string)
- func (mb *MetadataBuilder) SetTags(tags []string)
- func (mb *MetadataBuilder) UpdateFromCostInfo(costs []types.CostInfo)
- func (mb *MetadataBuilder) ValidateMetadata() []string
- type ModelOverride
- type ModelTestResultRef
- type MultimodalExample
- type Pack
- func (p *Pack) GetOptionalVariables(taskType string) map[string]string
- func (p *Pack) GetPrompt(taskType string) *PackPrompt
- func (p *Pack) GetRequiredVariables(taskType string) []string
- func (p *Pack) GetTool(name string) *PackTool
- func (p *Pack) GetToolNames(taskType string) []string
- func (p *Pack) ListPrompts() []string
- func (p *Pack) ListTools() []string
- func (p *Pack) PromptConfig(taskType string) *Config
- func (p *Pack) Summary() string
- func (p *Pack) Validate() []string
- func (p *Pack) ValidateAgents() (errs, warnings []string)
- func (p *Pack) ValidateCompositions() *composition.ValidationResult
- func (p *Pack) ValidateDetailed() *PackValidationResult
- func (p *Pack) ValidateGovernance() *GovernanceValidationResult
- func (p *Pack) ValidateWorkflow() *workflow.ValidationResult
- type PackCompiler
- func (pc *PackCompiler) Compile(taskType, compilerVersion string) (*Pack, error)
- func (pc *PackCompiler) CompileFromRegistry(packID, compilerVersion string) (*Pack, error)
- func (pc *PackCompiler) CompileFromRegistryWithOptions(packID, compilerVersion string, parsedTools []ParsedTool, ...) (*Pack, error)
- func (pc *PackCompiler) CompileFromRegistryWithParsedTools(packID, compilerVersion string, parsedTools []ParsedTool) (*Pack, error)
- func (pc *PackCompiler) CompileFromRegistryWithTools(packID, compilerVersion string, toolData []ToolData) (*Pack, error)
- func (pc *PackCompiler) CompileToFile(taskType, outputPath, compilerVersion string) error
- func (pc *PackCompiler) MarshalPack(pack *Pack) ([]byte, error)
- func (pc *PackCompiler) WritePack(pack *Pack, outputPath string) error
- type PackPrompt
- type PackTool
- type PackValidationResult
- type ParametersPack
- type ParsedTool
- type PerformanceMetrics
- type ProviderInventory
- type ProviderRequirement
- type Registry
- func (r *Registry) CallParameters(activity, model string) CallParams
- func (r *Registry) ClearCache()
- func (r *Registry) GetAvailableRegions() []string
- func (r *Registry) GetAvailableTaskTypes() []string
- func (r *Registry) GetCachedFragments() []string
- func (r *Registry) GetCachedPrompts() []string
- func (r *Registry) GetInfo(taskType string) (*Info, error)
- func (r *Registry) GetLoadedFragments() []string
- func (r *Registry) GetLoadedPrompts() []string
- func (r *Registry) ListTaskTypes() []string
- func (r *Registry) Load(activity string) *AssembledPrompt
- func (r *Registry) LoadConfig(activity string) (*Config, error)
- func (r *Registry) LoadPromptFragment(taskType string, ref FragmentRef) (*Fragment, error)
- func (r *Registry) LoadTemplate(activity string, vars map[string]string, model string) (*Template, error)
- func (r *Registry) LoadTemplateDeferRequired(activity string, vars map[string]string, model string) (*Template, error)
- func (r *Registry) LoadWithVars(activity string, vars map[string]string, model string) *AssembledPrompt
- func (r *Registry) RegisterConfig(taskType string, config *Config) error
- type Repository
- type Requires
- type ResolvedRequirement
- type SkillSourceConfig
- type Spec
- type Template
- type TemplateEngineInfo
- type TestResultSummary
- type TimeProvider
- type ToolData
- type ToolPolicyPack
- type Validator
- type ValidatorConfig
- type Variable
- type VariableBinding
- type VariableBindingFilter
- type VariableBindingKind
- type VariableMetadata
- type VariableValidation
- type VideoConfig
- type WorkflowConfig
- type WorkflowState
Constants ¶
const ( // AutonomyLevelSuggests — produces output, a human performs any action. AutonomyLevelSuggests = "suggests" // AutonomyLevelActsWithApproval — acts, but each consequential action is // approved first. AutonomyLevelActsWithApproval = "acts_with_approval" // AutonomyLevelActsWithOversight — acts on its own; a human monitors and // can intervene or reverse. AutonomyLevelActsWithOversight = "acts_with_oversight" // AutonomyLevelActsAutonomously — acts without a human in the loop. AutonomyLevelActsAutonomously = "acts_autonomously" )
AutonomyLevel values named by RFC 0013. The schema closes this enum, so a value outside these four fails validation.
const ( // RequirementKeyDefault is reserved for the primary LLM. RequirementKeyDefault = "default" // RequirementRoleLLM is the role a bare string shorthand expands to. RequirementRoleLLM = "llm" // AnyKey marks a role the host can satisfy under any key, for providers // supplied without an identifier to match on. AnyKey = "*" )
Reserved requirement keys and roles named by RFC 0012.
const DefaultBlockedMessage = "Sorry, we can't provide this response as it would violate our content policy."
DefaultBlockedMessage is the user-facing message shown when a content guardrail blocks output.
const PromptPackSchemaURL = "https://promptpack.org/schema/latest/promptpack.schema.json"
PromptPackSchemaURL is the JSON Schema URL for validating PromptPack files
Variables ¶
var ErrUnsafeFragmentValue = errors.New("variable value cannot be used in a fragment path")
ErrUnsafeFragmentValue reports that variables, filled into a fragment's path, would make it climb or leave its directory: a value holding a path separator, "..", a drive colon or a placeholder, or values that together make a ".." segment. The fragment is not loaded.
var ErrVariableNotInEnum = errors.New("variable value is not one of its declared enum values")
ErrVariableNotInEnum reports a variable value outside the values its declaration's validation.enum allows.
Functions ¶
func CallProviderKey ¶ added in v2.13.0
CallProviderKey returns the requires key that runs a call to promptTask, with stepProvider the composition step's own `provider` ("" outside a composition or when the step sets none).
func DescribeGovernance ¶
func DescribeGovernance(g *Governance) string
DescribeGovernance renders a governance declaration as a short human-readable summary, for logs and for the operator who has to answer "what does this thing claim about itself".
Only declared fields appear: an undeclared field is not the same as a default, and printing "autonomy: unknown" invites reading absence as a value.
func DescribeUnsatisfied ¶
func DescribeUnsatisfied(reqs []ResolvedRequirement) string
DescribeUnsatisfied renders requirements for an error or log message, naming what the pack asked for and why, so an operator can act without opening the pack. The description exists in the spec for exactly this purpose.
func ExtractVariablesFromTemplate ¶
ExtractVariablesFromTemplate analyzes a template string and extracts variable names This helps auto-generate variable metadata when not explicitly specified
func GetDefaultPipelineConfig ¶
func GetDefaultPipelineConfig() *packspec.PipelineConfig
GetDefaultPipelineConfig returns the default Arena pipeline configuration Returns as map to avoid import cycle with pipeline package GetDefaultPipelineConfig returns the pipeline a pack gets when it declares none: template, provider and validator stages with their default middleware.
Typed now that PackPrompt.Pipeline is the generated *PipelineConfig rather than a map[string]any.
func GetUsedVars
deprecated
func IsNamedProviderKey ¶ added in v2.13.0
IsNamedProviderKey reports whether key names a requirement rather than the default provider.
func IsPlainFragmentValue ¶ added in v2.19.0
IsPlainFragmentValue reports whether value may fill a fragment's name or path: non-empty, with no path separator, "..", drive colon or placeholder, and not an absolute path.
func NeedsDefaultProvider ¶ added in v2.13.0
NeedsDefaultProvider reports whether any call in p can run on the default provider: a prompt that names no key, or a composition prompt/agent step whose step and prompt name none. When none can, a host that bound every key p names need not supply an agent provider.
func SetMetadataChangelog ¶
func SetMetadataChangelog(m *Metadata, entries []ChangelogEntry)
SetMetadataChangelog stores the version history in the metadata envelope. An empty changelog removes the key.
func SetMetadataPerformance ¶
func SetMetadataPerformance(m *Metadata, p *PerformanceMetrics)
SetMetadataPerformance stores performance benchmarks in the metadata envelope. A nil value removes the key rather than writing a null, so a pack does not gain a meaningless `"performance": null`.
func SkillPath ¶
func SkillPath(s *SkillSourceConfig) string
SkillPath returns the path a skill source points at, resolving the bare-string shorthand. A free function because SkillSourceConfig is the generated type and an alias cannot carry methods.
func SupportsMediaType ¶
func SupportsMediaType(config *MediaConfig, mediaType string) bool
SupportsMediaType checks if a MediaConfig supports a specific media type
func ValidateMediaConfig ¶
func ValidateMediaConfig(config *MediaConfig) error
ValidateMediaConfig validates a MediaConfig for correctness and completeness
Types ¶
type AgentDef ¶
AgentDef provides A2A Agent Card metadata for a single prompt.
Generated from the schema: this is an ALIAS for packspec.AgentDef, not a copy. An alias keeps every call site, tag and behavior identical while making the schema the single source of the shape — a defined type would not, and the two would be free to drift again.
The hand-written struct it replaced was already field-for-field identical to $defs/AgentDef, which is why it is first: the switch is provably a no-op.
type AgentsConfig ¶
type AgentsConfig = packspec.AgentsConfig
AgentsConfig maps prompts to A2A-compatible agent definitions.
Generated from the schema: an ALIAS for packspec.AgentsConfig.
type AssembledPrompt ¶
type AssembledPrompt struct {
TaskType string `json:"task_type"`
SystemPrompt string `json:"system_prompt"`
AllowedTools []string `json:"allowed_tools,omitempty"` // Tools this prompt can use
Validators []ValidatorConfig `json:"validators,omitempty"` // Validators to apply at runtime
}
AssembledPrompt represents a complete prompt ready for LLM execution.
func (*AssembledPrompt) UsesTools ¶
func (ap *AssembledPrompt) UsesTools() bool
UsesTools returns true if this prompt has tools configured
type AudioConfig ¶
type AudioConfig = packspec.AudioConfig
AudioConfig contains audio-specific configuration AudioConfig is generated from the schema: an ALIAS for packspec.AudioConfig, not a copy. The hand-written struct was field-for-field identical to $defs/AudioConfig.
func GetAudioConfig ¶
func GetAudioConfig(config *MediaConfig) *AudioConfig
GetAudioConfig returns the audio configuration if audio is supported
type CallParams ¶ added in v2.13.0
type CallParams struct {
MaxTokens int
Temperature float32
TemperatureSet bool
TopP float32
FrequencyPenalty *float32
PresencePenalty *float32
TopK *int
}
CallParams are the sampling parameters a call to a prompt requests. Zero MaxTokens and TopP, and nil penalties and TopK, mean unset; Temperature is meaningful only with TemperatureSet, so a prompt can ask for a temperature of 0.
type CallSite ¶ added in v2.13.0
type CallSite struct {
// Site names the call site for an error message: `prompt "drafter"`,
// `composition "c" step "s"`.
Site string
// Key is the requires key it runs on.
Key string
// NeedsTools is set when the call runs a tool loop (an agent step, a
// prompt with tools, or a workflow state's prompt), so its provider must
// support tools.
NeedsTools bool
}
CallSite is one call site's reference to a requires key.
func CallSites ¶ added in v2.13.0
CallSites lists, in a stable order, every call site in p that names a non-default key. A host checks each against its bindings before running, so a pack fails at load rather than at the call that reaches a bad key. An agent step that names no key of its own is listed when its prompt names one, because it is the step that needs tool support; a prompt step that inherits its prompt's key is already covered by that prompt.
type ChangelogEntry ¶
type ChangelogEntry struct {
// Version number
Version string `yaml:"version" json:"version"`
// Date of change (YYYY-MM-DD)
Date string `yaml:"date" json:"date"`
// Author of change
Author string `yaml:"author,omitempty" json:"author,omitempty"`
// Description of change
Description string `yaml:"description" json:"description"`
}
ChangelogEntry records a change in the prompt configuration
func MetadataChangelog ¶
func MetadataChangelog(m *Metadata) []ChangelogEntry
MetadataChangelog returns the version history a pack declares, or nil. See MetadataPerformance for why this is not a struct field.
type CompilationInfo ¶
type CompilationInfo = packspec.PackCompilation
CompilationInfo records when and how a pack was compiled.
Generated. `compilation` is a spec property with a defined shape (compiled_with, created_at and schema are all required), not a promptkit extension — it was hand-written here on the false premise that it was one.
type CompileOption ¶
type CompileOption func(*compileOptions)
CompileOption configures optional fields for CompileFromRegistryWithOptions.
func WithAgents ¶
func WithAgents(a *AgentsConfig) CompileOption
WithAgents sets the agents config on the compiled pack.
func WithCompositions ¶
func WithCompositions(c map[string]*composition.Composition) CompileOption
WithCompositions sets the compositions map on the compiled pack.
func WithMetadata ¶
func WithMetadata(m *Metadata) CompileOption
WithMetadata sets the pack-level metadata block — domain, language, tags, cost_estimate and governance (RFC 0013).
Governance had no authoring route before this: metadata.governance could be carried in a compiled pack and never written by an author, which is the same as not existing.
func WithSkills ¶
func WithSkills(s []SkillSourceConfig) CompileOption
WithSkills sets the skills config on the compiled pack.
func WithWorkflow ¶
func WithWorkflow(w *workflow.Spec) CompileOption
WithWorkflow sets the workflow config on the compiled pack.
type Config ¶
type Config struct {
APIVersion string `yaml:"apiVersion" json:"apiVersion"`
Kind string `yaml:"kind" json:"kind"`
Metadata metav1.ObjectMeta `yaml:"metadata,omitempty" json:"metadata,omitempty"`
Spec Spec `yaml:"spec" json:"spec"`
}
Config represents a YAML prompt configuration file in K8s-style manifest format
func ParseConfig ¶
ParseConfig parses a prompt config from YAML data. This is a package-level utility function for parsing prompt configs in the config layer. The config layer should read files using os.ReadFile and pass the data to this function. Returns the parsed Config or an error if parsing/validation fails.
func ToConfig ¶
func ToConfig(pr *PackPrompt, taskType string) *Config
ToConfig converts a pack prompt into a prompt.Config suitable for registration in a prompt.Registry. It carries the fields the prompt-assembly pipeline needs; tools and validators are wired separately by the caller. Extensions are deep-copied, so a pack → config → pack round trip keeps them and editing the Config never reaches the pack.
func (*Config) GetAllowedTools ¶
GetAllowedTools returns the allowed tools from the prompt config
func (*Config) GetTaskType ¶
GetTaskType returns the task type from the prompt config
type ConfigDirResolver ¶ added in v2.18.0
ConfigDirResolver is implemented by a Repository that loads prompt configs from files. PromptDir returns the directory the config for taskType was loaded from: the base a FragmentRef.Path is relative to. The YAML and JSON file repositories implement it.
type CostEstimate ¶
type CostEstimate = packspec.PackMetadataCostEstimate
CostEstimate provides estimated costs for prompt execution.
Generated, for the same reason as Metadata. Note the fields are *float64: the spec makes all three optional, and a plain float64 cannot tell "no estimate" from "estimated at zero".
type DocumentConfig ¶
type DocumentConfig = packspec.DocumentConfig
DocumentConfig configures document media (PDFs, CAD files, spreadsheets). Reachable now that MediaConfig is the generated type.
type ExampleContentPart ¶
type ExampleContentPart = packspec.ContentPart
ExampleContentPart is one content part of a multimodal example.
Generated. This is $defs/ContentPart, the PACK authoring type — distinct from types.ContentPart, which is the runtime message type and a different graph.
type ExampleMedia ¶
type ExampleMedia = packspec.MediaReference
ExampleMedia is a media reference inside a multimodal example.
Generated. The hand-written version was identical property-for-property except that it lacked `base64`, so a pack embedding media inline lost it.
Note the Go field is MimeType, not MIMEType: the generator derives names from the schema, and renaming it by hand would put this type back outside the generated guarantee for the sake of two characters.
type FileWriter ¶
FileWriter abstracts file writing for testing
type Fragment ¶
type Fragment struct {
Type string `yaml:"fragment_type"`
Version string `yaml:"version"`
Description string `yaml:"description"`
Content string `yaml:"content"`
SourceFile string `yaml:"source_file,omitempty"` // Source file path (for pack compilation)
ResolvedAtCompile bool `yaml:"resolved_at_compile,omitempty"` // Whether resolved at compile time
}
Fragment represents a reusable prompt fragment
type FragmentLoader ¶ added in v2.18.0
type FragmentLoader interface {
LoadPromptFragment(taskType string, ref FragmentRef) (*Fragment, error)
}
FragmentLoader is implemented by a Loader that can load a prompt's fragment references at compile time. *Registry implements it, through its repository. The pack compiler resolves fragments through it. A Loader that does not implement it cannot load fragments, so the compiler writes each reference as its "{{name}}" placeholder, as it did before it resolved fragments.
type FragmentRef ¶
type FragmentRef struct {
Name string `yaml:"name"`
Path string `yaml:"path,omitempty"` // Optional: relative path to fragment file
Required bool `yaml:"required"`
}
FragmentRef references a prompt fragment for assembly
type FragmentRepository ¶
type FragmentRepository interface {
LoadFragment(name, relativePath, baseDir string) (*Fragment, error)
}
FragmentRepository interface for loading fragments (to avoid import cycles)
type FragmentResolver ¶
type FragmentResolver struct {
// contains filtered or unexported fields
}
FragmentResolver handles fragment loading, resolution, and variable substitution using the repository pattern.
It is safe for concurrent use: one Registry, and so one resolver, serves every conversation built on it, and a fragment chosen by a variable is first loaded, and cached, by whichever turn asks for it first.
func NewFragmentResolverWithRepository ¶
func NewFragmentResolverWithRepository(repository FragmentRepository) *FragmentResolver
NewFragmentResolverWithRepository creates a new fragment resolver with a repository
func (*FragmentResolver) AssembleFragments ¶
func (fr *FragmentResolver) AssembleFragments( fragments []FragmentRef, vars map[string]string, configFilePath string, ) (map[string]string, error)
AssembleFragments loads and assembles prompt fragments into variables. Resolves dynamic names and paths using the provided variable map.
func (*FragmentResolver) LoadFragment ¶
func (fr *FragmentResolver) LoadFragment(name, relativePath, baseDir string) (*Fragment, error)
LoadFragment loads a fragment from the repository with caching.
A reference without a path is loaded and cached by name. A path is resolved as follows:
- an absolute path names one file and is loaded as it is, with no base dir;
- a relative path is loaded against baseDir first and, when no file exists there, against the repository's own default base (an empty base dir: for the file repositories, the process's working directory). Any other failure under baseDir is returned as it is.
type Governance ¶
type Governance = packspec.Governance
Governance is a governance declaration, at pack or agent level.
func AgentGovernance ¶
func AgentGovernance(pack *Pack, agent string) (*Governance, error)
AgentGovernance returns an agent's own governance declaration as written, without inheriting anything from the pack. Use ResolveGovernance for the effective values; this is for reporting what the pack actually says.
The error distinguishes "this agent declares no governance" from "there is no such agent" — see ResolveGovernance.
func PackGovernance ¶
func PackGovernance(pack *Pack) *Governance
PackGovernance returns the pack-level governance declaration, or nil.
Returns a copy: the result is a statement about the pack, and a caller that adjusted it in place would rewrite the loaded pack for everyone else.
func ResolveGovernance ¶
func ResolveGovernance(pack *Pack, agent string) (*Governance, error)
ResolveGovernance returns the effective governance for one agent: the pack declaration with the agent's own fields laid over it.
An unknown agent is an error rather than a fallback to the pack values. For most lookups a quiet fallback is a convenience; for governance it is a lie — a caller asking about "billing-agent" and getting the pack's autonomy level because it typed the name wrong would be told the agent needs no approval when nothing had been checked at all.
An empty agent name returns the pack-level declaration, so callers that may or may not be scoped to an agent need no special case.
type GovernanceValidationResult ¶ added in v2.13.0
GovernanceValidationResult carries the outcome of ValidateGovernance. An error makes the pack invalid; a warning does not.
type ImageConfig ¶
type ImageConfig = packspec.ImageConfig
ImageConfig contains image-specific configuration Generated from the schema: an ALIAS for packspec.ImageConfig. default_detail is *string: the spec defaults it to "auto", so absent and empty differ.
func GetImageConfig ¶
func GetImageConfig(config *MediaConfig) *ImageConfig
GetImageConfig returns the image configuration if images are supported
type Info ¶
type Info struct {
TaskType string
Version string
Description string
FragmentCount int
RequiredVars []string
OptionalVars []string
ToolAllowlist []string
ModelOverrides []string
}
Info provides summary information about a prompt configuration
type MediaConfig ¶
type MediaConfig = packspec.MediaConfig
MediaConfig configures multimodal support for a prompt.
Generated. It was hand-written, and dropped $defs/MediaConfig's `document` property entirely — a prompt declaring document media round-tripped to nothing. Same failure as metadata.governance, same fix.
type Metadata ¶
type Metadata = packspec.PackMetadata
Metadata contains additional metadata for the pack format.
This is the generated type: metadata is where the PromptPack spec puts the facts a pack declares ABOUT itself rather than about its execution, so it is where formalization lands as the spec grows — v1.6.0 added `governance` (RFC 0013: accountable owner, autonomy level, risk classification), and more of that shape is coming. A hand-written struct here dropped `governance` silently on load: the field validated, round-tripped clean, and vanished.
Generated means new spec properties arrive by regeneration, and `make packspec-check` fails if they have not.
Performance and Changelog are NOT spec properties. They live in Extra, which the spec permits (metadata is additionalProperties:true), and are reached through the accessors below rather than as struct fields.
type MetadataBuilder ¶
type MetadataBuilder struct {
// contains filtered or unexported fields
}
MetadataBuilder helps construct pack format metadata from prompt configs and test results
func NewMetadataBuilder ¶
func NewMetadataBuilder(spec *Spec) *MetadataBuilder
NewMetadataBuilder creates a new metadata builder for a prompt spec
func (*MetadataBuilder) AddChangelogEntry ¶
func (mb *MetadataBuilder) AddChangelogEntry(version, author, description string)
AddChangelogEntry adds a new entry to the prompt's changelog
func (*MetadataBuilder) BuildCompilationInfo ¶
func (mb *MetadataBuilder) BuildCompilationInfo(compilerVersion string) *CompilationInfo
BuildCompilationInfo generates compilation metadata
func (*MetadataBuilder) BuildMetadata ¶
func (mb *MetadataBuilder) BuildMetadata( domain, language string, tags []string, testResults []TestResultSummary, ) *Metadata
BuildMetadata generates Metadata from test execution results
func (*MetadataBuilder) SetDomain ¶
func (mb *MetadataBuilder) SetDomain(domain string)
SetDomain sets the domain for the prompt metadata
func (*MetadataBuilder) SetLanguage ¶
func (mb *MetadataBuilder) SetLanguage(language string)
SetLanguage sets the language for the prompt metadata
func (*MetadataBuilder) SetTags ¶
func (mb *MetadataBuilder) SetTags(tags []string)
SetTags sets the tags for the prompt metadata
func (*MetadataBuilder) UpdateFromCostInfo ¶
func (mb *MetadataBuilder) UpdateFromCostInfo(costs []types.CostInfo)
UpdateFromCostInfo updates cost estimate from types.CostInfo
func (*MetadataBuilder) ValidateMetadata ¶
func (mb *MetadataBuilder) ValidateMetadata() []string
ValidateMetadata checks that metadata fields are properly populated
type ModelOverride ¶
type ModelOverride = packspec.ModelOverride
ModelOverride contains model-specific template modifications. Note: Temperature and MaxTokens should be configured at the scenario or provider level, not in the prompt configuration.
The spec's $defs/ModelOverride also defines system_template_prefix and parameters. Neither is added here: nothing in the runtime assembles a prefix or applies per-model parameters, so declaring them would be vocabulary with a consumer and no producer. They are recorded as codegen candidates in docs/local-backlog/PACK_TYPES_FROM_SCHEMA_CODEGEN.md rather than added blind. Generated from the schema: an ALIAS for packspec.ModelOverride. Gains system_template_prefix and parameters from the spec.
type ModelTestResultRef ¶
type ModelTestResultRef = packspec.TestedModel
ModelTestResultRef is a simplified reference to model test results The full ModelTestResult type is in pkg/engine for tracking test execution ModelTestResultRef is the Go form of the spec's $defs/TestedModel.
provider, model and date are required by the spec, so they carry no omitempty — a required field that vanishes on serialize produces a pack that fails its own validation. Generated from the schema: an ALIAS for packspec.TestedModel. avg_tokens/avg_latency_ms are float64: the spec types them as number, not integer.
func AggregateTestResults ¶
func AggregateTestResults(results []TestResultSummary, provider, model string) *ModelTestResultRef
AggregateTestResults computes ModelTestResultRef from test execution summaries
type MultimodalExample ¶
type MultimodalExample = packspec.MultimodalExample
MultimodalExample is a few-shot example carrying media.
Generated, so that MediaConfig.Examples is the generated slice type.
type Pack ¶
type Pack struct {
packspec.Pack `yaml:",inline"`
// FilePath is the on-disk path this pack was loaded from, if any. It is
// never serialized; loaders set it so schema/fragment resolution can
// resolve paths relative to the pack file.
FilePath string `json:"-" yaml:"-"`
}
Pack represents a compiled PromptPack.
EMBEDS the generated type rather than aliasing it. Go has no partial classes, and a type alias cannot carry methods — but an embedded type can, and Pack has eighteen (Validate, ValidateWorkflow, ValidateAgents, GetPrompt, ...). Every spec property is promoted from packspec.Pack, so the properties cannot drift even though the methods live here.
This is the general answer for a pack type with behavior attached. An alias is still preferable where the methods are few enough to become free functions, because an alias gives true identity with the generated type; embedding needs .Pack to extract it. Types with a method set that IS their API embed instead.
FilePath is the only field of our own, and it is the reason a bare alias would not do even without the methods.
func (*Pack) GetOptionalVariables ¶
GetOptionalVariables returns all optional variable names with defaults for a specific prompt
func (*Pack) GetPrompt ¶
func (p *Pack) GetPrompt(taskType string) *PackPrompt
GetPrompt returns a specific prompt by task type
func (*Pack) GetRequiredVariables ¶
GetRequiredVariables returns all required variable names for a specific prompt
func (*Pack) GetToolNames ¶
GetToolNames returns the list of allowed tool names for a specific prompt
func (*Pack) ListPrompts ¶
ListPrompts returns all prompt task types in the pack, sorted.
func (*Pack) PromptConfig ¶ added in v2.19.0
PromptConfig converts the pack's prompt for taskType into a Config for a prompt.Registry, as ToConfig does, and gives it a reference to each of the pack's fragments. The PromptPack spec defines a pack's fragments as content any of its prompts can reference, so the registry renders a prompt's "{{name}}" placeholder from the fragment of that name; register the fragments with the registry's repository by name. It returns nil when the pack has no prompt for taskType.
A fragment whose name holds a variable (persona_{{region}}) gets no reference: a render resolves the name to one the pack does not hold, so its placeholder is left for the caller's variables to fill, and fails the render when nothing does. Neither does a fragment named like a variable the prompt declares: the variable wins.
func (*Pack) Validate ¶
Validate validates a pack format and returns its findings in one list, whatever their severity: ValidateDetailed's errors followed by its warnings. Among the errors are the eval definitions evals.ValidateEvals rejects, at pack level and in each prompt.
It leaves out two kinds of warning ValidateDetailed reports: undeclared prompt tools, and eval triggers this runtime does not know. Callers have treated every Validate finding as blocking, and both are legitimate in a valid pack: a host may supply the tool, and the schema leaves trigger open. Use ValidateDetailed to see them and to tell errors from warnings.
func (*Pack) ValidateAgents ¶
ValidateAgents validates the agents section of the pack. Returns errors (which block compilation) and warnings (informational).
func (*Pack) ValidateCompositions ¶
func (p *Pack) ValidateCompositions() *composition.ValidationResult
ValidateCompositions validates the pack's compositions (RFC 0010): each composition's internal rules + reference resolution against the pack's prompts/tools/evals, plus pack-level cross-checks against the workflow.
func (*Pack) ValidateDetailed ¶ added in v2.18.0
func (p *Pack) ValidateDetailed() *PackValidationResult
ValidateDetailed runs Validate's checks, plus a check of each prompt's tools against the pack's tools, and splits the findings by severity. Three are warnings rather than errors:
- a missing compilation block, which the PromptPack schema does not require;
- a prompt tool the pack's tools do not define. The schema asks for every prompt tool to be defined there, but a host may supply tools a pack does not carry (MCP servers, workflow and memory tools, skills);
- an eval trigger this runtime does not know. The schema lists trigger values as examples, not an enum, but the SDK skips such an eval.
Workflow, agents and governance findings keep the severity their own validators give them.
func (*Pack) ValidateGovernance ¶ added in v2.13.0
func (p *Pack) ValidateGovernance() *GovernanceValidationResult
ValidateGovernance checks the RFC 0016 rules JSON Schema cannot express.
Rules 2, 4, 5 and 8 apply to each governance object as written: the pack's and each agent's. Rules 6 and 7 apply to each effective object — the pack's, and each agent's resolved against it — because a control or review can legitimately rely on a field or obligation the agent inherits. Rule 10's undeclared-prefix check is a warning, never an error.
A pack declaring no governance produces an empty result unless two of its validators share an id, which rule 5 forbids whether or not anything references them.
func (*Pack) ValidateWorkflow ¶
func (p *Pack) ValidateWorkflow() *workflow.ValidationResult
ValidateWorkflow validates the workflow section and returns a detailed result with separate errors and warnings. Returns an empty result if no workflow is present.
type PackCompiler ¶
type PackCompiler struct {
// contains filtered or unexported fields
}
PackCompiler compiles Config to Pack format
func NewPackCompiler ¶
func NewPackCompiler(registry *Registry) *PackCompiler
NewPackCompiler creates a new pack compiler with default dependencies
func NewPackCompilerWithDeps ¶
func NewPackCompilerWithDeps(loader Loader, timeProvider TimeProvider, fileWriter FileWriter) *PackCompiler
NewPackCompilerWithDeps creates a pack compiler with injected dependencies (for testing)
func (*PackCompiler) Compile ¶
func (pc *PackCompiler) Compile(taskType, compilerVersion string) (*Pack, error)
Compile compiles a single prompt config to Pack format (for backward compatibility). The pack id is the task type with underscores replaced by hyphens.
func (*PackCompiler) CompileFromRegistry ¶
func (pc *PackCompiler) CompileFromRegistry(packID, compilerVersion string) (*Pack, error)
CompileFromRegistry compiles ALL prompts from the registry into a single Pack.
Prompts are compiled in sorted task-type order, so the output never depends on map order. A pack has one template_engine: it is the engine the prompts declare, and prompts that declare different engines are an error. A prompt whose engine equals the registry default counts as declaring none, because the registry fills that default in on every prompt that omits the field.
func (*PackCompiler) CompileFromRegistryWithOptions ¶
func (pc *PackCompiler) CompileFromRegistryWithOptions( packID, compilerVersion string, parsedTools []ParsedTool, packEvals []evals.EvalDef, opts ...CompileOption, ) (*Pack, error)
CompileFromRegistryWithOptions compiles ALL prompts from the registry into a single Pack with pre-parsed tool definitions, pack-level eval definitions, and optional workflow/agents config.
func (*PackCompiler) CompileFromRegistryWithParsedTools ¶
func (pc *PackCompiler) CompileFromRegistryWithParsedTools( packID, compilerVersion string, parsedTools []ParsedTool, ) (*Pack, error)
CompileFromRegistryWithParsedTools compiles ALL prompts from the registry into a single Pack and includes pre-parsed tool definitions. Use this when YAML parsing happens externally.
func (*PackCompiler) CompileFromRegistryWithTools ¶
func (pc *PackCompiler) CompileFromRegistryWithTools( packID, compilerVersion string, toolData []ToolData, ) (*Pack, error)
CompileFromRegistryWithTools compiles ALL prompts from the registry into a single Pack and includes tool definitions from the provided tool data. This method satisfies PromptPack spec Section 9 which requires tools to be defined at pack level with name, description, and parameters.
func (*PackCompiler) CompileToFile ¶
func (pc *PackCompiler) CompileToFile(taskType, outputPath, compilerVersion string) error
CompileToFile compiles a prompt config to a JSON pack file
func (*PackCompiler) MarshalPack ¶
func (pc *PackCompiler) MarshalPack(pack *Pack) ([]byte, error)
MarshalPack marshals pack to JSON (testable without I/O)
type PackPrompt ¶
PackPrompt is a single prompt definition within a pack.
Generated. It is the hub every prompt hangs off, so adopting it was left until everything reachable from it was generated first — validators, evals, variables, tested_models, model_overrides, media and parameters are all packspec types now, and the generated Prompt holds them as slices and maps of POINTERS, which is the shape the schema implies for optional objects.
ToPromptConfig() was a method. A type alias cannot carry methods, so it is the free function ToConfig below.
type PackTool ¶
PackTool represents a tool definition in the pack (per PromptPack spec Section 9). Tools are defined at pack level and referenced by prompts via the tools array.
Generated from the schema: an ALIAS for packspec.Tool.
Parameters is *ToolParameters rather than the interface{} the hand-written type used. The spec defines a shape here (type/properties/required) and interface{} ignored it; the generated type keeps that shape while remaining extensible, since Tool.parameters omits additionalProperties and JSON Schema defaults it to true. So a tool schema using $defs, oneOf or any other keyword still round-trips, through ToolParameters.Extra.
func ConvertToolToPackTool ¶
func ConvertToolToPackTool(name, description string, inputSchema json.RawMessage) *PackTool
ConvertToolToPackTool converts a tool descriptor to a PackTool. This is the preferred method when tool parsing happens externally.
It does not take action_scope or extensions: PackTool is the generated type, so a caller sets those fields on the result directly rather than growing this signature every time the spec adds a tool property.
type PackValidationResult ¶ added in v2.18.0
PackValidationResult is ValidateDetailed's result. Errors are findings that make the pack unusable or schema-invalid; Warnings are findings a valid pack may still have.
type ParametersPack ¶
type ParametersPack = packspec.Parameters
ParametersPack represents model parameters in pack format Generated from the schema: an ALIAS for packspec.Parameters. Gains frequency_penalty and presence_penalty, which the spec defines and the hand-written type omitted.
type ParsedTool ¶
type ParsedTool struct {
Name string
Description string
InputSchema json.RawMessage
}
ParsedTool holds pre-parsed tool information for compilation Use this when YAML parsing happens in the calling package
type PerformanceMetrics ¶
type PerformanceMetrics struct {
// Average latency in milliseconds
AvgLatencyMs int `yaml:"avg_latency_ms" json:"avg_latency_ms"`
// 95th percentile latency
P95LatencyMs int `yaml:"p95_latency_ms" json:"p95_latency_ms"`
// Average tokens used
AvgTokens int `yaml:"avg_tokens" json:"avg_tokens"`
// Success rate (0.0-1.0)
SuccessRate float64 `yaml:"success_rate" json:"success_rate"`
}
PerformanceMetrics provides performance benchmarks
func MetadataPerformance ¶
func MetadataPerformance(m *Metadata) *PerformanceMetrics
MetadataPerformance returns the performance benchmarks a pack declares, or nil.
performance is not a PromptPack property — it is a PromptKit extension carried in the metadata envelope the spec leaves open. Keeping the type assertion here rather than at each call site is what stops a silent nil creeping in; a value of the wrong shape yields nil rather than a half-populated struct.
type ProviderInventory ¶
ProviderInventory is what a host can supply, as role -> available keys.
type ProviderRequirement ¶
type ProviderRequirement = packspec.ProviderRequirement
ProviderRequirement is a single logical provider dependency.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages prompt templates, versions, and variable substitution.
func NewRegistryWithRepository ¶
func NewRegistryWithRepository(repository Repository) *Registry
NewRegistryWithRepository creates a registry with a repository (new preferred method). This constructor uses the repository pattern for loading prompts, avoiding direct file I/O.
func (*Registry) CallParameters ¶ added in v2.13.0
func (r *Registry) CallParameters(activity, model string) CallParams
CallParameters returns the sampling parameters a call to activity's prompt on model requests: the prompt's parameters, then those of its model_overrides entry for model. An unknown activity, or a prompt that sets none, returns the zero CallParams, leaving the provider's defaults.
func (*Registry) ClearCache ¶
func (r *Registry) ClearCache()
ClearCache clears all cached prompts and fragments
func (*Registry) GetAvailableRegions ¶
GetAvailableRegions returns the regions named by the fragments loaded so far (see GetCachedFragments), sorted.
func (*Registry) GetAvailableTaskTypes ¶
GetAvailableTaskTypes is deprecated: use ListTaskTypes instead
func (*Registry) GetCachedFragments ¶
GetCachedFragments returns the cache keys of the fragments loaded so far, sorted. A reference with no path is keyed "name:<name>"; one with a path "path:<file path>", the path it resolved to (against the prompt's directory, or as written for the working-directory fallback and an absolute path). The prefixes keep a name holding "/" apart from an equal path.
func (*Registry) GetCachedPrompts ¶
GetCachedPrompts returns a list of currently cached prompt task types. For a complete list including uncached prompts, use ListTaskTypes instead.
func (*Registry) GetLoadedFragments ¶
GetLoadedFragments is deprecated: use GetCachedFragments instead
func (*Registry) GetLoadedPrompts ¶
GetLoadedPrompts is deprecated: use GetCachedPrompts instead
func (*Registry) ListTaskTypes ¶
ListTaskTypes returns all available task types from the repository. Falls back to cached task types if repository is unavailable or returns empty.
func (*Registry) Load ¶
func (r *Registry) Load(activity string) *AssembledPrompt
Load returns an assembled prompt for the specified activity with variable substitution.
func (*Registry) LoadConfig ¶
LoadConfig is deprecated: use loadConfig directly (internal use) or use Load/LoadWithVars
func (*Registry) LoadPromptFragment ¶ added in v2.18.0
func (r *Registry) LoadPromptFragment(taskType string, ref FragmentRef) (*Fragment, error)
LoadPromptFragment loads one of a prompt's fragment references through the registry's repository. A relative FragmentRef.Path resolves against the prompt config's directory, falling back to the repository's default base (for the file repositories, the working directory) when no file exists there; an absolute path is used as it is. It does not substitute variables, so a reference whose name or path contains a {{variable}} is loaded literally; the pack compiler leaves those unresolved. *Registry implements FragmentLoader with it.
func (*Registry) LoadTemplate ¶
func (r *Registry) LoadTemplate(activity string, vars map[string]string, model string) (*Template, error)
LoadTemplate loads a prompt without rendering, returning the raw template and all metadata needed to render it later. This is the preferred path for pipeline stages that separate assembly from rendering (e.g. PromptAssemblyStage + TemplateStage). The returned Template is safe to cache across requests.
It fails when a required variable has no non-empty value in vars. A caller that learns some variables only after loading uses LoadTemplateDeferRequired instead.
func (*Registry) LoadTemplateDeferRequired ¶ added in v2.19.0
func (r *Registry) LoadTemplateDeferRequired(activity string, vars map[string]string, model string) (*Template, error)
LoadTemplateDeferRequired is LoadTemplate without the required-variable check, for a caller that supplies more variables when it renders: the pipeline merges SetVar and VariableProvider values into the turn after the template is loaded. The caller checks Template.RequiredVars against the variables it renders with (TemplateStage does, and fails the turn with ErrTemplateUnresolved). Every other load failure is returned as from LoadTemplate.
func (*Registry) LoadWithVars ¶
func (r *Registry) LoadWithVars(activity string, vars map[string]string, model string) *AssembledPrompt
LoadWithVars loads a prompt with variable substitution and optional model override.
func (*Registry) RegisterConfig ¶
RegisterConfig registers a Config directly into the registry. This allows programmatic registration of prompts without requiring disk files. Useful for loading prompts from compiled packs or other in-memory sources. If a repository is configured, the config is persisted there as well.
type Repository ¶
type Repository interface {
LoadPrompt(taskType string) (*Config, error)
LoadFragment(name, relativePath, baseDir string) (*Fragment, error)
ListPrompts() ([]string, error)
SavePrompt(config *Config) error
}
Repository interface defines methods for loading prompts (to avoid import cycles) This should match persistence.Repository interface
type Requires ¶
type Requires = packspec.PackRequires
Requires is the pack-level requirements block.
type ResolvedRequirement ¶
ResolvedRequirement is a requirement with the spec's defaults applied, so consumers never have to know which fields were written and which were implied.
func ResolveRequirements ¶
func ResolveRequirements(p *Pack) ([]ResolvedRequirement, error)
ResolveRequirements expands a pack's requirements into their full form and reports the spec's structural rules.
Two rules the JSON Schema cannot express, both stated in prose by RFC 0012:
- a bare string is shorthand for {key: <string>, role: "llm", required: true}
- key values MUST be unique, key being the sole discriminator between requirements
A duplicate key is an error rather than a last-one-wins merge: two entries with one key means the author intended two providers and will get one, which is the kind of silent loss this whole area keeps producing.
func Unsatisfied ¶
func Unsatisfied(reqs []ResolvedRequirement, have ProviderInventory) (required, optional []ResolvedRequirement)
Unsatisfied splits a pack's requirements into those the inventory cannot satisfy, separating required from optional so the caller can apply the spec's error-versus-warning distinction.
Matching is on key AND role: a requirement for an `embedding` named "judge" is not satisfied by an `llm` named "judge". Resolution beyond that — which concrete model, from where — is explicitly the host's business, not the spec's.
A host may list AnyKey for a role to mean "one provider of this role is wired, but it has no name to match on". That covers providers supplied programmatically rather than by key; without it the check rejects a host that has wired a working provider, and a false failure at Open is worse than no check, because it blocks a correct setup rather than an incorrect one.
type SkillSourceConfig ¶
type SkillSourceConfig = packspec.SkillSource
SkillSourceConfig declares a skill source for the pack.
Generated. $defs/SkillSource is a oneOf over a bare string, a SkillPathSource and an InlineSkill; the generator flattens that into one struct AND emits the Marshal/Unmarshal pair that keeps the scalar form in Shorthand, so the union needed no hand-written code at all.
The legacy `dir` alias is GONE. It was promptkit-only, and because $defs/SkillPathSource is additionalProperties:false and requires `path`, a pack emitted from `dir` failed validation three ways at once. No shipped pack used it. Author `path` instead, or the bare-string shorthand.
type Spec ¶
type Spec struct {
TaskType string `yaml:"task_type" json:"task_type"`
Version string `yaml:"version" json:"version"`
Description string `yaml:"description" json:"description"`
// TemplateEngine is the template engine configuration.
TemplateEngine *TemplateEngineInfo `yaml:"template_engine,omitempty" json:"template_engine,omitempty"`
// Fragments drive fragment assembly.
Fragments []FragmentRef `yaml:"fragments,omitempty" json:"fragments,omitempty"`
SystemTemplate string `yaml:"system_template" json:"system_template"`
// Variables are the variable definitions with rich metadata.
Variables []VariableMetadata `yaml:"variables,omitempty" json:"variables,omitempty"`
ModelOverrides map[string]ModelOverride `yaml:"model_overrides,omitempty" json:"model_overrides,omitempty"`
// AllowedTools are the tools this prompt can use.
AllowedTools []string `yaml:"allowed_tools,omitempty" json:"allowed_tools,omitempty"`
// MediaConfig is the multimodal media configuration.
MediaConfig *MediaConfig `yaml:"media,omitempty" json:"media,omitempty"`
// Validators are the validators/guardrails for the production runtime.
Validators []ValidatorConfig `yaml:"validators,omitempty" json:"validators,omitempty"`
// TestedModels is the model testing metadata.
TestedModels []ModelTestResultRef `yaml:"tested_models,omitempty" json:"tested_models,omitempty"`
ToolPolicy *ToolPolicyPack `yaml:"tool_policy,omitempty" json:"tool_policy,omitempty"`
Parameters *ParametersPack `yaml:"parameters,omitempty" json:"parameters,omitempty"`
Evals []evals.EvalDef `yaml:"evals,omitempty" json:"evals,omitempty"`
Metadata *Metadata `yaml:"metadata,omitempty" json:"metadata,omitempty"`
Compilation *CompilationInfo `yaml:"compilation,omitempty" json:"compilation,omitempty"`
// Extensions are opaque policy annotations about this prompt (RFC 0016),
// carried into the compiled pack unchanged and never interpreted by
// PromptKit. Keys SHOULD be namespaced to the tool that reads them, for
// example `vendor.feature` (promptarena.qualification); the spec does not
// enforce a key format, so neither does PromptKit.
Extensions map[string]any `yaml:"extensions,omitempty" json:"extensions,omitempty"`
}
Spec contains the actual prompt configuration
type Template ¶
type Template struct {
TaskType string `json:"task_type"`
RawTemplate string `json:"raw_template"`
DefaultVars map[string]string `json:"default_vars,omitempty"`
RequiredVars []string `json:"required_vars,omitempty"`
FragmentVars map[string]string `json:"fragment_vars,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
Validators []ValidatorConfig `json:"validators,omitempty"`
ModelOverride string `json:"model_override,omitempty"`
// ToolPolicy is the prompt's declared tool_policy, if any. The provider
// stage merges it with its caller's policy (pipeline.MergeToolPolicy).
ToolPolicy *ToolPolicyPack `json:"tool_policy,omitempty"`
}
Template holds an unrendered prompt template with all metadata required to render it later. This is the intermediate form produced by LoadTemplate, consumed by the TemplateStage to perform deferred variable substitution.
type TemplateEngineInfo ¶
type TemplateEngineInfo = packspec.PackTemplateEngine
TemplateEngineInfo is the pack's template engine configuration.
Generated. template_engine is an inline object under the root's properties rather than a $def, but the generator emits types for those too — this is packspec.PackTemplateEngine, and it was field-for-field identical to the hand-written struct it replaced.
type TestResultSummary ¶
TestResultSummary contains summarized test execution data
type TimeProvider ¶
TimeProvider allows injecting time for deterministic tests
type ToolPolicyPack ¶
type ToolPolicyPack = packspec.ToolPolicy
ToolPolicyPack represents tool policy in pack format Generated from the schema: an ALIAS for packspec.ToolPolicy. max_rounds, max_tool_calls_per_turn and tool_choice are pointers for the same reason.
type Validator ¶
Validator is a compiled pack validator.
Generated. It carries the spec's `message`, which the COMPILED form does not use — foldValidatorMessages folds it into params at compile time, so nothing populates it and omitempty keeps it out of the emitted pack. Carrying an unused field is cheaper than maintaining a second definition of this type.
func ValidatorValues ¶
ValidatorValues dereferences a slice of validator pointers into values, at the boundary between the generated Prompt (which holds pointers) and the APIs that take values. A nil entry is skipped.
type ValidatorConfig ¶
type ValidatorConfig struct {
Type string `yaml:"type" json:"type"`
Params map[string]interface{} `yaml:"params" json:"params"`
// Enable/disable validator (default: true)
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
// FailOnViolation is ignored — guardrails always enforce. This used to
// be a deviation from the spec; as of PromptPack v1.7.0 it is the
// conformant behavior and the field is the deprecated thing. RFC 0015
// keeps it schema-valid through v1.x and removes it in v2.0.0, no
// earlier than 2027-08-31.
//
// Disable a validator with enabled: false. For observation without
// enforcement, declare an eval and assert on its score.
//
// https://promptpack.org/docs/rfcs/deprecate-fail-on-violation
FailOnViolation *bool `yaml:"fail_on_violation,omitempty" json:"fail_on_violation,omitempty"`
// User-facing message shown when content is blocked (default: DefaultBlockedMessage)
Message string `yaml:"message,omitempty" json:"message,omitempty"`
// ID names the validator so a governance obligation control can refer to
// it (RFC 0016). It does not change how the validator runs.
ID string `yaml:"id,omitempty" json:"id,omitempty"`
// Extensions are opaque policy annotations about this validator (RFC
// 0016), carried into the compiled pack unchanged. They are never merged
// into Params and never reach the validator's handler.
Extensions map[string]any `yaml:"extensions,omitempty" json:"extensions,omitempty"`
// Declaration is the pack's definition of this validator (RFC 0016),
// carried to the guardrail so validation events can report it. Nil when
// the validator does not come from a pack. Never passed to the handler.
Declaration *packspec.Validator `yaml:"-" json:"-"`
}
ValidatorConfig describes a validator/guardrail configuration from a prompt pack.
type Variable ¶
Variable is a spec-exact compiled prompt template variable.
Generated. It deliberately omits nothing of its own: Binding IS on the generated type, but compileVariables never populates it, because variable binding (auto-population from platform resources) is a runtime concern resolved at compile time and not part of the portable pack. The authoring type VariableMetadata carries it; omitempty keeps it out of the emitted pack.
toMetadata() was a method. A type alias cannot carry methods, so it is VariableToMetadata below.
type VariableBinding ¶
type VariableBinding struct {
// Kind specifies the type of resource to bind to.
Kind VariableBindingKind `yaml:"kind" json:"kind"`
// Field specifies which field of the resource to bind (e.g., "name", "model").
Field string `yaml:"field,omitempty" json:"field,omitempty"`
// AutoPopulate enables automatic population of this variable from the bound resource.
// When true, the variable may be auto-filled and optionally hidden from the wizard.
AutoPopulate bool `yaml:"autoPopulate,omitempty" json:"autoPopulate,omitempty"`
// Filter specifies criteria for filtering bound resources.
Filter *VariableBindingFilter `yaml:"filter,omitempty" json:"filter,omitempty"`
}
VariableBinding defines how a variable binds to system resources. This enables automatic population from system resources and type-safe UI selection.
type VariableBindingFilter ¶
type VariableBindingFilter struct {
// Capability filters resources by capability (e.g., "chat", "embeddings").
Capability string `yaml:"capability,omitempty" json:"capability,omitempty"`
// Labels filters resources by label selectors.
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
}
VariableBindingFilter specifies criteria for filtering bound resources.
type VariableBindingKind ¶
type VariableBindingKind string
VariableBindingKind defines the type of resource a variable binds to.
const ( // BindingKindProject binds to project metadata (name, description, tags). BindingKindProject VariableBindingKind = "project" // BindingKindProvider binds to provider/model selection. BindingKindProvider VariableBindingKind = "provider" // BindingKindWorkspace binds to current workspace (name, namespace). BindingKindWorkspace VariableBindingKind = "workspace" // BindingKindSecret binds to Kubernetes Secret resources. BindingKindSecret VariableBindingKind = "secret" // BindingKindConfigMap binds to Kubernetes ConfigMap resources. BindingKindConfigMap VariableBindingKind = "configmap" )
type VariableMetadata ¶
type VariableMetadata struct {
Name string `yaml:"name" json:"name"`
// Type is one of "string", "number", "boolean", "object", "array".
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Required bool `yaml:"required" json:"required"`
Default interface{} `yaml:"default,omitempty" json:"default,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Example interface{} `yaml:"example,omitempty" json:"example,omitempty"`
Validation map[string]interface{} `yaml:"validation,omitempty" json:"validation,omitempty"`
// Binding enables automatic population from system resources and type-safe UI selection.
// This allows prompts to declare semantic meaning for variables beyond just their data type.
Binding *VariableBinding `yaml:"binding,omitempty" json:"binding,omitempty"`
}
VariableMetadata contains enhanced metadata for a variable VariableMetadata defines a template variable with validation rules This struct matches the SDK Variable type for PromptPack spec compliance
func VariableToMetadata ¶
func VariableToMetadata(v Variable) VariableMetadata
VariableToMetadata converts a compiled variable back to the authoring metadata form. Binding is always nil — it is not carried in the pack.
A free function rather than a method: Variable is the generated type now, and a type alias cannot carry methods.
type VariableValidation ¶
type VariableValidation = packspec.VariableValidation
VariableValidation is the validation rule set on a Variable.
type VideoConfig ¶
type VideoConfig = packspec.VideoConfig
VideoConfig contains video-specific configuration Generated from the schema: an ALIAS for packspec.VideoConfig. Optional numeric and boolean fields are pointers: zero is a real setting.
func GetVideoConfig ¶
func GetVideoConfig(config *MediaConfig) *VideoConfig
GetVideoConfig returns the video configuration if video is supported
type WorkflowConfig ¶
WorkflowConfig is an alias for workflow.Spec for backward compatibility.
type WorkflowState ¶
WorkflowState is an alias for workflow.State for backward compatibility.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agentcard generates A2A Agent Cards from a compiled Pack's agents section.
|
Package agentcard generates A2A Agent Cards from a compiled Pack's agents section. |
|
Package schema provides embedded PromptPack schema for offline validation.
|
Package schema provides embedded PromptPack schema for offline validation. |