control

package
v0.148.5 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package control defines the transport-independent contract for Wingthing runtime operations. Adapters decide how to authenticate and transport a call; the operation name, schema, grant, annotations, and audit policy live here.

Index

Constants

View Source
const (
	SurfaceLocalMCP Surface = "local-mcp"
	SurfaceHTTPMCP  Surface = "http-mcp"
	// SurfaceDirectMCP is the native multi-wing adapter. Portal operations are
	// local to the coordinator, while every wing-owned operation carries an
	// explicit wing_id used to select a peer-to-peer transport.
	SurfaceDirectMCP Surface = "direct-mcp"
	ContractVersion  string  = "v1"
)
View Source
const DirectChannelPrefix = "control:v1:"

Variables

This section is empty.

Functions

func AuditTarget

func AuditTarget(name string, arguments json.RawMessage, result map[string]any) string

AuditTarget extracts the first bounded resource label approved by the operation definition. Full arguments remain digest-only.

func ObjectKinds

func ObjectKinds(surface Surface) []string

ObjectKinds returns the semantic resource kinds visible through one surface. The order is stable for capability responses.

func OperationNames

func OperationNames(surface Surface) []string

OperationNames returns the stable operation names exposed by one surface.

func QualifyResult

func QualifyResult(wingID string, result map[string]any) map[string]any

QualifyResult makes the owning wing part of the result envelope so clients never need mutable "current wing" state to interpret an object ID. Resource objects returned by current list/send operations are qualified individually as well, so retaining one object outside its response cannot lose its wing.

func SplitWingTarget

func SplitWingTarget(arguments json.RawMessage) (string, json.RawMessage, error)

SplitWingTarget validates and removes the transport-only wing_id argument. The selected wing receives only the operation's original contract.

Types

type AuditArgumentMode

type AuditArgumentMode string

AuditArgumentMode describes how an adapter may record tool arguments.

const (
	// AuditArgumentsDigest permits only a digest of the complete argument
	// envelope. Adapters may separately record the bounded target selected by
	// AuditTargetKeys.
	AuditArgumentsDigest AuditArgumentMode = "digest"
)

type Authority

type Authority string

Authority identifies the component that owns an operation's state and handler. Portal operations use gateway inventory; wing operations use the selected execution runtime.

const (
	AuthorityWing   Authority = "wing"
	AuthorityPortal Authority = "portal"
)

type DirectRequest

type DirectRequest struct {
	Version   string          `json:"version"`
	ID        string          `json:"id"`
	Tool      string          `json:"tool"`
	Arguments json.RawMessage `json:"arguments"`
}

DirectRequest is one authenticated operation sent over a WebRTC control data channel. User identity is deliberately absent: the wing obtains it from the coordinator-authenticated signaling exchange.

type DirectResponse

type DirectResponse struct {
	Version string         `json:"version"`
	ID      string         `json:"id"`
	Result  map[string]any `json:"result,omitempty"`
	IsError bool           `json:"is_error,omitempty"`
	Error   string         `json:"error,omitempty"`
}

DirectResponse is the bounded result envelope returned by a wing.

type Surface

type Surface string

Surface identifies one adapter that can expose an operation.

type Tool

type Tool struct {
	Name        string         `json:"name"`
	Title       string         `json:"title,omitempty"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"inputSchema"`
	Annotations map[string]any `json:"annotations,omitempty"`

	Version         string            `json:"-"`
	Grant           string            `json:"-"`
	Surfaces        []Surface         `json:"-"`
	Authority       Authority         `json:"-"`
	AuditArguments  AuditArgumentMode `json:"-"`
	AuditTargetKeys []string          `json:"-"`
}

Tool is one versioned Wingthing control operation. MCP adapters serialize the public fields directly. The remaining fields govern authorization, transport exposure, and audit redaction.

func Lookup

func Lookup(name string) (Tool, bool)

Lookup returns one operation definition by stable name.

func Tools

func Tools(surface Surface) []Tool

Tools returns the ordered operation set exposed by one adapter surface.

func ToolsForAuthority

func ToolsForAuthority(surface Surface, authority Authority) []Tool

ToolsForAuthority returns the operations implemented by one authority and exposed through the requested surface.

func (Tool) Supports

func (t Tool) Supports(surface Surface) bool

Supports reports whether an operation is exposed by the adapter surface.

Jump to

Keyboard shortcuts

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