adapter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 12 Imported by: ? 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 adapter defines narrow host integration contracts for MCP servers and external agent harnesses. It contains no transport implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentHarness

AgentHarness normalizes lifecycle, cancellation, events, and terminal outcome for one explicitly supported external agent runtime.

type AuthMode

type AuthMode string
const (
	AuthNone  AuthMode = "none"
	AuthToken AuthMode = "token"
	AuthOAuth AuthMode = "oauth"
)

type HarnessCapabilities

type HarnessCapabilities struct {
	ResumeToken       bool `json:"resume_token"`
	TranscriptReplay  bool `json:"transcript_replay"`
	ExactCheckpoint   bool `json:"exact_checkpoint"`
	EventReplay       bool `json:"event_replay"`
	WorkspaceSnapshot bool `json:"workspace_snapshot"`
	IdempotentResume  bool `json:"idempotent_resume"`
}

HarnessCapabilities are host-observed properties of a configured harness. A manifest pins these values so a resumed request cannot silently negotiate weaker recovery semantics.

func (HarnessCapabilities) Supports

func (c HarnessCapabilities) Supports(mode ResumeMode) bool

type HarnessCapabilityReporter

type HarnessCapabilityReporter interface {
	Capabilities(context.Context) (HarnessCapabilities, error)
}

HarnessCapabilityReporter lets an adapter expose configured recovery guarantees without expanding the execution interface for legacy harnesses.

type HarnessConfig

