Documentation
¶
Overview ¶
Package harnessconfig defines the shared Harness declaration. This file is the authoring entry point for a Harness: one Declaration states its kind, display name, model providers, native parameter validation, capabilities, placements and the public admission rules it adds. Core admission, support descriptions and every Runtime execution/preparation entry consume that same value, so nothing about a Harness is declared a second time elsewhere. Adapter-specific validation and native rendering remain private implementations. Execution lifecycle is a separate contract.
The current HarnessConfig wire object is defined by proto.HarnessConfig. Omission and {} mean no native parameters. Explicit null, arrays, repeated object members and objects above MaxHarnessConfigBytes are rejected by the shared decoder in native.go. Errors must omit submitted keys and values. Native schemas must reject unknown fields and any setting that overrides model, provider/authentication, workspace, tools/MCP, permissions or lifecycle controls. Never merge arbitrary host configuration into the frozen model configuration.
Acceptance obligates the adapter to apply every accepted parameter accurately through native configuration, SDK options or native Turn settings. Validate and prepare before native resources or model input; never ignore preparation errors, silently drop parameters or retry with weaker settings. Native resource cleanup and uncertain ownership follow the separate execution lifecycle contract.
Core freezes the model configuration per Session. Its meaning and explicit settings must hold for the first Turn, later Turns, native retries, tool continuations and recovery. A Runtime that cannot preserve a frozen snapshot rejects it without rewriting, migration or aliases. Native connection setup is direct: no model API proxy, passthrough gateway or protocol conversion, including inside an adapter. Protocol acceptance does not declare model capabilities; operation and input requirements must still be checked before native submission.
Index ¶
- Constants
- Variables
- func RequireObjectSchemas(functions []proto.FunctionTool) error
- func ValidateModel(value any) (string, error)
- type Admission
- type Configuration
- func (c Configuration) AcceptsHarnessConfig() bool
- func (c Configuration) Clone() Configuration
- func (c Configuration) ParseHarnessConfig(raw json.RawMessage) (proto.HarnessConfig, error)
- func (c Configuration) ParseProvider(raw any) (modelprovider.Provider, error)
- func (c Configuration) Prepare(options map[string]any) (PreparedConfiguration, error)
- func (c Configuration) PrepareHarnessConfig(options map[string]any) (proto.HarnessConfig, error)
- func (c Configuration) Provider(protocol string) (Provider, bool)
- func (c Configuration) ValidateDeclaration() error
- func (c Configuration) ValidateMaxOutputTokens(value int32) error
- func (c Configuration) ValidateProtocol(protocol string) error
- type Declaration
- func (d Declaration) Accepts(placement string) bool
- func (d Declaration) Clone() Declaration
- func (d Declaration) Info() proto.SupportedAgentKind
- func (d Declaration) ValidateDeclaration() error
- func (d Declaration) ValidateExecutionControls(controls *proto.ExecutionControls) error
- func (d Declaration) ValidateMCPOrigins(placement string, servers []proto.MCPHTTPServer) error
- type ExecutionOptions
- type PreparedConfiguration
- type Provider
- type Registry
- func (r Registry) IsZero() bool
- func (r Registry) Kinds() []string
- func (r Registry) Lookup(kind string) (Declaration, bool)
- func (r Registry) SupportsProtocol(protocol string) bool
- func (r Registry) ValidateHarnessConfig(kind string, raw json.RawMessage) error
- func (r Registry) ValidateProtocol(kind, protocol string) error
Constants ¶
const MaxHarnessConfigBytes = 16 * 1024
Variables ¶
var ErrHarnessConfig = errors.New("invalid or unsupported harness_config")
ErrHarnessConfig deliberately excludes caller-controlled keys and values.
var ErrInvalidInput = errors.New("invalid harness configuration")
ErrInvalidInput marks a configuration a Harness declaration rejects. Core reports it as an invalid request, without echoing submitted values.
var ErrModel = errors.New("model must be a nonempty model identifier")
Functions ¶
func RequireObjectSchemas ¶ added in v0.0.12
func RequireObjectSchemas(functions []proto.FunctionTool) error
RequireObjectSchemas rejects a function whose parameter schema has no root type object.
func ValidateModel ¶
ValidateModel is shared by public admission and Runtime preparation.
Types ¶
type Admission ¶ added in v0.0.12
type Admission struct {
TextFormat string
TextSchema json.RawMessage
MultiAgent bool
Tools []json.RawMessage
// WorkspaceDirectory is the Environment's workspace, empty without one.
WorkspaceDirectory string
}
Admission is the saved Agent and Environment a Harness declaration validates. Core projects its public types into it, so declarations stay independent of the public API package.
type Configuration ¶
type Configuration struct {
Providers []Provider
// MaxOutputTokens reports that the adapter maps a provider's
// max_output_tokens to a native setting. Every adapter maps context_window.
MaxOutputTokens bool
// ValidateNativeConfig belongs to the selected adapter, never Core.
ValidateNativeConfig func(proto.HarnessConfig) bool
}
Configuration is an adapter-owned declaration, not live provider readiness. Providers is ordered; its first entry is the default. An explicit empty declaration accepts no provider or nonempty native parameters. It is useful only for direct adapters whose model connection remains native-owned.
func (Configuration) AcceptsHarnessConfig ¶
func (c Configuration) AcceptsHarnessConfig() bool
func (Configuration) Clone ¶
func (c Configuration) Clone() Configuration
func (Configuration) ParseHarnessConfig ¶
func (c Configuration) ParseHarnessConfig(raw json.RawMessage) (proto.HarnessConfig, error)
func (Configuration) ParseProvider ¶
func (c Configuration) ParseProvider(raw any) (modelprovider.Provider, error)
ParseProvider validates the frozen bundle against this adapter's native declaration before launching a Harness. Unsupported snapshots are not rewritten.
func (Configuration) Prepare ¶
func (c Configuration) Prepare(options map[string]any) (PreparedConfiguration, error)
Prepare validates the current model/provider/native-parameter contract before creating native resources. Other options belong to the execution contract.
func (Configuration) PrepareHarnessConfig ¶
func (c Configuration) PrepareHarnessConfig(options map[string]any) (proto.HarnessConfig, error)
PrepareHarnessConfig copies the wire object before passing it to native code. An absent option means {}, while an explicitly supplied null is invalid.
func (Configuration) ValidateDeclaration ¶
func (c Configuration) ValidateDeclaration() error
ValidateDeclaration rejects ambiguous support before registration. A caller must pass the declaration explicitly; there is no inferred built-in fallback.
func (Configuration) ValidateMaxOutputTokens ¶ added in v0.0.12
func (c Configuration) ValidateMaxOutputTokens(value int32) error
ValidateMaxOutputTokens rejects a set limit the Harness has no native home for.
func (Configuration) ValidateProtocol ¶
func (c Configuration) ValidateProtocol(protocol string) error
type Declaration ¶ added in v0.0.12
type Declaration struct {
// Kind is the public identifier; Label is its display name.
Kind, Label string
// Configuration declares model providers and native parameter validation.
Configuration
// Capabilities is the maximum the adapter supports on a capable host and the
// operations Core may rely on once a connected Runtime advertises them.
Capabilities proto.AgentKindCapabilities
// Placements lists the Environment types the Harness executes in.
Placements []string
// MCPOrigins lists where HTTP MCP connections originate: "service" for the
// service-side environment:none profile, "environment" for the Environment.
MCPOrigins []string
// Execution declares which official execution option values the Harness
// maps to a native setting. Admission rejects any other user-set value.
Execution ExecutionOptions
// WhitespaceOnlyText declares messages without an image or non-whitespace
// text. Unsupported Harnesses reject them at admission; Core never trims or
// pads model input to fit a Harness.
WhitespaceOnlyText proto.CapabilitySupport
// ValidateConfiguration adds pure restrictions on a saved Agent and
// Environment.
ValidateConfiguration func(Admission) error
// ValidateTools adds restrictions on resolved function and MCP tools.
ValidateTools func([]proto.FunctionTool, []proto.MCPHTTPServer) error
// ValidateMessageInput adds restrictions on messages that carry images.
ValidateMessageInput func(proto.MessageInput) error
// ValidateFunctionResult adds restrictions on submitted function results.
ValidateFunctionResult func(proto.FunctionResultPayload) error
}
Declaration is everything a Harness states about itself, authored once in internal/harnessconfig/<package>/declaration.go. The Runtime adapter binds it to native execution, and Core admission validates every Session against it: Core keeps no parallel per-Harness description.
Every capability is Supported or Unsupported; the zero value is invalid. Runtime discovery may narrow Capabilities for the installed host (a missing binary, an unsupported platform) and never widens them. A nil validator means only the common validation applies.
func (Declaration) Accepts ¶ added in v0.0.12
func (d Declaration) Accepts(placement string) bool
Accepts reports whether the Harness executes in the Environment type.
func (Declaration) Clone ¶ added in v0.0.12
func (d Declaration) Clone() Declaration
func (Declaration) Info ¶ added in v0.0.12
func (d Declaration) Info() proto.SupportedAgentKind
Info is the Runtime descriptor before discovery has checked the host.
func (Declaration) ValidateDeclaration ¶ added in v0.0.12
func (d Declaration) ValidateDeclaration() error
ValidateDeclaration rejects ambiguous support before registration. Nothing is inferred: every capability, placement and origin is stated.
func (Declaration) ValidateExecutionControls ¶ added in v0.0.12
func (d Declaration) ValidateExecutionControls(controls *proto.ExecutionControls) error
ValidateExecutionControls rejects a user-set or default value the Harness does not declare. Core admission and the Runtime call it with the same controls, so neither keeps a second list. Messages name the field and never echo configuration other than the rejected value.
func (Declaration) ValidateMCPOrigins ¶ added in v0.0.12
func (d Declaration) ValidateMCPOrigins(placement string, servers []proto.MCPHTTPServer) error
ValidateMCPOrigins preserves outbound authority independently of Harness names. Workspace connections never stand in for service-network connections.
type ExecutionOptions ¶ added in v0.0.12
type ExecutionOptions struct {
// WebSearchModes are the supported web_search modes: disabled, cached, live.
WebSearchModes []string
// WebSearchSettings reports native homes for context_size, allowed_domains
// and location.
WebSearchSettings bool
// ReasoningEfforts and ReasoningSummaries are the supported reasoning values.
ReasoningEfforts, ReasoningSummaries []string
// ServiceTiers are the supported tiers other than auto.
ServiceTiers []string
// ProgrammaticToolCalling lists the supported enabled values.
ProgrammaticToolCalling []bool
// TextVerbosities are the supported text verbosity levels.
TextVerbosities []string
}
ExecutionOptions lists the official execution option values a Harness maps to a native setting. An empty set declares the option unsupported. Absent options need no declaration: they follow the Harness's native default. Auto service tier means unset, so it is always accepted.
func (ExecutionOptions) Clone ¶ added in v0.0.12
func (o ExecutionOptions) Clone() ExecutionOptions
type PreparedConfiguration ¶
type PreparedConfiguration struct {
Model string
Provider *modelprovider.Provider
HarnessConfig proto.HarnessConfig
}
PreparedConfiguration owns a validated snapshot without native side effects. Model and Provider may be absent only for the existing native-owned connection path. A supplied model must be a nonempty string; an explicit provider requires an explicit model. HarnessConfig is always an independently owned object.
type Provider ¶
type Provider struct {
Protocol string
}
Provider is deliberately limited to configuration compatibility. Core owns credential admission and endpoint security; native launch options stay private.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is an immutable snapshot. Missing declarations remain unknown rather than inheriting another harness's rules.
func NewRegistry ¶
func NewRegistry(declarations ...Declaration) Registry
NewRegistry panics on an invalid or duplicate declaration. Static registrations are programmer errors, never runtime input.
func (Registry) IsZero ¶ added in v0.0.12
IsZero reports a Registry that was never built by NewRegistry.
func (Registry) Kinds ¶ added in v0.0.12
Kinds returns a stable snapshot of the declared Harness identifiers.
func (Registry) SupportsProtocol ¶
func (Registry) ValidateHarnessConfig ¶
func (r Registry) ValidateHarnessConfig(kind string, raw json.RawMessage) error
ValidateHarnessConfig validates a selected adapter. An empty kind is for saved Agents without a selected Harness: at least one registered adapter must accept the object. Session admission always validates its resolved kind again.
func (Registry) ValidateProtocol ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package builtin is the set of Harnesses in this build.
|
Package builtin is the set of Harnesses in this build. |
|
Package claudesdk declares the Claude Code Harness.
|
Package claudesdk declares the Claude Code Harness. |
|
Package codex declares the Codex Harness.
|
Package codex declares the Codex Harness. |
|
Package harnesstest supplies explicit Harness declarations for admission fixtures.
|
Package harnesstest supplies explicit Harness declarations for admission fixtures. |
|
Package mcode declares the MiniMax Code Harness.
|
Package mcode declares the MiniMax Code Harness. |