pack

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package pack provides internal pack loading functionality.

Package pack provides internal pack loading functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateAgainstSchema

func ValidateAgainstSchema(data []byte) error

ValidateAgainstSchema validates pack JSON data against the PromptPack schema. It uses the $schema URL from the pack if present, otherwise uses the embedded schema. The PROMPTKIT_SCHEMA_SOURCE environment variable can override this behavior:

  • "local": Always use embedded schema (default, for offline support)
  • "remote": Always fetch from URL
  • file path: Load schema from local file

Returns nil if validation passes, or a SchemaValidationError with details.

Types

type LoadOptions

type LoadOptions struct {
	// SkipSchemaValidation disables JSON schema validation during load.
	// Default is false (validation enabled).
	SkipSchemaValidation bool
}

LoadOptions configures pack loading behavior.

type MediaConfig

type MediaConfig struct {
	AllowedTypes []string `json:"allowed_types,omitempty"`
	MaxSize      int      `json:"max_size,omitempty"`
}

MediaConfig represents media/multimodal configuration.

type Pack

type Pack struct {
	// Identity
	ID          string `json:"id"`
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description"`

	// Prompts - Map of prompt name -> Prompt
	Prompts map[string]*Prompt `json:"prompts"`

	// Tools - Map of tool name -> Tool
	Tools map[string]*Tool `json:"tools,omitempty"`

	// Fragments - Map of fragment name -> content
	Fragments map[string]string `json:"fragments,omitempty"`

	// Evals - Pack-level eval definitions (applied to all prompts unless overridden)
	Evals []evals.EvalDef `json:"evals,omitempty"`

	// FilePath is the path from which this pack was loaded.
	FilePath string `json:"-"`
}

Pack represents a loaded prompt pack. This is the SDK's view of a pack, optimized for runtime use.

func Load

func Load(path string, opts ...LoadOptions) (*Pack, error)

Load loads a pack from a JSON file. By default, the pack is validated against the PromptPack JSON schema. Use LoadOptions to customize behavior.

func Parse

func Parse(data []byte) (*Pack, error)

Parse parses pack JSON data.

func (*Pack) GetPrompt

func (p *Pack) GetPrompt(name string) *Prompt

GetPrompt returns a prompt by name, or nil if not found.

func (*Pack) GetTool

func (p *Pack) GetTool(name string) *Tool

GetTool returns a tool by name, or nil if not found.

func (*Pack) ListPrompts

func (p *Pack) ListPrompts() []string

ListPrompts returns all prompt names in the pack.

func (*Pack) ListTools

func (p *Pack) ListTools() []string

ListTools returns all tool names in the pack.

func (*Pack) ToPromptRegistry

func (p *Pack) ToPromptRegistry() *prompt.Registry

ToPromptRegistry creates a prompt.Registry from the pack. This allows the SDK to use the same PromptAssemblyMiddleware as Arena.

func (*Pack) ToToolRepository

func (p *Pack) ToToolRepository() *memory.ToolRepository

ToToolRepository creates a memory.ToolRepository from the pack. This allows the SDK to use the same tools.Registry as Arena.

type Parameters

type Parameters struct {
	Temperature *float64 `json:"temperature,omitempty"`
	MaxTokens   *int     `json:"max_tokens,omitempty"`
	TopP        *float64 `json:"top_p,omitempty"`
	TopK        *int     `json:"top_k,omitempty"`
}

Parameters represents model parameters.

type Prompt

type Prompt struct {
	ID             string          `json:"id"`
	Name           string          `json:"name"`
	Description    string          `json:"description"`
	Version        string          `json:"version"`
	SystemTemplate string          `json:"system_template"`
	Variables      []Variable      `json:"variables,omitempty"`
	Tools          []string        `json:"tools,omitempty"`
	ToolPolicy     *ToolPolicy     `json:"tool_policy,omitempty"`
	MediaConfig    *MediaConfig    `json:"media,omitempty"`
	Parameters     *Parameters     `json:"parameters,omitempty"`
	Validators     []Validator     `json:"validators,omitempty"`
	Evals          []evals.EvalDef `json:"evals,omitempty"`
	ModelOverrides map[string]any  `json:"model_overrides,omitempty"`
}

Prompt represents a prompt definition within a pack.

func (*Prompt) ToPromptConfig

func (pr *Prompt) ToPromptConfig(taskType string) *prompt.Config

ToPromptConfig converts a pack Prompt to a prompt.Config.

type SchemaValidationError

type SchemaValidationError struct {
	Errors []string
}

SchemaValidationError represents a schema validation error with details.

func (*SchemaValidationError) Error

func (e *SchemaValidationError) Error() string

type Tool

type Tool struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Parameters  any    `json:"parameters"`
}

Tool represents a tool definition.

type ToolPolicy

type ToolPolicy struct {
	ToolChoice          string   `json:"tool_choice,omitempty"`
	MaxRounds           int      `json:"max_rounds,omitempty"`
	MaxToolCallsPerTurn int      `json:"max_tool_calls_per_turn,omitempty"`
	Blocklist           []string `json:"blocklist,omitempty"`
}

ToolPolicy represents tool usage policy.

type Validator

type Validator struct {
	Type   string         `json:"type"`
	Config map[string]any `json:"config,omitempty"`
}

Validator represents a validator configuration.

type Variable

type Variable struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
	Default     string `json:"default,omitempty"`
	// Binding enables automatic population from system resources and type-safe UI selection.
	Binding *VariableBinding `json:"binding,omitempty"`
}

Variable represents a template variable.

type VariableBinding added in v1.1.10

type VariableBinding struct {
	// Kind specifies the type of resource to bind to.
	Kind VariableBindingKind `json:"kind"`
	// Field specifies which field of the resource to bind (e.g., "name", "model").
	Field string `json:"field,omitempty"`
	// AutoPopulate enables automatic population of this variable from the bound resource.
	AutoPopulate bool `json:"autoPopulate,omitempty"`
	// Filter specifies criteria for filtering bound resources.
	Filter *VariableBindingFilter `json:"filter,omitempty"`
}

VariableBinding defines how a variable binds to system resources.

type VariableBindingFilter added in v1.1.10

type VariableBindingFilter struct {
	// Capability filters resources by capability (e.g., "chat", "embeddings").
	Capability string `json:"capability,omitempty"`
	// Labels filters resources by label selectors.
	Labels map[string]string `json:"labels,omitempty"`
}

VariableBindingFilter specifies criteria for filtering bound resources.

type VariableBindingKind added in v1.1.10

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"
)

Jump to

Keyboard shortcuts

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