daemon

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MPL-2.0 Imports: 58 Imported by: 0

Documentation

Overview

Package daemon implements the a2ald runtime: DHT/QUIC host, REST API, TCP gateway, and MCP server. It is shared by the CLI binary (cmd/a2ald) and the mobile binding (mobile/).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MsgIDFromRecord added in v0.2.4

func MsgIDFromRecord(sr protocol.SignedRecord) [32]byte

MsgIDFromRecord computes a stable deduplication key: SHA-256(SignedRecord.Payload). When Payload is empty (legacy entry), it falls back to SHA-256(Address + Seq CBOR).

Types

type Config

type Config struct {
	// DataDir is the directory for keys, agents.json, peers.cache, and
	// config.toml. Required.
	DataDir string
	// CfgPath overrides the default config file path (DataDir/config.toml).
	CfgPath string
	// Override is called after the config is loaded, allowing the caller to
	// apply additional overrides (e.g., CLI flags).
	Override func(*config.Config)
	// Log is the structured logger to use. Defaults to text output on Stdout.
	Log *slog.Logger
	// MCPStdio runs the MCP server on stdin/stdout instead of HTTP.
	MCPStdio bool
}

Config is the startup configuration for New.

type Daemon

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

Daemon is the a2ald runtime.

func New

func New(cfg Config) (*Daemon, error)

New loads config, generates or loads the node key, and initialises the host. Call Run to start serving.

func (*Daemon) APIAddr

func (d *Daemon) APIAddr() string

APIAddr returns the REST API / Web UI listen address from the loaded config.

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context, mcpStdio bool) error

Run starts the daemon and blocks until ctx is cancelled. It saves the peers cache and config on return.

type Event added in v0.2.4

type Event struct {
	Type string
	AID  a2al.Address // zero = global / not agent-specific
	Data any
	At   time.Time
}

Event is a single daemon-internal event. Type follows the naming convention "<domain>.<verb>" (e.g. "mailbox.received").

type EventBus added in v0.2.4

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

EventBus is a simple in-process publish/subscribe bus. All methods are safe for concurrent use.

func NewEventBus added in v0.2.4

func NewEventBus(log *slog.Logger) *EventBus

NewEventBus returns an initialised EventBus.

func (*EventBus) Publish added in v0.2.4

func (b *EventBus) Publish(evt Event)

Publish delivers evt to all matching subscribers. Slow consumers are handled without blocking: if a subscriber's channel is full, the oldest event is discarded and the new one is enqueued.

func (*EventBus) Subscribe added in v0.2.4

func (b *EventBus) Subscribe(filter Filter) (<-chan Event, func())

Subscribe registers a subscriber with the given filter. Returns a receive-only channel and a cancel function. The caller must call cancel when done to release resources.

type Filter added in v0.2.4

type Filter struct {
	AID   a2al.Address // zero = any AID
	Types []string     // empty = all types
}

Filter restricts which events a subscriber receives. Empty/zero values match everything in that dimension.

type MailboxStoreEntry added in v0.2.4

type MailboxStoreEntry struct {
	RecipientAID a2al.Address          `cbor:"1,keyasint"`
	Record       protocol.SignedRecord `cbor:"2,keyasint"` // encrypted; zero-value when sourced from old-style poll
	ReceivedAt   int64                 `cbor:"3,keyasint"`
	TTLExpires   int64                 `cbor:"4,keyasint"`
	ConsumedAt   int64                 `cbor:"5,keyasint,omitempty"` // 0 = unconsumed
}

MailboxStoreEntry is one persisted mailbox record.

Directories

Path Synopsis
Package aidproxy implements the AID Resource Addressing Gateway.
Package aidproxy implements the AID Resource Addressing Gateway.

Jump to

Keyboard shortcuts

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