localapp

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 13 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 localapp speaks MCP to the HEY desktop app's own socket: the door the app opens while "Let agents use HEY" is on in its Settings. It is plain MCP, JSON-RPC 2.0 with one message per line, and the client asks only for what hey local needs: initialize, tools/list and tools/call.

What the door serves is the app's, not HEY's: it runs the app's own commands over the mail the app holds, and a command that reaches people (a send) answers pending, waiting in the app's window for the person to press Send. Nothing here can confirm one.

Index

Constants

View Source
const EffectMetaKey = "com.hey/effect"

EffectMetaKey is where a tool's _meta names its effect: read, reversible or reaches_people.

View Source
const MaxLine = 16 << 20

MaxLine bounds one message from the app. An Imbox listing is a few hundred kilobytes at most; a line past this is not an answer worth waiting for.

View Source
const ProtocolVersion = "2025-06-18"

ProtocolVersion is the MCP revision the client asks for. initialize, tools/list and tools/call read the same in every revision so far, so whichever one the app answers with is accepted.

View Source
const SocketEnv = "HEY_LOCAL_SOCKET"

SocketEnv overrides where the door is looked for, as --socket does for one command.

Variables

View Source
var ErrNoRuntimeDir = errors.New("XDG_RUNTIME_DIR is not set to an absolute path")

ErrNoRuntimeDir is a session with no XDG_RUNTIME_DIR, the one folder the app opens its door in. The app refuses to open one without it, so there is nothing to guess at.

Functions

func SocketPath

func SocketPath(flag string) (string, error)

SocketPath is where the door is: the flag's path, else HEY_LOCAL_SOCKET's, else $XDG_RUNTIME_DIR/hey/agent.sock, where the app opens it.

Types

type Client

type Client struct {

	// Server is what the app said about itself in its initialize answer.
	Server ServerInfo
	// contains filtered or unexported fields
}

Client is one connection to the app's door, initialized and ready for calls. It sends one request at a time and reads its answer before the next.

func Dial

func Dial(ctx context.Context, path string) (*Client, error)

Dial connects to the door at path and initializes the session. ctx bounds the dial and the initialize; each later call is bounded by its own.

func (*Client) Call

func (c *Client) Call(ctx context.Context, name string, arguments map[string]any) (*Result, error)

Call runs one tool. A refusal comes back as a Result with IsError set, as MCP has it; only a failure of the exchange itself is an error.

func (*Client) Close

func (c *Client) Close() error

func (*Client) Tools

func (c *Client) Tools(ctx context.Context) ([]Tool, error)

Tools lists every tool the app offers now, following pagination should the app page.

type ConnectError

type ConnectError struct {
	Path  string
	Cause error
}

ConnectError is a socket that is there but could not be used: refused by permissions, not a socket, or a connection that broke.

func (*ConnectError) Error

func (e *ConnectError) Error() string

func (*ConnectError) Unwrap

func (e *ConnectError) Unwrap() error

type Content

type Content struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type DoorClosedError

type DoorClosedError struct {
	Path  string
	Cause error
}

DoorClosedError is a socket that is not there, or that nothing answers on: the door is off in the app's Settings, or the app is not running.

func (*DoorClosedError) Error

func (e *DoorClosedError) Error() string

func (*DoorClosedError) Unwrap

func (e *DoorClosedError) Unwrap() error

type Pending

type Pending struct {
	Confirmation json.RawMessage `json:"confirmation,omitempty"`
	Snapshot     json.RawMessage `json:"snapshot,omitempty"`
}

Pending is a call the app took but did not carry out: it waits in the app's window for the person, who sees Snapshot and sends it or not.

type ProtocolError

type ProtocolError struct {
	Method string
	Reason string
	Closed bool
}

ProtocolError is an answer the client cannot read as MCP. Closed is a connection the app closed before it answered, as it does a caller of another user account.

func (*ProtocolError) Error

func (e *ProtocolError) Error() string

type Result

type Result struct {
	Content           []Content       `json:"content"`
	StructuredContent json.RawMessage `json:"structuredContent,omitempty"`
	IsError           bool            `json:"isError,omitempty"`
}

Result is the app's answer to a tools/call.

func (*Result) Answer

func (r *Result) Answer() json.RawMessage

Answer is the result's structured answer: structuredContent, or the text content where that is JSON and there is no structuredContent. nil where the result carries neither.

func (*Result) Pending

func (r *Result) Pending() (*Pending, bool)

Pending reports a call the app answered "pending, waiting in HEY": a structured answer whose status is pending, however the rest of it reads, since reading a waiting send as done is the one mistake this must not make. A refusal is never pending.

func (*Result) Text

func (r *Result) Text() string

Text is the result's text content, every text block joined by a newline.

type ServerError

type ServerError struct {
	Method  string
	Code    int
	Message string
}

ServerError is a JSON-RPC error the app answered with: a method or a tool it does not have, or arguments it could not read.

func (*ServerError) Error

func (e *ServerError) Error() string

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Title   string `json:"title,omitempty"`
	Version string `json:"version,omitempty"`
}

type TimeoutError

type TimeoutError struct {
	Method string
	Cause  error
}

TimeoutError is an answer that did not come in time.

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

func (*TimeoutError) Unwrap

func (e *TimeoutError) Unwrap() error

type Tool

type Tool struct {
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	InputSchema json.RawMessage `json:"inputSchema,omitempty"`
	Annotations json.RawMessage `json:"annotations,omitempty"`
	Meta        map[string]any  `json:"_meta,omitempty"`
}

Tool is one command the app offers now.

func (Tool) Effect

func (t Tool) Effect() string

Effect is what the tool's _meta says running it does, or "" where it says nothing.

Directories

Path Synopsis
Package localapptest is a fake of the HEY app's door for tests: a Unix socket that answers MCP as the door's contract does, from what a test gives it.
Package localapptest is a fake of the HEY app's door for tests: a Unix socket that answers MCP as the door's contract does, from what a test gives it.

Jump to

Keyboard shortcuts

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