pack

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 9 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 AgentDef added in v1.3.1

type AgentDef struct {
	Description string   `json:"description,omitempty"`
	Tags        []string `json:"tags,omitempty"`
	InputModes  []string `json:"input_modes,omitempty"`
	OutputModes []string `json:"output_modes,omitempty"`
}

AgentDef provides A2A Agent Card metadata for a single prompt.

type AgentsConfig added in v1.3.1

type AgentsConfig struct {
	Entry   string               `json:"entry"`
	Members map[string]*AgentDef `json:"members"`
}

AgentsConfig maps prompts to A2A-compatible agent definitions.

type AgentsValidationError added in v1.3.1

type AgentsValidationError struct {
	Errors []string
}

AgentsValidationError represents an agents section validation error with details.

func (*AgentsValidationError) Error added in v1.3.1

func (e *AgentsValidationError) Error() string

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

	// Workflow - State-machine workflow config
	Workflow *WorkflowSpec `json:"workflow,omitempty"`

	// Agents - Agent configuration mapping prompts to A2A-compatible agent definitions
	Agents *AgentsConfig `json:"agents,omitempty"`

	// Skills - Skill sources for dynamic capability loading
	Skills []SkillSourceConfig `json:"skills,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.

func (*Pack) ValidateAgents added in v1.3.1

func (p *Pack) ValidateAgents() error

ValidateAgents validates the agents section of a pack. Returns nil if agents is nil (the section is optional) or if validation passes.

func (*Pack) ValidateWorkflow added in v1.3.1

func (p *Pack) ValidateWorkflow() error

ValidateWorkflow validates the workflow section of a pack. Returns nil if workflow is nil (the section is optional) or if validation passes. Warnings are returned inside the error value when errors are also present.

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 SkillSourceConfig added in v1.3.1

type SkillSourceConfig struct {
	Dir          string `json:"dir,omitempty"`
	Path         string `json:"path,omitempty"` // schema alias for dir
	Name         string `json:"name,omitempty"`
	Description  string `json:"description,omitempty"`
	Instructions string `json:"instructions,omitempty"`
	Preload      bool   `json:"preload,omitempty"`
}

SkillSourceConfig represents a skill source in the pack.

func (*SkillSourceConfig) EffectiveDir added in v1.3.1

func (s *SkillSourceConfig) EffectiveDir() string

EffectiveDir returns the directory path, preferring Dir over Path.

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

type WorkflowSpec added in v1.3.1

type WorkflowSpec struct {
	Version int                       `json:"version"`
	Entry   string                    `json:"entry"`
	States  map[string]*WorkflowState `json:"states"`
	Engine  map[string]any            `json:"engine,omitempty"`
}

WorkflowSpec is the SDK's mirror of runtime/workflow.WorkflowSpec. It is kept as a separate type to avoid coupling the SDK's internal package graph to runtime/workflow, following the same pattern as other Pack fields.

type WorkflowState added in v1.3.1

type WorkflowState struct {
	PromptTask    string            `json:"prompt_task"`
	Description   string            `json:"description,omitempty"`
	OnEvent       map[string]string `json:"on_event,omitempty"`
	Persistence   string            `json:"persistence,omitempty"`
	Orchestration string            `json:"orchestration,omitempty"`
	Skills        string            `json:"skills,omitempty"`
}

WorkflowState is the SDK's mirror of runtime/workflow.WorkflowState.

type WorkflowValidationError added in v1.3.1

type WorkflowValidationError struct {
	Errors   []string
	Warnings []string
}

WorkflowValidationError represents a workflow section validation error with details.

func (*WorkflowValidationError) Error added in v1.3.1

func (e *WorkflowValidationError) Error() string

Jump to

Keyboard shortcuts

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