adapter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package adapter contains explicit, versioned harness capability profiles. It never infers write or execution capabilities from a JSON schema shape.

Index

Constants

View Source
const (
	HumanShimID      = "human-shim"
	HumanShimVersion = "1"
)
View Source
const (
	OpenCodeID      = "opencode"
	OpenCodeVersion = "1.17.18"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EditSemantics

type EditSemantics string
const (
	EditExact EditSemantics = "exact"
	EditFuzzy EditSemantics = "fuzzy"
	EditLine  EditSemantics = "line"
)

type EditTool

type EditTool struct {
	Tool
	Semantics EditSemantics `json:"semantics"`
	OldField  string        `json:"old_field"`
	NewField  string        `json:"new_field"`
}

type ExecTool

type ExecTool struct {
	Tool
	CWDField     string `json:"cwd_field,omitempty"`
	TimeoutField string `json:"timeout_field,omitempty"`
	Approval     string `json:"approval,omitempty"`
}

type PathStyle

type PathStyle string

PathStyle describes how a harness addresses files. Mirror code uses this declaration instead of guessing from a field name or JSON schema.

const (
	PathWorkspaceVirtual PathStyle = "workspace_virtual"
	PathAbsolute         PathStyle = "absolute"
)

type Profile

type Profile struct {
	HarnessID      string                       `json:"harness_id"`
	HarnessVersion string                       `json:"harness_version"`
	PathStyle      PathStyle                    `json:"path_style,omitempty"`
	ResultCodec    ResultCodec                  `json:"result_codec,omitempty"`
	Read           *Tool                        `json:"read,omitempty"`
	Search         *Tool                        `json:"search,omitempty"`
	Write          *Tool                        `json:"write,omitempty"`
	Edit           *EditTool                    `json:"edit,omitempty"`
	Delete         *Tool                        `json:"delete,omitempty"`
	Rename         *Tool                        `json:"rename,omitempty"`
	Exec           *ExecTool                    `json:"exec,omitempty"`
	NativeTools    map[string]ToolAuthorization `json:"native_tools,omitempty"`
	ParallelCalls  bool                         `json:"parallel_calls"`
	ErrorShape     string                       `json:"error_shape"`
}

func HumanShimProfile

func HumanShimProfile() Profile

func OpenCode11718Profile

func OpenCode11718Profile() Profile

OpenCode11718Profile describes only the native tools observed from OpenCode 1.17.18. Keep the version in the constructor name so a future schema change is introduced as a separate profile instead of silently widening this one.

func (Profile) AllowsTool

func (profile Profile) AllowsTool(name string) bool

AllowsTool reports whether name is explicitly mapped by this exact harness profile. It deliberately performs no schema-shape inference.

func (Profile) AuthorizeTool

func (profile Profile) AuthorizeTool(name string) (ToolAuthorization, bool)

AuthorizeTool reports the reviewed authorization class for name. Exact filesystem mappings are standard workspace capabilities, while the mapped command tool is privileged. A false result is intentionally not equivalent to safe: unclassified native/custom/MCP tools require explicit privileged authorization at the gateway, where caller declaration is checked separately.

func (Profile) IsExecTool

func (profile Profile) IsExecTool(name string) bool

func (Profile) Key

func (profile Profile) Key() string

func (Profile) Validate

func (profile Profile) Validate() error

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewDefaultRegistry

func NewDefaultRegistry() *Registry

NewDefaultRegistry returns the exact, versioned adapters shipped with the daemon. Real harness adapters are registered only after their tool contracts have been captured and reviewed.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Register

func (registry *Registry) Register(profile Profile) error

func (*Registry) Resolve

func (registry *Registry) Resolve(harnessID, harnessVersion string) (Profile, bool)

type ResultCodec

type ResultCodec string

ResultCodec names an exact, versioned tool-result contract. A profile may omit it when it is not eligible for workspace reconciliation.

const (
	ResultHumanShimV1   ResultCodec = "human_shim_v1"
	ResultOpenCode11718 ResultCodec = "opencode_1_17_18"
)

type Tool

type Tool struct {
	Name string            `json:"name"`
	Args map[string]string `json:"args,omitempty"`
}

type ToolAuthorization

type ToolAuthorization string

ToolAuthorization classifies caller-native tools that do not need a workspace semantic mapping. Standard tools are known not to grant command, network, sub-agent, or otherwise open-ended authority. Privileged tools (and tools an exact profile does not classify) require the task's explicit active capability opt-in before Human may return them.

This is deliberately separate from Tool mappings: a native tool such as todowrite can be safe to return without being usable for mirror reconciliation, while task/webfetch must not inherit authority merely from appearing in the caller's schema.

const (
	ToolAuthorizationStandard   ToolAuthorization = "standard"
	ToolAuthorizationPrivileged ToolAuthorization = "privileged"
)

Jump to

Keyboard shortcuts

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