daemon

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 50 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 daemon wires Smif together: the socket API, the store, the router, the scheduler, the supervisor and the runners. It is the only long-lived process (RFC 4.1).

Index

Constants

View Source
const MaxPromptRunes = 4000

MaxPromptRunes caps one prompt.

View Source
const (

	// RemoteCommand runs in a non-login shell, which has no ~/.local/bin.
	RemoteCommand = `PATH="$HOME/.local/bin:$PATH" smif sessions --json`
)

Other machines (ADR-0023): a remote is an ssh host that runs smif too. The daemon asks it for its session list and shows the rows here, read only.

View Source
const RemoteKey = "smif_ed25519"

RemoteKey is the daemon's own key in ~/.ssh (ADR-0024). The other machine lets it run the session list and nothing else.

View Source
const SessionAskProfile = "answer"

SessionAskProfile is the worker profile that answers session asks.

Variables

View Source
var Version = "dev"

Version is set at build time.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is a store not-found.

func RemoteArgv added in v0.2.0

func RemoteArgv(host, command string) []string

RemoteArgv is the ssh call. The host passed config validation, and -- ends the options. A shared connection keeps a poll cheap.

func SSHCommand added in v0.3.0

func SSHCommand() string

SSHCommand is the ssh binary.

Types

type Daemon

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

Daemon is the running service.

func New

func New(o Options) (*Daemon, error)

New opens state and prepares the daemon. Call Start to serve.

func (*Daemon) Cancel

func (d *Daemon) Cancel(id string) (string, error)

Cancel cancels a queued, waiting or running message. It returns the state the item has after the call: api.CancelRejected when the item is rejected at once, api.CancelCancelling when a running worker must stop first (the outcome then shows in thread.get).

func (*Daemon) Config

func (d *Daemon) Config() *config.Config

Config returns the current config.

func (*Daemon) GC

func (d *Daemon) GC() (*api.GCResult, error)

GC applies the retention rules of RFC 8.1.

func (*Daemon) HumanReply

func (d *Daemon) HumanReply(p api.HumanReplyParams) (*api.SendResult, error)

HumanReply answers a needs_human item (RFC 5.3, 7.3 `smif reply`).

An ask the rules escalated is answered directly: the text becomes the reply to the asker. Anything else continues in the same thread: the text goes back to the agent as a reply and its worker runs again.

func (*Daemon) Ingest

func (d *Daemon) Ingest(c auth.Principal, kind string, raw json.RawMessage) (*api.SendResult, error)

Ingest validates, stamps and persists a client message, then routes it. The message is committed before the ack (R-DEL-2).

func (*Daemon) Reload

func (d *Daemon) Reload() error

Reload re-reads the config. An invalid config keeps the old one.

func (*Daemon) Retry

func (d *Daemon) Retry(id string) error

Retry requeues a dead letter.

func (*Daemon) Start

func (d *Daemon) Start() error

Start reconciles state, probes claude, binds the socket and starts the dispatcher. It returns once the socket accepts connections.

func (*Daemon) Stop

func (d *Daemon) Stop()

Stop cancels running work (their messages go back to the queue without counting an attempt), closes the socket and the store.

func (*Daemon) Store

func (d *Daemon) Store() *store.Store

Store exposes the store (tests).

func (*Daemon) Wait

func (d *Daemon) Wait()

Wait blocks until the daemon stops.

type Options

type Options struct {
	ConfigPath string
	DataDir    string
	Socket     string
	// Notifier overrides the configured notifier (tests).
	Notifier notify.Notifier
	// SkipProbe uses the verified capability set instead of probing claude.
	SkipProbe bool
	// LogWriter receives daemon logs in addition to the log file.
	LogWriter io.Writer
}

Options configure a daemon.

Jump to

Keyboard shortcuts

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