node

package
v0.0.0-...-7235933 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 156 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 node runs on every machine: it drives herdr/claude locally and talks to the hub over stdio RPC.

Index

Constants

View Source
const (
	DoctorOK   = "ok"
	DoctorWarn = "warn"
	DoctorFail = "fail"
)

Check statuses.

View Source
const (
	RestoreConversation = "conversation"
	RestoreCodeAndConv  = "code_and_conversation"
)

Restore choices of session.rewind.

View Source
const ClaudeVersionUnanswered = "unanswered"

ClaudeVersionUnanswered is the claude-version check's state when no version was read but the shell did find claude (it ran out of time, or printed none): the assistant's readiness then says unknown, not claude_missing. The hub matches the literal (assistant/readiness.go); "" is every other outcome, as with nodes from before it.

View Source
const DaemonSubprotocol = "persona-runtime.v1"

DaemonSubprotocol is the WebSocket subprotocol a daemon's endpoint must answer with.

View Source
const NodeLaunchdLabel = "com.persona.node"

NodeLaunchdLabel is the resident node's launchd agent, as both installers name it (and write it on a new install).

View Source
const ResidentHandoverSupported = true
View Source
const RuntimeProtocol = 1

RuntimeProtocol is the runtime wire's version, answered to runtime.hello; it grows only for changes old runtimes misread.

Variables

This section is empty.

Functions

func AgyHooksCommand

func AgyHooksCommand(args []string, out interface{ Write([]byte) (int, error) }) error

AgyHooksCommand is `personad node agy-hooks [status|install|uninstall]`: the entries in agy's hooks file. uninstall removes them and keeps the node from putting them back (agyHooksOffFile); install undoes that.

func AssistantTUI

func AssistantTUI(args []string, stdin io.Reader, stdout, stderr io.Writer) int

AssistantTUI runs the bridge; it returns the process's exit status.

func AssistantsBusy

func AssistantsBusy() bool

AssistantsBusy: a conversation is answering or waiting on its background tasks or monitors; a resident node asked to restart (SIGHUP, a deploy) waits until none is (cmd/personad runResident). Idle ones resume on the next message.

func Attach

func Attach(ctx context.Context, newNode func() (*Node, error), extra <-chan net.Conn, runtimes *RuntimeHost) error

Attach runs a resident node: it listens on AttachSocketPath and serves one hub connection at a time, each relayed by `personad node --stdio`, or arriving on extra (the hub dialing in over tailcat, tailcat.go; nil: none). A new connection replaces the one being served whichever way either came (the hub reconnected, maybe the other way; the old one may not have noticed yet), as a new ssh-started node used to replace the old one. newNode makes the Node for a connection. runtimes, when set, is the runtime socket (runtimehost.go): opened here, once this is the one resident node, and shared by every connection's Node, so runtimes connect before the hub does and stay connected while it reconnects.

func AttachSocketPath

func AttachSocketPath() string

AttachSocketPath is where a resident node listens for relays.

func AttachWithTransport

func AttachWithTransport(ctx context.Context, newNode func() (*Node, error), extra <-chan net.Conn, runtimes *RuntimeHost, transport *ResidentTransport) error

AttachWithTransport serves on a resident-owned listener that can retain duplicates through an executable handover.

func ClaudePluginCommand

func ClaudePluginCommand(ctx context.Context, args []string, stdout, stderr io.Writer) int

ClaudePluginCommand is `claude-plugin <op>` (nodecmd): the status after op, as JSON.

func ClaudePluginManager

func ClaudePluginManager(logf func(string, ...any)) *claudeplugin.Manager

