applink

package
v0.6.173 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package applink is the app link: the MCP server through which a persistent agent reaches the application that runs it, and nothing else. The gateway launches it on the runner image with no network and one bind, a socket the agent's supervisor serves; each tool call is forwarded over that socket as one request, and the supervisor's answer is returned as the tool's result. It holds no credential, and the tools it lists are a fixed set per agent: none of them changes what an agent is given, so an agent cannot widen its own grants through it.

This package is part of the embedded runner-image build context and therefore MUST remain stdlib-only.

Index

Constants

View Source
const (
	SocketDir   = "/run/agentry"
	SocketMount = SocketDir + "/app.sock"
)

SocketMount is where the app link finds the supervisor's socket: the supervisor's own, bound by its exact path, or, where the engine's daemon runs in a VM, the relay's, in a volume mounted at SocketDir.

View Source
const (
	SetMain      = "main"
	SetAssistant = "assistant"
)

The tool sets, by the agent they are for.

View Source
const (
	TaskAdd    = "task_add"
	TaskList   = "task_list"
	TaskUpdate = "task_update"
	TaskRemove = "task_remove"
)

The Assistant's task tools: the tasks its heartbeat fires, which it registers itself. A task is a turn at a time; it grants nothing.

View Source
const MaxLine = 4 << 20

MaxLine bounds a line either way, on the socket and on the relay's stdio.

View Source
const SelfConfigure = "self_configure"

SelfConfigure is the Assistant's tool for its own name and personality.

View Source
const ServerName = "agentry-applink"

ServerName is the app link's name in the gateway's catalog.

Variables

View Source
var CallTimeout = 30 * time.Minute

CallTimeout bounds one call: a QuickAgent's run is answered once it is started, and a consent waits for the person.

Functions

func Relay

func Relay(ctx context.Context, cfg RelayConfig) error

Relay serves the socket until In ends or ctx is done.

func Serve

func Serve(ctx context.Context, in io.Reader, out, logw io.Writer, set, socket string) error

Serve answers MCP on stdio for set, forwarding each call to socket.

func Sets

func Sets() []string

Sets are the tool sets there are.

func Tools

func Tools(set string) []string

Tools are a set's tool names, in a fixed order; none for an unknown set.

Types

type Answer

type Answer struct {
	Text    string `json:"text"`
	IsError bool   `json:"isError,omitempty"`
}

Answer is the supervisor's answer, one JSON line.

func Call

func Call(ctx context.Context, socket string, req Request) (Answer, error)

Call sends one request over the socket and reads one answer.

type Frame

type Frame struct {
	ID      uint64   `json:"id,omitempty"`
	Ready   bool     `json:"ready,omitempty"`
	Request *Request `json:"request,omitempty"`
	Answer  *Answer  `json:"answer,omitempty"`
}

Frame is one line between the relay and the CLI: the relay's ready line, a call it carries out (ID and Request), or the answer carried back (ID and Answer).

func ReadFrame

func ReadFrame(line []byte) (Frame, error)

ReadFrame decodes one frame strictly: a field it does not know refuses it.

type RelayConfig

type RelayConfig struct {
	// Listen is the socket's path.
	Listen string
	// Owner is the uid:gid the socket is given, the app link's user; empty
	// leaves it the relay's.
	Owner string
	// In carries the answers from the CLI, Out the calls to it.
	In  io.Reader
	Out io.Writer
	// Log takes what goes wrong.
	Log io.Writer
}

RelayConfig is what the relay serves.

type Request

type Request struct {
	Tool      string          `json:"tool"`
	Arguments json.RawMessage `json:"arguments,omitempty"`
}

Request is one tool call as the app link sends it over the socket: one JSON line on a connection of its own.

func ReadRequest

func ReadRequest(r io.Reader) (Request, error)

ReadRequest reads one request from a connection, as the supervisor does.

type Tool

type Tool struct {
	Name        string
	Description string
	Schema      map[string]any
}

Tool is one tool of a set: its name, what it does, and its input schema.

Jump to

Keyboard shortcuts

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