harnessconfig

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const MaxHarnessConfigBytes = 16 * 1024

Variables

View Source
var ErrHarnessConfig = errors.New("invalid or unsupported harness_config")

ErrHarnessConfig deliberately excludes caller-controlled keys and values.

View Source
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.

View Source
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

func ValidateModel(value any) (string, error)

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(model string, options map[string]any) (PreparedConfiguration, error)

Prepare validates the current model/provider/native-parameter contract before creating native resources. An empty model is absent, which only the native-owned connection path without a provider may use. 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) Provider

func (c Configuration) Provider(protocol string) (Provider, bool)

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
	// Native is the pinned native package the Harness runs. Every projection of
	// its name and version is generated from, or checked against, this value.
	Native NativePackage
	// 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
	// SessionUpdates declares which settings a Session update changes natively
	// between root Turns. A change to an unsupported setting is a typed error.
	SessionUpdates SessionUpdates
	// 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
	// MaxInstructionsBytes is the native limit on an Agent's instructions in
	// bytes; zero declares none. Admission rejects longer instructions.
	MaxInstructionsBytes int
	// 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

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.

func (Declaration) ValidateSessionUpdate added in v0.0.14

func (d Declaration) ValidateSessionUpdate(before, after proto.TurnSettings) error

ValidateSessionUpdate rejects a change of model, effort, tier or review that the Harness does not declare it applies natively between root Turns. Unchanged settings pass.

func (Declaration) ValidateTurnSettings added in v0.0.14

func (d Declaration) ValidateTurnSettings(turn proto.TurnSettings) error

ValidateTurnSettings rejects an effort, tier or review the Harness does not declare. Core admission and the Runtime call it with the same settings.

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
	// Reviews are the supported review values other than none: auto_review.
	Reviews []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

type NativePackage added in v0.0.13

type NativePackage struct{ Component, Version string }

NativePackage names the native Harness package and its single supported version. Component is the name of its native installer component.

type PreparedConfiguration

type PreparedConfiguration struct {
	HarnessConfig proto.HarnessConfig
}

PreparedConfiguration owns a validated snapshot without native side effects. 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

func (r Registry) IsZero() bool

IsZero reports a Registry that was never built by NewRegistry.

func (Registry) Kinds added in v0.0.12

func (r Registry) Kinds() []string

Kinds returns a stable snapshot of the declared Harness identifiers.

func (Registry) Lookup

func (r Registry) Lookup(kind string) (Declaration, bool)

func (Registry) SupportsProtocol

func (r Registry) SupportsProtocol(protocol string) bool

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

func (r Registry) ValidateProtocol(kind, protocol string) error

type SessionUpdates added in v0.0.14

type SessionUpdates struct {
	Model, ReasoningEffort, ReasoningEffortReset, ServiceTier proto.CapabilitySupport
}

SessionUpdates declares which settings the adapter changes natively between root Turns. Every field is Supported or Unsupported.

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.

Jump to

Keyboard shortcuts

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