type HarnessConfig struct {
	Name       string            `json:"name"`
	Executable string            `json:"executable"`
	Arguments  []string          `json:"arguments,omitempty"`
	AllowEnv   []string          `json:"allow_env,omitempty"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

type HarnessManifest

type HarnessManifest struct {
	Name         string              `json:"name"`
	Version      string              `json:"version"`
	ConfigDigest string              `json:"config_digest"`
	Health       Health              `json:"health"`
	Capabilities HarnessCapabilities `json:"capabilities"`
}

type HarnessRegistry

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

HarnessRegistry activates only explicitly named and host-allowlisted CLI adapters. Discovery never turns an arbitrary executable into authority.

func NewHarnessRegistry

func NewHarnessRegistry(allowlist ...string) *HarnessRegistry

func (*HarnessRegistry) Configure

func (r *HarnessRegistry) Configure(ctx context.Context, name string, config HarnessConfig) error

func (*HarnessRegistry) Get

func (r *HarnessRegistry) Get(name string) (AgentHarness, bool)

func (*HarnessRegistry) List

func (r *HarnessRegistry) List() []string

func (*HarnessRegistry) Manifest

func (r *HarnessRegistry) Manifest(ctx context.Context, name string) (HarnessManifest, error)

func (*HarnessRegistry) Register

func (r *HarnessRegistry) Register(harness AgentHarness) error

func (*HarnessRegistry) Statuses

func (r *HarnessRegistry) Statuses(ctx context.Context) ([]HarnessStatus, error)

type HarnessRequest

type HarnessRequest struct {
	Identity          execution.Identity    `json:"identity"`
	InputID           string                `json:"input_id"`
	Prompt            string                `json:"prompt"`
	Model             string                `json:"model"`
	Environment       workspace.Environment `json:"environment"`
	ChildRunID        string                `json:"child_run_id"`
	PolicyVersion     string                `json:"policy_version"`
	CatalogVersion    string                `json:"catalog_version"`
	ContextDigest     string                `json:"context_digest,omitempty"`
	OutputTokenBudget int                   `json:"output_token_budget,omitempty"`
	RequiredResume    ResumeMode            `json:"required_resume,omitempty"`
	ContinuationID    string                `json:"continuation_id,omitempty"`
	CheckpointHash    string                `json:"checkpoint_hash,omitempty"`
	ResumeToken       string                `json:"resume_token,omitempty"`
	Deadline          time.Time             `json:"deadline,omitempty"`
	Harness           HarnessManifest       `json:"harness"`
}

type HarnessResult

type HarnessResult struct {
	Status         string          `json:"status"`
	Final          string          `json:"final,omitempty"`
	ArtifactRef    string          `json:"artifact_ref,omitempty"`
	InputTokens    int             `json:"input_tokens,omitempty"`
	OutputTokens   int             `json:"output_tokens,omitempty"`
	ResumeMode     ResumeMode      `json:"resume_mode,omitempty"`
	ResumeToken    string          `json:"resume_token,omitempty"`
	ContinuationID string          `json:"continuation_id,omitempty"`
	CheckpointHash string          `json:"checkpoint_hash,omitempty"`
	ContextDigest  string          `json:"context_digest,omitempty"`
	Metadata       json.RawMessage `json:"metadata,omitempty"`
}

type HarnessStatus

type HarnessStatus struct {
	Name       string    `json:"name"`
	Version    string    `json:"version,omitempty"`
	Health     Health    `json:"health"`
	Configured bool      `json:"configured"`
	ActiveRuns int       `json:"active_runs"`
	LastError  string    `json:"last_error,omitempty"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type HarnessSupervisor

type HarnessSupervisor struct {
	Harness   AgentHarness
	Manifest  HarnessManifest
	MaxActive int
	// contains filtered or unexported fields
}

HarnessSupervisor enforces manifest pinning, bounded concurrency, event provenance, and run cleanup around one explicitly configured harness.

func NewHarnessSupervisor

func NewHarnessSupervisor(harness AgentHarness, manifest HarnessManifest, maxActive int) (*HarnessSupervisor, error)

func (*HarnessSupervisor) Cancel

func (s *HarnessSupervisor) Cancel(ctx context.Context, runID string) error

func (*HarnessSupervisor) Resume

func (s *HarnessSupervisor) Resume(ctx context.Context, request HarnessRequest, sink func(trajectory.Event) error) (HarnessResult, error)

func (*HarnessSupervisor) Run

func (*HarnessSupervisor) Status

type Health

type Health string
const (
	HealthStarting Health = "starting"
	HealthReady    Health = "ready"
	HealthDegraded Health = "degraded"
	HealthStopped  Health = "stopped"
)

type MCPCatalog

type MCPCatalog struct {
	Version   string           `json:"version"`
	Tools     []MCPTool        `json:"tools,omitempty"`
	Resources []MCPResourceRef `json:"resources,omitempty"`
	Prompts   []MCPPromptRef   `json:"prompts,omitempty"`
}

type MCPConfig

type MCPConfig struct {
	Name             string        `json:"name"`
	Version          string        `json:"version"`
	Transport        Transport     `json:"transport"`
	Endpoint         string        `json:"endpoint"`
	Auth             AuthMode      `json:"auth"`
	ConnectTimeout   time.Duration `json:"connect_timeout"`
	CallTimeout      time.Duration `json:"call_timeout"`
	ReconnectBackoff time.Duration `json:"reconnect_backoff"`
}

type MCPPromptRef

type MCPPromptRef struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type MCPPromptRequest

type MCPPromptRequest struct {
	Identity  execution.Identity `json:"identity"`
	Prompt    MCPPromptRef       `json:"prompt"`
	Arguments json.RawMessage    `json:"arguments,omitempty"`
}

type MCPRegistry

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

MCPRegistry owns configuration, authentication, catalog refresh, status, and cleanup for explicitly allowlisted servers.

func NewMCPRegistry

func NewMCPRegistry(allowlist ...string) *MCPRegistry

func (*MCPRegistry) Catalog

func (r *MCPRegistry) Catalog(name string) (MCPCatalog, bool)

func (*MCPRegistry) Reconnect

func (r *MCPRegistry) Reconnect(ctx context.Context, name string) error

func (*MCPRegistry) Refresh

func (r *MCPRegistry) Refresh(ctx context.Context, name string, refreshAuth bool) (MCPCatalog, error)

func (*MCPRegistry) Register

func (r *MCPRegistry) Register(ctx context.Context, config MCPConfig, server MCPServer) error

func (*MCPRegistry) Statuses

func (r *MCPRegistry) Statuses(ctx context.Context) (map[string]MCPStatus, error)

func (*MCPRegistry) Unregister

func (r *MCPRegistry) Unregister(ctx context.Context, name string) error

func (*MCPRegistry) WatchCatalog

func (r *MCPRegistry) WatchCatalog(ctx context.Context, name string) error

WatchCatalog consumes versioned updates until ctx is cancelled. Invalid or empty versions stop the watch rather than replacing a known-good catalog.

type MCPResourceRef

type MCPResourceRef struct {
	URI     string `json:"uri"`
	Version string `json:"version"`
}

type MCPResourceRequest

type MCPResourceRequest struct {
	Identity execution.Identity `json:"identity"`
	Resource MCPResourceRef     `json:"resource"`
}

type MCPServer

type MCPServer interface {
	Validate(MCPConfig) error
	Configure(context.Context, MCPConfig) error
	Start(context.Context) error
	Authenticate(context.Context) error
	RefreshAuth(context.Context) error
	Discover(context.Context) (MCPCatalog, error)
	WatchCatalog(context.Context) (<-chan MCPCatalog, error)
	CallTool(context.Context, MCPToolCall) (MCPToolResult, error)
	ReadResource(context.Context, MCPResourceRequest) (json.RawMessage, error)
	RenderPrompt(context.Context, MCPPromptRequest) (json.RawMessage, error)
	Health(context.Context) (Health, error)
	Status(context.Context) (MCPStatus, error)
	Stop(context.Context) error
}

MCPServer is the lifecycle surface required from a local or remote MCP transport. OAuth and transport details remain implementation-specific.

type MCPStatus

type MCPStatus struct {
	Health         Health    `json:"health"`
	CatalogVersion string    `json:"catalog_version,omitempty"`
	Authenticated  bool      `json:"authenticated"`
	LastError      string    `json:"last_error,omitempty"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type MCPTool

type MCPTool struct {
	Ref          execution.ToolRef   `json:"ref"`
	SchemaDigest string              `json:"schema_digest"`
	Class        execution.ToolClass `json:"class"`
}

type MCPToolCall

type MCPToolCall struct {
	Envelope execution.OperationEnvelope `json:"envelope"`
}

type MCPToolResult

type MCPToolResult struct {
	Content       json.RawMessage `json:"content,omitempty"`
	Indeterminate bool            `json:"indeterminate,omitempty"`
	Metadata      json.RawMessage `json:"metadata,omitempty"`
	ResultHash    string          `json:"result_hash,omitempty"`
}

type ResumeMode

type ResumeMode string

ResumeMode names a concrete recovery mechanism rather than treating every harness Resume method as equivalent.

const (
	ResumeNone            ResumeMode = ""
	ResumeToken           ResumeMode = "token"
	ResumeTranscript      ResumeMode = "transcript"
	ResumeExactCheckpoint ResumeMode = "exact_checkpoint"
)

type Transport

type Transport string
const (
	TransportStdio Transport = "stdio"
	TransportHTTP  Transport = "http"
	TransportSSE   Transport = "sse"
)

Jump to

Keyboard shortcuts

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