ClaudePluginManager is the plugin's manager for this computer: the user's Claude Code config directories, the CLI found the way the node finds it (or the desktop app's own), the plugin this build carries.

func CodexCatalogWait

func CodexCatalogWait() time.Duration

CodexCatalogWait is codexCatalogWait, for nodecmd's check that `personad launch` waits well longer for the node.

func CodexStart

func CodexStart(args []string) error

CodexStart is `personad codex-start <file>`: it claims a codexStartFile (renames it away, then reads and removes it), changes to its directory, then runs its words with any message as one more argument after "--", in place of itself. Neither is parsed as shell code. Claimed by a rename, the file is either this process's or withdrawn by the node (a switch whose start gave up on it, codexMessageMayHaveGone): never both. The file's agent replaces a HERDR_AGENT the shell had: appended, the inherited one would come first, and that is the one getenv and herdr read.

func DoctorCommand

func DoctorCommand(ctx context.Context, args []string, out io.Writer) (failed bool, err error)

DoctorCommand is `personad node doctor [--json] [--fix]`: it prints the report to out and says whether a check failed (the caller exits non-zero then).

func GatewayAvailableAgain

func GatewayAvailableAgain(text string, at time.Time) (time.Time, bool)

GatewayAvailableAgain shares the transcript parser used by worker usage-limit waits.

func Launch

func Launch(ctx context.Context, name string, args []string, ticket string) error

Launch is `personad launch [--ticket <ticket>] <name> [claude args…]`: the managed launcher's settings from the local node, a hand-off's values with a ticket (secretenv.go), then claude.

func LaunchWithSecrets

func LaunchWithSecrets(ctx context.Context, ticket string, argv []string) error

LaunchWithSecrets is `personad launch --ticket <ticket> -- <command> [args…]`: plain claude (or what argv names) with a hand-off's values in its environment (secretenv.go), the rest of the environment as the shell gave it.

func LauncherDetail

func LauncherDetail(p Probe) proto.LauncherDetail

LauncherDetail turns a probe into the page's fields: agent, gateway, how it authenticates, every model tier, the context window, effort, flags, and the other settings — secrets masked.

func LoadMachineUID

func LoadMachineUID(dir string) (string, error)

LoadMachineUID reads the id, making it the first time. A file that does not hold one (edited by hand, cut short) is replaced: an id nobody can match is worse than a new one.

func MachineUIDPath

func MachineUIDPath(dir string) string

MachineUIDPath is where the id lives, under dir (~/.persona).

func ModelRecoveryExplanation

func ModelRecoveryExplanation(reason string) string

ModelRecoveryExplanation is the public, non-internal reason text for a recovery reason enum.

func ModelRecoveryReason

func ModelRecoveryReason(result string) string

ModelRecoveryReason classifies the failure that moved a conversation off its configured model.

func ModelSourceLaunch

func ModelSourceLaunch(args []string) error

ModelSourceLaunch is the final CLI hop, after shell functions set their environment and provider flags. Provider credentials remain in memory/environment; only header-to-environment bindings reach argv.

func NodeLaunchAgentPath

func NodeLaunchAgentPath(home, label string) string

NodeLaunchAgentPath is where the resident node's launchd agent called label is described.

func PrintDoctor

func PrintDoctor(out io.Writer, rep DoctorReport)

PrintDoctor writes the legacy zh-Hans text report. New display paths choose their language explicitly.

func PrintDoctorIn

func PrintDoctorIn(out io.Writer, rep DoctorReport, lang i18n.Lang)

PrintDoctorIn writes rep, one line per check: label | name: what was found; what to do about it.

func Relay

func Relay(ctx context.Context, r io.Reader, w io.Writer) (ok bool, err error)

Relay pipes r / w to a resident node if one is listening. ok is false when there is none (the caller serves the connection itself); otherwise it returns when either side closes.

func ResetMachineUID

func ResetMachineUID(dir string) (string, error)

ResetMachineUID writes a new id and returns it.

func RuntimeSocketPath

func RuntimeSocketPath() string

RuntimeSocketPath is where runtimes reach the node.

func ServeTailcat

func ServeTailcat(ctx context.Context, logger *log.Logger, upgraded func()) (conns <-chan net.Conn, stopped <-chan struct{}, err error)

ServeTailcat brings up this machine's tailcat endpoint for a resident node, when it was set up for it (`personad node tailcat init`, ~/.persona/tailcat.json): the hub's connections on tunnel.NodePort go to the returned channel (Attach's extra), a new binary on tunnel.UploadPort replaces this one and calls upgraded. Not set up: a nil channel. Starting needs the network (the DERP map, the relay), so it retries in the background until it works: relays over ssh are served meanwhile. stopped closes once ctx ended and the endpoint is down.

func SetResident

func SetResident(program, version string)

SetResident says which program and build the resident node of this process is (nodecmd runResident, before Attach).

func SpoolPath

func SpoolPath() string

SpoolPath is where a resident node keeps what it took while its manager was away.

func StartClaudePlugin

func StartClaudePlugin(ctx context.Context, logger *log.Logger)

StartClaudePlugin starts the resident node's keeper (runResident).

func TabStart

func TabStart(args []string) error

TabStart resumes a runtime-provided command, such as pi, in a new tab.

func TailcatAddr

func TailcatAddr() (tailcat.Addr, error)

TailcatAddr is this machine's address for hub.json (machines[].tailcat_addr).

Types

type ClaudeSetting

type ClaudeSetting struct {
	Key          string   `json:"key"`
	Title        string   `json:"title"`
	Detail       string   `json:"detail"`
	Type         string   `json:"type"` // bool | enum | string
	Options      []string `json:"options,omitempty"`
	Default      any      `json:"default"`
	Value        any      `json:"value"`                   // nil when unset (Claude Code uses the default)
	IgnoredValue string   `json:"ignored_value,omitempty"` // stored but not applied by Claude Code
}

ClaudeSetting is one Claude Code /config option the app may change. Only these keys are read or written; everything else in settings.json (of each config directory, claudedirs.go) is preserved as is.

type DirEntry

type DirEntry struct {
	Name    string    `json:"name"`
	Dir     bool      `json:"dir"`
	Symlink bool      `json:"symlink,omitempty"`
	Size    int64     `json:"size"`
	ModTime time.Time `json:"mtime"`
	// Ignored: Git ignores it (the tree dims it); never set outside a repository or without git (fsignore.go).
	Ignored bool `json:"ignored,omitempty"`
	// LinkTarget: what a symlink says (its text, as readlink gives it); LinkBroken: what it points to is not there, or
	// a loop of links. A link is never followed for the listing beyond telling a folder from a file; Size and ModTime
	// are its target's when that can be read, otherwise the link's own (#5827).
	LinkTarget string `json:"link_target,omitempty"`
	LinkBroken bool   `json:"link_broken,omitempty"`
}

DirEntry is one row of the phone's file tree.

type DoctorCheck

type DoctorCheck struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	// State is current / stale / missing for a generated file or directory, "" for the other checks.
	State  string   `json:"state"`
	Detail string   `json:"detail"`
	Hint   string   `json:"hint"`
	Items  []string `json:"items"` // what differs, which commands, ...; never null
}

DoctorCheck is one line of the report; the names are stable for scripts.

type DoctorOptions

type DoctorOptions struct {
	// Lang words this run's human-readable fields. Empty keeps the legacy zh-Hans report; it never comes from the
	// resident node's environment.
	Lang i18n.Lang
	Dir  string // the node's directory (~/.persona)
	Bin  string // the program the generated files should run: this binary
	// Sockets: node.sock, runtime.sock and herdr's API socket.
	NodeSock, RuntimeSock, HerdrSock string
	// ClaudeConfigDir is where the user's own Claude Code settings are (read, never written).
	ClaudeConfigDir string
	// ClaudeVersion asks claude's version ("" when unknown); ClaudeProbe, when set, is asked instead and also says
	// whether the shell found no claude at all (claudeProbe), so a version that could not be read this time is not
	// reported as Claude Code missing.
	ClaudeVersion func(context.Context) string
	ClaudeProbe   func(context.Context) (version string, missing bool)
	// LaunchAgent is the resident node's launchd agent on a Mac (NodeLaunchAgentPath; pickNodeLaunchdLabel says which
	// when a Mac keeps its previously installed label); "" elsewhere, and the launchd-process-type check is
	// left out.
	LaunchAgent string
	// LaunchdTarget is that agent as launchctl names it (gui/<uid>/com.persona.node, or the older label).
	LaunchdTarget string
	// Launchctl runs launchctl and returns its output; nil: launchd is not asked (the check reads the plist only).
	Launchctl func(ctx context.Context, args ...string) (string, error)
	// InsideNode: the doctor runs in the resident node (node.doctor) or under it. --fix then leaves the LaunchAgent
	// alone: loading it again stops the node, and with it the doctor, half way.
	InsideNode bool
	// RestartWait caps the wait, after --fix loaded the agent again, for the new node to answer (0: nodeRestartWait).
	RestartWait time.Duration
	// Preflight is the path-access check (preflight.go); nil leaves it out. It receives this run's language so a
	// terminal --json run can keep the legacy bytes even when the terminal is not Chinese.
	Preflight func(context.Context, i18n.Lang) DoctorCheck
	// AgyHooksFile is agy's global hooks file (node/agyhooks.go); "" leaves the check out (agy is not here).
	AgyHooksFile string
	// Fix writes the generated files again when they are stale or missing, and (outside the node) writes
	// ProcessType=Interactive into the LaunchAgent and loads it again.
	Fix bool
}

DoctorOptions says where to look; DefaultDoctorOptions fills them in for this machine (tests give their own).

func DefaultDoctorOptions

func DefaultDoctorOptions() (DoctorOptions, error)

DefaultDoctorOptions is this machine's: the same places the node itself uses, without creating or moving any.

type DoctorReport

type DoctorReport struct {
	OK     bool          `json:"ok"` // no check failed
	Dir    string        `json:"dir"`
	Checks []DoctorCheck `json:"checks"`
	// Fixed names what --fix put right: the generated files it wrote again; on a Mac launchd-process-type when it
	// wrote ProcessType into the LaunchAgent and launchd-reload when it loaded the agent again.
	Fixed []string `json:"fixed"`
}

DoctorReport is what `node doctor` prints (--json: as it is).

func RunDoctor

func RunDoctor(ctx context.Context, opts DoctorOptions) DoctorReport

RunDoctor runs the checks. With opts.Fix it first puts right what it may (the generated files; outside the node, the LaunchAgent's ProcessType), then checks again.

type FileContent

type FileContent struct {
	Path      string   `json:"path"`
	Name      string   `json:"name"`
	Size      int64    `json:"size"`
	Mime      string   `json:"mime"`
	Text      string   `json:"text,omitempty"` // UTF-8 text files
	Data      string   `json:"data,omitempty"` // base64 for binary files (images, PDFs), unless asked with stream
	Truncated bool     `json:"truncated"`      // there is more after this page
	Offset    int64    `json:"offset"`         // where this page starts (bytes)
	Next      int64    `json:"next,omitempty"` // where the next page starts; 0 at the end
	IsDir     bool     `json:"is_dir"`
	Entries   []string `json:"entries,omitempty"` // directory listing (names, dirs end with /)
	// Stream: a binary file asked for with stream; its bytes come from file/download (Range), Revision pins them.
	Stream   bool   `json:"stream,omitempty"`
	Revision string `json:"revision,omitempty"`
}

FileContent is a file read for the phone's file viewer (paths mentioned in a conversation).

type FindResult

type FindResult struct {
	Cwd       string   `json:"cwd"`
	Files     []string `json:"files"`
	Truncated bool     `json:"truncated"`
	Source    string   `json:"source"` // "git" or "walk"
}

FindResult is the list fs.find returns.

type GitBranch

type GitBranch struct {
	Name     string    `json:"name"`
	Remote   bool      `json:"remote,omitempty"`
	Current  bool      `json:"current,omitempty"`
	Upstream string    `json:"upstream,omitempty"`
	Hash     string    `json:"hash"`
	Subject  string    `json:"subject"`
	Date     time.Time `json:"date"`
}

type GitCheck

type GitCheck struct {
	Name  string `json:"name"`
	State string `json:"state"` // pass, fail, pending, skipped
	URL   string `json:"url,omitempty"`
}

type GitCommit

type GitCommit struct {
	Hash    string    `json:"hash"`
	Short   string    `json:"short"`
	Subject string    `json:"subject"`
	Body    string    `json:"body,omitempty"`
	Author  string    `json:"author"`
	Date    time.Time `json:"date"`
	Refs    string    `json:"refs,omitempty"`
}

type GitFile

type GitFile struct {
	Path     string `json:"path"`
	OrigPath string `json:"orig_path,omitempty"` // renames
	// Index / Worktree are the porcelain status letters (M A D R C U ? or "."), e.g. "M." staged, ".M" unstaged.
	Index    string `json:"index"`
	Worktree string `json:"worktree"`
	Added    int    `json:"added"`
	Deleted  int    `json:"deleted"`
	Binary   bool   `json:"binary,omitempty"`
}

type GitPR

type GitPR struct {
	Number          int           `json:"number"`
	URL             string        `json:"url"`
	Title           string        `json:"title"`
	State           string        `json:"state"` // OPEN, CLOSED, MERGED
	Draft           bool          `json:"draft,omitempty"`
	Base            string        `json:"base"`
	Head            string        `json:"head"`
	HeadOID         string        `json:"head_oid,omitempty"`
	Mergeable       string        `json:"mergeable,omitempty"`   // MERGEABLE, CONFLICTING, UNKNOWN
	MergeState      string        `json:"merge_state,omitempty"` // gh's mergeStateStatus: CLEAN, BLOCKED, BEHIND, DIRTY…
	Review          string        `json:"review,omitempty"`      // APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED
	ReviewsComplete bool          `json:"reviews_complete,omitempty"`
	LastReviewAt    *time.Time    `json:"last_review_at,omitempty"`
	AutoMerge       bool          `json:"auto_merge,omitempty"`      // set to merge when ready
	Checks          []GitCheck    `json:"checks"`                    // the head commit's checks
	ChecksState     string        `json:"checks_state,omitempty"`    // passing, failing, pending ("" when there are none)
	ChecksComplete  bool          `json:"checks_complete,omitempty"` // every rollup context was returned and its status was checked
	Threads         []GitPRThread `json:"threads"`                   // the open (unresolved) review threads
	ThreadsComplete bool          `json:"threads_complete,omitempty"`
}

GitPR is the branch's pull request as the panel shows it.

type GitPRComment

type GitPRComment struct {
	Author string    `json:"author"`
	Body   string    `json:"body"`
	URL    string    `json:"url,omitempty"`
	At     time.Time `json:"at"`
}

type GitPRThread

type GitPRThread struct {
	Path     string         `json:"path"`
	Line     int            `json:"line,omitempty"`
	Outdated bool           `json:"outdated,omitempty"`
	Comments []GitPRComment `json:"comments"`
}

GitPRThread is an unresolved review thread: where, and what was said.

type GitPullResult

type GitPullResult struct {
	Status  *GitStatus `json:"status"`
	Updated bool       `json:"updated"`
}

type GitShow

type GitShow struct {
	Commit    GitCommit `json:"commit"`
	Files     []GitFile `json:"files"`
	Diff      string    `json:"diff"`
	Truncated bool      `json:"truncated"`
}

type GitStashEntry

type GitStashEntry struct {
	Index   int       `json:"index"`
	OID     string    `json:"oid"`
	Message string    `json:"message"`
	Date    time.Time `json:"date"`
}

type GitStatus

type GitStatus struct {
	IsRepo   bool        `json:"is_repo"`
	Root     string      `json:"root,omitempty"`
	Branch   string      `json:"branch,omitempty"` // empty when detached
	Head     *GitCommit  `json:"head,omitempty"`
	Upstream string      `json:"upstream,omitempty"`
	Ahead    int         `json:"ahead"`
	Behind   int         `json:"behind"`
	Files    []GitFile   `json:"files"`
	Stashes  int         `json:"stashes"`
	Commits  []GitCommit `json:"commits"`
	// Gone: the upstream is configured but its ref is not there (the remote branch was deleted and pruned, as a merged
	// pull request's branch is); ahead and behind are then 0 and mean nothing, and a push publishes the branch again.
	Gone bool `json:"gone,omitempty"`
}

type Handoff

type Handoff struct {
	Summary string        `json:"summary"`
	Recent  []HandoffTurn `json:"recent"`
}

Handoff is what assistant.handoff reads from a conversation: its latest compaction summary ("" when it was never compacted) and the messages after it, the newest last.

type HandoffTurn

type HandoffTurn struct {
	Role string `json:"role"`
	Text string `json:"text"`
}

HandoffTurn is one recent message of a conversation handed off: role user or assistant.

type MachineOps

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

MachineOps exposes strictly read-only local machine diagnostics for the five machine-ops domains (#12349 storage/hotspots, #12350 toolchain, #12351 redacted network/proxy probes, #12352 listening ports and processes, #12353 user services/containers and bounded logs).

Mutating operations (storage cleanup, process kill, service start/stop/restart) and human-only file browser/write endpoints (#12354/#12403) are deliberately excluded from this surface.

func NewMachineOps

func NewMachineOps() *MachineOps

NewMachineOps creates a standalone read-only diagnostics runner for the local machine without starting any node sockets, hub connections, or background loops.

func (*MachineOps) Network

Network runs redacted proxy inspection and fixed allowlisted developer endpoint reachability probes.

func (*MachineOps) Ports

Ports lists active listening TCP/UDP sockets with bind scopes and redacted command lines.

func (*MachineOps) Processes

Processes lists running processes with orphan heuristics, protection flags, and redacted command lines.

func (*MachineOps) ServiceLogs

ServiceLogs fetches bounded tail logs for a validated systemd unit, launchd label, or Docker container.

func (*MachineOps) Services

Services lists user systemd/launchd services, Docker containers, and manager availability.

func (*MachineOps) Storage

Storage collects fast read-only per-mount disk and inode utilization (statfs only).

func (*MachineOps) StorageHotspots

StorageHotspots runs an on-demand bounded scan across allowlisted storage hotspot categories.

func (*MachineOps) Toolchain

Toolchain collects the redacted local development toolchain, agent CLI, Docker/gh, and hardware profile.

type MemoryFile

type MemoryFile struct {
	Name      string    `json:"name"` // file name, e.g. "lark-access.md"
	Content   string    `json:"content"`
	UpdatedAt time.Time `json:"updated_at"`
	// CreatedAt is when the file was made, where the file system keeps it (fileBirth); absent otherwise.
	CreatedAt *time.Time `json:"created_at,omitempty"`
}

type Node

type Node struct {
	Version string

	// Program is what bin is (nodeproto.ProgramPersonad / ProgramPersonaNode), for node.info; "" says nothing.
	Program string
	// Edition is the edition bin was built as (nodeproto.EditionFull when nothing says), for node.info.
	Edition nodeproto.Edition
	// contains filtered or unexported fields
}

func New

func New(version string) (*Node, error)

func (*Node) Serve

func (n *Node) Serve(ctx context.Context, r io.Reader, w io.Writer) error

Serve runs the node protocol for one hub connection on r / w until it ends. One Node serves one connection: `personad node --attach` makes a new one per connection (attach.go).

func (*Node) ServeStdio

func (n *Node) ServeStdio(ctx context.Context) error

ServeStdio runs the node protocol on stdin/stdout until the hub disconnects.

func (*Node) SetResidentReload

func (n *Node) SetResidentReload(r *ResidentReload)

func (*Node) SetUpdater

func (n *Node) SetUpdater(updater *nodeupdate.Manager)

SetUpdater is used by the resident's Node factory, never by a stdio node.

func (*Node) StopUnusedHerdr

func (n *Node) StopUnusedHerdr(ctx context.Context)

StopUnusedHerdr is what a node serving one hub connection over stdio does as it ends (#10114): the herdr server it started itself in this process (startHerdr) is stopped when nothing is open in it, so a hub's own machine, or a throwaway hub run for a check, leaves no server behind that it made and nobody used. A server with any pane, one this process did not start, or one that does not answer is left as it is; a later start starts one again. The resident node (--attach) never calls it: its herdr is the user's working set.

type PathStat

type PathStat struct {
	Path string `json:"path"` // as asked
	Kind string `json:"kind"` // with detail also "link": a symlink whose target is not there (LinkBroken)
	Size int64  `json:"size,omitempty"`

	// With detail (the Info sheet, files_info.go): permission bits as chmod takes them, owner and group names (numbers
	// when unknown), the times the system keeps, a folder's item count, and for a symlink what it says, the real path
	// it leads to and whether that is missing. Absent where the platform has no such thing.
	Mode       *int       `json:"mode,omitempty"`
	Owner      string     `json:"owner,omitempty"`
	Group      string     `json:"group,omitempty"`
	ModTime    *time.Time `json:"mtime,omitempty"`
	ChangeTime *time.Time `json:"ctime,omitempty"`
	BirthTime  *time.Time `json:"birthtime,omitempty"`
	Items      *int       `json:"items,omitempty"`
	ItemsMore  bool       `json:"items_more,omitempty"`
	Symlink    bool       `json:"symlink,omitempty"`
	LinkTarget string     `json:"link_target,omitempty"`
	LinkReal   string     `json:"link_real,omitempty"`
	LinkBroken bool       `json:"link_broken,omitempty"`
	Mime       string     `json:"mime,omitempty"` // a regular file's type, as file.read would give it
}

PathStat is whether a path mentioned in a conversation is there on this machine: file, dir, denied (macOS keeps the folder from personad; opening it explains what to do) or missing (also: not resolvable, iCloud Drive).

type Probe

type Probe struct {
	Agent string
	Args  []string
	Env   map[string]string
	File  string
	// Shell is the shell's environment before the launcher ran (what ~/.zshrc exports for everything); nil when it
	// was not seen (a wrapper script read from its text).
	Shell map[string]string
	// Unset are the variables of Shell the agent did not get (`env -u NAME`, `unset NAME` in the launcher), sorted.
	Unset []string
}

Probe is what a launcher would run: the agent, its arguments, the environment it sets. File: the launcher is a file on PATH, which the probe did not run (the stubs cannot reach into it): it is read instead (pathlaunchers.go).

type ResidentFiles

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

func (*ResidentFiles) Close

func (f *ResidentFiles) Close()

func (*ResidentFiles) Exec

func (f *ResidentFiles) Exec(path string, args, env []string) error

type ResidentReload

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

ResidentReload drains work while Attach is still serving. Only the final exec closes existing connections; idle conversations that need the SIGKILL fallback are reaped before that transport gap begins.

func (*ResidentReload) Announce

func (r *ResidentReload) Announce(ctx context.Context) error

func (*ResidentReload) CancelAnnouncement

func (r *ResidentReload) CancelAnnouncement()

func (*ResidentReload) Prepare

func (r *ResidentReload) Prepare(ctx context.Context) error

Prepare never stops an answering conversation or an admitted RPC. Natural idle pauses admission immediately; after the grace it drains admitted RPCs and holds only headless admission for a bounded window so short continuous turns finish without locking out read-only RPCs, session.stop/session.interrupt, or unrelated conversations when a long-running background task or turn blocks reload. A pre-transfer headless pause stays in force until the manager clears it.

func (*ResidentReload) Preparing

func (r *ResidentReload) Preparing() bool

Preparing reports whether Prepare is currently waiting to drain and restart the resident node.

func (*ResidentReload) ReportUpdateDraining

func (r *ResidentReload) ReportUpdateDraining(ctx context.Context, id, target string)

ReportUpdateDraining records draining state and notifies connected peers without stalling the reload worker.

func (*ResidentReload) ReportUpdatePreflightFailure

func (r *ResidentReload) ReportUpdatePreflightFailure(ctx context.Context, id string, err error)

ReportUpdatePreflightFailure lets the manager stop waiting for a replacement while the current node keeps serving.

func (*ResidentReload) Resume

func (r *ResidentReload) Resume()

func (*ResidentReload) SetGrace

func (r *ResidentReload) SetGrace(grace time.Duration)

SetGrace sets the next Prepare's admission grace. Zero preserves the indefinite natural-idle wait.

func (*ResidentReload) SetHeadlessPaused

func (r *ResidentReload) SetHeadlessPaused(paused bool)

SetHeadlessPaused controls only new external assistant turns. Other RPCs and recovery of an admitted turn continue.

func (*ResidentReload) SetLogger

func (r *ResidentReload) SetLogger(logger *log.Logger)

SetLogger routes reload wait diagnostics to logger instead of the process default logger.

func (*ResidentReload) SetUpdateDraining

func (r *ResidentReload) SetUpdateDraining(id, target string)

SetUpdateDraining records the committed update transaction currently waiting for idle handover, or clears it when id is empty.

func (*ResidentReload) UpdateDraining

func (r *ResidentReload) UpdateDraining() *proto.NodeUpdateDraining

UpdateDraining returns a copy of the active committed update waiting for idle handover, or nil.

type ResidentTransport

type ResidentTransport struct {
	Listener net.Listener
	// contains filtered or unexported fields
}

ResidentTransport owns the attach listener and its run lock independently of a connection's Node. Keeping duplicates through exec leaves the same socket and accept backlog available to reconnecting relays.

func OpenResidentTransport

func OpenResidentTransport() (*ResidentTransport, error)

func (*ResidentTransport) Close

func (t *ResidentTransport) Close()

func (*ResidentTransport) PrepareExec

func (t *ResidentTransport) PrepareExec() (*ResidentFiles, error)

type RuntimeHost

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

RuntimeHost is the runtime socket (runtime.sock, runtimes.go) and the runtimes connected to it. A resident node (`personad node --attach`, attach.go) makes one when it starts and shares it with the Node it makes for each hub connection, so runtimes connect before the hub does and stay connected while it reconnects: their sessions are in the first list the next connection sends, and nothing on the runtime's side notices the gap. A node serving its one connection itself (`--stdio` with no resident node) has one of its own, for that connection (listenRuntimeSocket).

Between hub connections runtimes are still answered: hello (with hub: false), their lists are kept, what they push for the phone is dropped (the hub re-watches from where the phone is when it is back), and an ask answers node_gone so the runtime asks again, with the same id, once a hub is connected. Runtimes are told when the hub comes and goes (runtime.hub), so they do not wait on a phone that cannot answer.

func NewRuntimeHost

func NewRuntimeHost(version, path string) *RuntimeHost

NewRuntimeHost is a runtime socket at path (RuntimeSocketPath when empty) for a resident node; Attach starts it.

func (*RuntimeHost) EnableAutoCompanions

func (rh *RuntimeHost) EnableAutoCompanions()

EnableAutoCompanions turns on automatic supervision of built-in CLI companions (Antigravity `agy` and `opencode`) once Listen runs. Production nodes (`personad node --attach` and `personad node --stdio`) enable this; unit test fixtures leave it off so the host machine's installed CLIs never join synthetic runtime tests.

func (*RuntimeHost) Listen

func (rh *RuntimeHost) Listen(ctx context.Context) error

Listen serves runtimes on the socket until ctx ends, re-creating the socket file if something removes it (an older node shutting down), as the hook socket does. It dials the daemons in daemons.json beside the socket too.

Source Files

Directories

Path Synopsis
Package diskmap is a computer's disk usage map (#14576, docs/server/machine-usage-map.md): the node method machine.storage.usage sizes the disk as a tree the apps draw as a treemap, and the protection rules here decide what the map may offer to move to the trash or hand to an offload provider (machine.storage.check, and again before each trash).
Package diskmap is a computer's disk usage map (#14576, docs/server/machine-usage-map.md): the node method machine.storage.usage sizes the disk as a tree the apps draw as a treemap, and the protection rules here decide what the map may offer to move to the trash or hand to an offload provider (machine.storage.check, and again before each trash).
Package imessageport is how the iMessage connector module reaches the node (docs/architecture/core-and-modules.md "Provider seams"): the node's composition root (internal/modules/all/node) provides the module's handler of the hub's connector.* RPCs, and the node answers them with it.
Package imessageport is how the iMessage connector module reaches the node (docs/architecture/core-and-modules.md "Provider seams"): the node's composition root (internal/modules/all/node) provides the module's handler of the hub's connector.* RPCs, and the node answers them with it.
Package iphoneport is how the phone-extra module reaches the node (docs/architecture/core-and-modules.md "The node's modules"): the built-in program iphone (docs/extensions/iphone-bridge.md), this computer's paired iPhones over the bridge, which the hub asks over plugin.node.call.
Package iphoneport is how the phone-extra module reaches the node (docs/architecture/core-and-modules.md "The node's modules"): the built-in program iphone (docs/extensions/iphone-bridge.md), this computer's paired iPhones over the bridge, which the hub asks over plugin.node.call.
Package larkgateport connects the lark module's node-side gate rules to internal/node without core importing internal/modules/lark (#13404).
Package larkgateport connects the lark module's node-side gate rules to internal/node without core importing internal/modules/lark (#13404).
Package machdiag answers a computer's diagnosis and empties its rebuildable caches (#8037, docs/server/machines.md "Diagnosis and cleanup"): node methods machine.diagnose and machine.cleanup.
Package machdiag answers a computer's diagnosis and empties its rebuildable caches (#8037, docs/server/machines.md "Diagnosis and cleanup"): node methods machine.diagnose and machine.cleanup.
Package screenport is how the screen-share module reaches the node (docs/architecture/core-and-modules.md "The node's modules"): a live screen whose phone asks for a session (#6398) gets one, with its RFB and video channels resumed across the hub's relays and the computer's direct routes.
Package screenport is how the screen-share module reaches the node (docs/architecture/core-and-modules.md "The node's modules"): a live screen whose phone asks for a session (#6398) gets one, with its RFB and video channels resumed across the hub's relays and the computer's direct routes.
Package transcripttail recovers an agent's last words when they fall outside a transcript's quick tail.
Package transcripttail recovers an agent's last words when they fall outside a transcript's quick tail.

Jump to

Keyboard shortcuts

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