Documentation
¶
Overview ¶
Package daemon is Open Machine's device-side Code integration.
Index ¶
- Constants
- Variables
- func App(pid int, process func(pid int) (parent int, name string, args []string)) string
- func AutoUpdate(ctx context.Context, state string, refused <-chan struct{}, open func() bool, ...)
- func Clean(s string) string
- func CloudTransport(dial func(ctx context.Context, network, addr string) (net.Conn, error), ...) *http.Transport
- func GitCredential(args []string, stdin io.Reader, stdout, stderr io.Writer) int
- func GitHub(args []string, stdout, stderr io.Writer) int
- func Include(home, dir string) error
- func LogDiscarded(dir string)
- func PeerUID(proc []byte, peer, local netip.AddrPort) (uint32, bool)
- func PinnedClient(pin string, timeout time.Duration) *http.Client
- func Probe(addr netip.AddrPort) (web bool, title string, again bool)
- func ProcNet(b []byte) map[string]netip.AddrPort
- func Proxy(state, host string, stdin io.Reader, stdout io.Writer) error
- func ReadApp(r *bufio.Reader) string
- func RedactNetwork(line, home, authKey string) string
- func Run(ctx context.Context, core Core) error
- func SendsScript(line string) bool
- func ServeModels(ch io.ReadWriter, list []Service, forwarded func(port int))
- func Sign(key ed25519.PrivateKey, origin, method, path, challengeID, challenge string, ...) string
- func StateDir(home string) string
- type Authority
- func (a *Authority) Core(v string, policies map[string]string)
- func (a *Authority) Current() *Lease
- func (a *Authority) Devices() []ViewDevice
- func (a *Authority) Joining(reason string)
- func (a *Authority) Listening()
- func (a *Authority) Recheck() error
- func (a *Authority) Refused() <-chan struct{}
- func (a *Authority) Run(ctx context.Context)
- func (a *Authority) Services(list []Service)
- func (a *Authority) Status() string
- func (a *Authority) View() ([]byte, <-chan struct{})
- func (a *Authority) Wait(ctx context.Context) (*Lease, error)
- type Broker
- type CommandRule
- type Core
- type Device
- type Discovery
- type FileRule
- type GitSession
- type Host
- type Identity
- type Lease
- type Listener
- type Local
- type Lock
- type Log
- func (l *Log) Close(reason string, lease *Lease)
- func (l *Log) Enter(lease *Lease, s Source, app string) *Visit
- func (l *Log) Expire(now time.Time)
- func (l *Log) Frame() (*LogFrame, <-chan struct{})
- func (l *Log) Logged(queue string, through int64)
- func (l *Log) Refuse(source, app, reason, message string)
- func (l *Log) Start()
- type LogFrame
- type Model
- type Opener
- type Page
- type Pattern
- type Record
- type Refusal
- type Rules
- type Service
- type Source
- type Stop
- type Target
- type ViewDevice
- type Visit
Constants ¶
const ProofsKey = "openmachineProofs"
ProofsKey names, under credential.<broker>, the directory of Full Access proofs.
Variables ¶
var ( // ErrNoAuthority reports that Cloud grants this device no Code authority. ErrNoAuthority = errors.New("native: this device has no Code authority") // sessions continue, but nothing new is admitted until it can. ErrUnavailable = errors.New("native: Cloud is unavailable; existing Code sessions only") )
var CloudClient = &http.Client{Transport: CloudTransport(nil, nil)}
CloudClient is the client of every request this device makes to Cloud: enrollment, the Code lease and the GitHub broker's proofs. It has no timeout, since a lease's WebSocket lives on; each request bounds itself with its context.
var CoreRead = 10 * time.Minute
CoreRead is how often a Core that answered is asked again; tests shorten it.
var ErrDeviceChanged = errors.New("native: this computer moved to another device")
ErrDeviceChanged ends a daemon whose computer a sign-in moved to another device.
var ErrOffline = errors.New("native: this computer is disconnected from Open Machine")
ErrOffline reports that this computer is offline: Desktop is Disconnected, signed out or cannot be read safely, or the Connector is stopped, revoked or registered otherwise. Offline admits no SSH and closes every SSH connection into or out of this computer.
var ErrUnreachable = errors.New("offline or unreachable")
ErrUnreachable is in dial's error for a machine that is offline.
var HardwareID = func() func(dir string) (string, error) { var mu sync.Mutex ids := map[string]string{} return func(dir string) (string, error) { mu.Lock() defer mu.Unlock() if ids[dir] == "" { read, err := readHardwareID(dir) if err != nil { return "", err } ids[dir] = read } return ids[dir], nil } }()
HardwareID returns this machine's hardware ID: its IOPlatformUUID on macOS; on Linux the file hardware-id in the Connector's state directory dir if it exists, else /etc/machine-id. It is read once per process and directory, retried until read, and never leaves this machine. Tests replace it.
var JoinTimeout = time.Minute
JoinTimeout bounds each start of the network node; tests shorten it.
var MaxDaemonLog int64 = 1 << 20
MaxDaemonLog bounds daemon.log; one earlier file, daemon.log.1, is kept. Tests shorten it.
var StartMove = func(secret string) bool { return startOM("move", secret) }
StartMove starts `om move` as StartUpdate starts an update: the move makes this daemon exit for the device it registers. The move's secret goes to its standard input, never to a command line or the environment. Tests replace it.
var StartUpdate = func() bool { return startOM("update", "") }
StartUpdate starts this binary's `om update` in its own session: the update restarts this daemon and must outlive it. It reports whether it started. Tests replace it.
Functions ¶
func App ¶
App names the app that ran the ssh whose process is pid: the nearest of up to 8 processes, from ssh's parent upward, whose name, or the last path segment of its first or second argument, matches an app; else Terminal. process returns a process's parent, name and arguments.
func AutoUpdate ¶
func AutoUpdate(ctx context.Context, state string, refused <-chan struct{}, open func() bool, start func(), first, daily, every time.Duration)
AutoUpdate asks for updates of a headless installation until ctx ends: after first and then once each daily, and at once when refused receives, Cloud having refused this om as too old, then at most once each every while it does. A request calls start when auto_update in state's headless.json, read then, is on and open reports no SSH connection; while one is open it waits and looks again each every. A Mac has no headless.json, so it never asks.
func Clean ¶
Clean makes a name from a machine's program safe to show: white space collapsed, control and format characters removed, the ends trimmed and at most 40 code points kept.
func CloudTransport ¶
func CloudTransport(dial func(ctx context.Context, network, addr string) (net.Conn, error), roots *x509.CertPool) *http.Transport
CloudTransport dials with Happy Eyeballs, as Go does by default, and, when the connection or its TLS handshake fails, dials once more over IPv4 only. A VPN that tunnels IPv6 without forwarding it accepts the IPv6 TCP connection and then drops it, so Happy Eyeballs picks it and never tries IPv4. Nothing of the request is written before the handshake completes, so the second dial never resends one. Like the Connector, it never takes a proxy from the environment. dial and roots replace the system dialer and certificate roots when not nil.
func GitCredential ¶
GitCredential is om git-credential, a session's only Git credential helper for its broker (gitcredentials(7)). get exchanges the session's capability for one command's credential for the remote's repository; store and erase do nothing, so the credential lives only in git's memory. A refusal stops git from asking anyone else.
func GitHub ¶
GitHub is om github: a session's fixed pull request and CI operations, through its broker and the account's GitHub connection in Cloud. There is no merge, workflow dispatch, release or other call, and no gh or token.
func Include ¶
Include adds one line, an Include of the generated ssh_config in the daemon's state dir, at the top of ~/.ssh/config under home, once: it creates ~/.ssh (0700) and the file (0600) if missing, writes atomically, keeps every other byte and the file's mode, and records in dir that it is done, so it never touches the file again and a user who removes the line keeps it removed. A ~/.ssh/config that is a symbolic link, as dotfile managers make, is left untouched for good; one that is not this user's regular file is an error, tried again with a later lease. Nothing is checked for conflicts or ever undone.
func LogDiscarded ¶
func LogDiscarded(dir string)
LogDiscarded sends the daemon's log to daemon.log in its state directory dir when its standard error is closed or /dev/null, as launchd leaves a Mac's agent, so why it is not connected can be read. A supervisor that keeps the log, as systemd or om's shell kind does, keeps it alone.
func PeerUID ¶
PeerUID finds, in Linux's /proc/net/tcp or tcp6, the socket connected from peer to local, and returns the user that owns it.
func PinnedClient ¶
PinnedClient returns a client that completes a TLS handshake only with a server holding the key pin names, and checks nothing else of its certificate, as Git does with the routing's pinnedPubkey and sslVerify false. It never sends a request in plain text.
func Probe ¶
Probe tells a web page from another program listening at addr. A program that speaks first is not one. Otherwise it sends GET / without a Host line, which Redis closes on, and once more with one after a 403, which Vite 5 and 6 and webpack-dev-server give without it. 3xx, or HTML with 2xx, 401 or 403, is a page; a page's title comes from a 2xx answer, after at most 2 redirects to this port's address. again reports an answer late or with a 5xx, also a redirect's, as from a program still starting. It dials the loopback addresses that reach addr, never a name, which a resolver could send elsewhere: both for any address, as a dual-stack socket may be reachable on either.
func ProcNet ¶
ProcNet reads the sockets in LISTEN state from Linux's /proc/net/tcp or tcp6, by inode.
func Proxy ¶
Proxy is the ProxyCommand: it asks the local daemon, over its owner-only socket, for an SSH stream to host and copies it between stdin and stdout. It starts no network node of its own; stdout carries SSH bytes only. Before ssh's bytes it tells the target which app ran ssh, in a line an older target's SSH server skips.
func ReadApp ¶
ReadApp reads the line a source's om proxy sends before SSH, OM-APP and the app's name, from a reader whose 64-byte buffer bounds it: the name, or "" for a line that is not one. A stream that starts otherwise is left unread.
func RedactNetwork ¶
RedactNetwork removes from a network log line what must not reach a log: what redact hides, the node's registration key, any other key of that form and URL queries; and writes home as ~, so a log can be shared.
func Run ¶
Run runs the daemon of the user whose HOME is core.Home until ctx ends. It waits for the device identity, which sign-in creates, then joins the network once for that device and reuses its node and host key from then on. Its only OS TCP ports are the local entry to machines' web pages and each opened page's own, on 127.0.0.1 and [::1]. Neither a missing identity nor state that needs recovery, which a restart cannot fix, ends it: a supervisor never restarts it in a loop. It returns ErrDeviceChanged when a sign-in moves this computer to another device, also during recovery, so its supervisor starts it again for that device.
func SendsScript ¶
SendsScript reports whether line runs what the connection's input holds: anywhere in it, a pipe's included, a shell given no -c and no file, su given no -c, or one of starts given nothing to run, such as bash -euo pipefail, cd /srv && bash -s or sudo -i.
func ServeModels ¶
func ServeModels(ch io.ReadWriter, list []Service, forwarded func(port int))
ServeModels answers the one HTTP request of a models channel from list, this machine's services: GET /v1/models with their models; an inference POST by passing it to the server of the model its body names, once forwarded is told that server's port, and passing the answer back as it comes. Anything else is {"error":{"message":…}}. Every answer says Connection: close.
Types ¶
type Authority ¶
type Authority struct {
// contains filtered or unexported fields
}
Authority holds this device's Code lease. A new Code admission needs a current lease from a live Cloud session. Losing Cloud, or a lease running out, only stops new admissions: what was admitted keeps running until an applied lease closes it. Each lease runs from when its renewal was sent, so a late reply never extends it, and replies apply in the order sent. A changed lease admits nothing new until it is applied, and is then acknowledged.
Each renewal reports whether this computer can serve Code, Core's version, the modes Core can enforce and the machine's listening programs. Leases also carry the account view, which is held in memory only.
func NewAuthority ¶
func NewAuthority(origin, deviceID string, key ed25519.PrivateKey, d Device, log *Log, client *http.Client) *Authority
NewAuthority returns the Code authority of the device registered under deviceID with key, at the Cloud origin, served by d. It starts log at the first lease of a Cloud that takes it, and sends it over every presence.
func (*Authority) Core ¶
Core records Core's version and the modes it can enforce, renewing at once when either changes. A version that is not 1 to 32 letters, digits, '.', '+' or '-', or policies that are not the three modes' states, are reported as unknown.
func (*Authority) Devices ¶
func (a *Authority) Devices() []ViewDevice
Devices returns the machines of the last lease's view.
func (*Authority) Joining ¶
Joining records why the last step toward listening failed, as a status reason; "" while the next step runs without one.
func (*Authority) Listening ¶
func (a *Authority) Listening()
Listening records that the SSH host listens on the private network.
func (*Authority) Recheck ¶
Recheck reads the device's Admission, renews at once when that changes whether this computer can serve Code, and returns it.
func (*Authority) Refused ¶
func (a *Authority) Refused() <-chan struct{}
Refused receives after each connection attempt Cloud refused as too old.
func (*Authority) Services ¶
Services records this machine's listening programs, renewing at once when they change.
func (*Authority) Status ¶
Status reports whether this computer is connected to Open Machine Code: "" when it is, else the first reason it is not: offline; joining, or while the network is not joined why the last step failed (see joinReason); update_required (Cloud refused this om as too old); cloud_unavailable or no_authority.
func (*Authority) View ¶
View returns the account view as one JSON line and a channel closed when it may have changed. Without a session that holds a lease the last values stay, and every device's state is unknown.
type Broker ¶
type Broker struct {
URL string // https://127.0.0.1:PORT
Pin string // sha256//BASE64 of its key, Git's http.pinnedPubkey form
// contains filtered or unexported fields
}
Broker is the target's Code GitHub broker: a loopback endpoint for the Git commands and om github calls of admitted SSH sessions, never the daemon's management socket. A session holds a capability in its environment; om git-credential exchanges it for one command's credential, for one repository and the actions the session's policy allows there. Cloud adds the account's token: neither the broker nor the session ever holds one.
A restricted sandbox can read other processes' environments (kern.procargs2), which Seatbelt cannot deny. So a Full Access session's capability, the only one that writes, also needs a proof the broker keeps in a file named after it under proofs, in the daemon's state, which Core denies to restricted work. om reads it there, outside any sandbox, from the directory its own routing names, never from a reply: whatever answers at the broker's port gets nothing else.
Any local process, a restricted sandbox too, may listen on the port a stopped broker freed, where detached jobs' routing still points. So the broker serves TLS with a key made in memory each time it starts, never stored, and every client pins it: Git through its routing, om by the same routing. Whatever else answers there, a later broker too, fails the handshake before a request is sent, and Git fails closed.
func NewBroker ¶
func NewBroker(origin, deviceID string, key ed25519.PrivateKey, client *http.Client, proofs string) (*Broker, error)
NewBroker starts the broker of the device registered under deviceID with key, at the Cloud origin, keeping Full Access sessions' proofs in the owner-only directory proofs, emptied first.
func (*Broker) Environment ¶
Environment is a session's Git routing: process-scoped configuration, never a global or repository edit, that sends github.com remotes over HTTPS or SSH to this broker, with client's git-credential as their only credential helper, the capability it uses and, for om alone (Git ignores the key), where a Full Access session finds its proof.
func (*Broker) Open ¶
func (b *Broker) Open(s GitSession) (string, func())
Open registers an admitted session and returns its capability, and a function that ends the session's GitHub access, called when the session ends.
type CommandRule ¶
type CommandRule struct {
Title string `json:"title"`
Note string `json:"note"`
Match []Pattern `json:"match"`
Paths []string `json:"paths"`
}
CommandRule stops a line one of whose commands its patterns hold, or that touches its paths at the level read.
type Core ¶
type Core struct {
Python string // Core's interpreter
Args []string // optional --config and --state-dir for Core
Home string // HOME for Core, so its control paths cover this daemon's state
}
Core runs Core's access launcher, the one boundary through which Code work starts: Go checks Cloud authority, and Core checks paths and confines the command.
func (Core) Folders ¶
func (c Core) Folders(request []byte) (json.RawMessage, error)
Folders runs Core's Workspace folder check in its own Core process, with request on its stdin, for at most 120 seconds, and returns the JSON object Core writes: the canonical folders or Core's refusal. Anything else, such as more than 64 KiB or a failed launcher, is an error.
type Device ¶
type Device interface {
// Apply closes the connections l no longer permits, with their channels
// and forwards, before it returns; Lease.Target nil closes them all. It
// ends no process: Code is a connection layer.
Apply(l Lease)
// Admission reports whether this computer is online: nil, or why not.
Admission() error
// Folders is this machine's own check of l's Workspace folders, once l is
// applied: nil, or its refusal. It may take as long as Core's check.
Folders(l Lease) *Refusal
// Update starts this machine's own update now, as its owner asked in the
// Console, and reports whether it started.
Update() bool
// Move starts this machine's move to another account of the person who
// asked for it in the Console, with the one-time secret Cloud issued, and
// reports whether it started.
Move(secret string) bool
}
Device is the device side of an Authority.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery remembers each port and process it probed, so each is probed once, or up to 3 times in a row of passes while it answers late or with a 5xx, and reads each model server's list again every pass, as it asks one that is not ready yet.
func (*Discovery) Pass ¶
Pass returns the services of ls, in its order, probing at most 8 new or unsettled ports and processes at once; the others wait for the next pass. Beside them it asks each model server it knows, and each program whose models are still to come, again. Of the models it returns the first 200 whose JSON fits 32 KiB, each id once.
type FileRule ¶
type FileRule struct {
Title string `json:"title"`
Note string `json:"note"`
Level string `json:"level"`
Paths []string `json:"paths"`
}
FileRule stops a line one of whose commands touches its paths at its level, none or read.
type GitSession ¶
type GitSession struct {
Source string
SourceGrantRevision int64
TargetGrant string
TargetGrantRevision int64
PolicyRevision int64
Mode string // read_only, workspace or full_access
Visit string // the session's connection in the log, which Cloud's records of its Git name
Live func() error
Done <-chan struct{}
}
GitSession is what one admitted SSH session may do with GitHub: the binding and policy it was admitted under. Live reports whether it may start new GitHub work; Done closes when its connection ends, which stops its requests in flight.
type Host ¶
type Host struct {
DeviceID string `json:"device_id"`
NodeKey string `json:"node_key"`
Key string `json:"key"` // OpenSSH public key
User string `json:"user"` // the OS user that runs Open Machine there
Aliases []string `json:"aliases"` // the first is canonical
}
Host is a device this one may connect to, at its registered SSH host.
type Identity ¶
type Identity struct {
Origin, DeviceID, PrincipalID string
Key ed25519.PrivateKey
// contains filtered or unexported fields
}
Identity is this device's registration, owned by the Python Connector. Code only reads it: a missing or unsafe identity means sign-in or recovery is needed, never a new enrollment.
func ReadIdentity ¶
ReadIdentity reads the device in use in the Connector's state directory: its binding and the 32-byte Ed25519 seed of the key file it names, which must be that key and bound to this machine. Anything else means this computer is not ready: it has yet to sign in.
type Lease ¶
type Lease struct {
Epoch int64 `json:"epoch"` // the Code presence it was issued to
Revision string `json:"revision"` // identifies Target, Sources and Hosts
Target *Target `json:"target"` // nil: the device has no Code authority, and all its Code connections close
Sources []Source `json:"sources"` // the devices that may connect to this one
Hosts []Host `json:"hosts"` // the devices this one may connect to
}
Lease is this device's Code authority from Cloud.
type Listener ¶
type Listener struct {
Addr netip.AddrPort
PID int
Name string
Exe string // its executable, read on macOS only
}
Listener is a TCP socket the OS lists in LISTEN state, with the process holding it: PID 0 and no name when that is unreadable.
func Listed ¶
Listed returns the listeners a pass lists, one per port by its lowest PID, the lowest 64 ports: those bound where localhost reaches them, other than om's own, Apple's programs, ports below 1024 but 80 and 443, and the OS's ephemeral range from first to last, where editors' and kernels' random ports live.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is this computer's entry to the web pages on the machines it reaches. http://localhost:<entry>/<alias>/<port> gives the page a port of its own on this computer and sends the browser there: http://127.0.0.1:<that port>/ is localhost:<port> on that machine, through one OM SSH connection for each page, once the person has confirmed the page in this browser. Of the names that reach this computer, only localhost and its addresses are ones no browser sends to a system proxy, so pages differ by port; 127.0.0.1 keeps their cookies apart from this computer's own programs at localhost. At the entry's port it is also the one address of the AI models this computer reaches, through one OM SSH connection for each machine.
type Lock ¶
type Lock struct {
Title string `json:"title"`
Note string `json:"note"`
Allow [][]string `json:"allow"`
}
Lock runs only the commands that begin with an allowed one.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is a machine's own record of who connected to it and what they ran: signed lines in a queue on disk, each named by its place, sent to Cloud and deleted once Cloud has them. It records nothing until it is started.
func OpenLog ¶
func OpenLog(dir, device string, key ed25519.PrivateKey) *Log
OpenLog returns the log of device kept in dir. A queue made by an earlier run records and sends at once.
func (*Log) Close ¶
Close ends, for reason, each connected connection that lease no longer permits: every one when lease is nil, as the machine goes offline.
func (*Log) Enter ¶
Enter records a transport from source s through app, admitted under lease: it joins that source and app's open connection, after ending one admitted under another binding, or opens one. The first admitted transport of a connection is its connect. A source limited to the AI models connects with that access, in no folder, whatever the machine's mode.
func (*Log) Expire ¶
Expire ends each connection that has had no transport for the 10 minutes before now.
func (*Log) Frame ¶
Frame returns the frame to send next, from the first place Cloud has not confirmed, or nil when it has them all, and a channel closed when a record is written or Cloud confirms one.
func (*Log) Logged ¶
Logged takes Cloud's confirmation of every place of queue through n, and deletes each file it covers but the one appended to.
type LogFrame ¶
type LogFrame struct {
Type string `json:"type"` // log
Queue string `json:"queue"`
From int64 `json:"from"`
Records []json.RawMessage `json:"records"`
}
LogFrame is the records a machine sends next: the queue's lines from the place From, each as stored, or null for one that is no record.
type Opener ¶
type Opener interface {
// Lease returns the lease new work starts under, once this computer has
// joined the private network, or why it is not ready.
Lease() (*Lease, error)
// Devices returns the machines of the last lease's view.
Devices() []ViewDevice
// Dial opens an OM SSH stream to the machine alias names, for app, that
// going offline closes. ErrUnreachable reports a machine that is offline.
Dial(alias, app string) (net.Conn, error)
// Services returns this computer's listening programs, with their models.
Services() []Service
// Key returns the 32-byte key the cookies of confirmed pages are made with.
Key() ([]byte, error)
// Pages returns the pages given a port on this computer, the one opened
// last first, as SavePages last kept them.
Pages() ([]Page, error)
SavePages([]Page) error
}
Opener is the daemon side of a Local: this computer's lease, its view of the account's machines and the OM SSH streams out of it.
type Pattern ¶
type Pattern struct {
W [][]string `json:"w"` // tokens, each a list of alternatives
Into []string `json:"into"` // when not nil, what the command's output goes into matches one
Not bool `json:"not"` // an exception
}
Pattern holds a command whose name matches its first token and whose words match each other one.
type Record ¶
type Record struct {
Queue string `json:"queue"`
N int64 `json:"n"`
At string `json:"at"`
Type string `json:"type"` // connect, disconnect, refuse, start, end, block, forward or boot
Device string `json:"device"`
Visit string `json:"visit,omitempty"`
Source string `json:"source,omitempty"`
Session string `json:"session,omitempty"`
App string `json:"app,omitempty"`
Access string `json:"access,omitempty"`
Folder string `json:"folder,omitempty"`
Grant int64 `json:"grant,omitempty"`
SourceGrant int64 `json:"source_grant,omitempty"`
Policy int64 `json:"policy,omitempty"`
Reason string `json:"reason,omitempty"`
Last string `json:"last,omitempty"`
Stage string `json:"stage,omitempty"`
Message string `json:"message,omitempty"`
Kind string `json:"kind,omitempty"`
Terminal int `json:"terminal,omitempty"`
Command string `json:"command,omitempty"` // only where the account records commands
Script string `json:"script,omitempty"` // as Command
Cut int `json:"cut,omitempty"`
Exit *int `json:"exit,omitempty"`
Signal string `json:"signal,omitempty"`
Error string `json:"error,omitempty"`
Rule string `json:"rule,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Version string `json:"version,omitempty"`
Sig string `json:"sig"`
}
Record is one record of a machine's log: its fields in the order they are signed, the absent ones left out.
type Refusal ¶
Refusal is a machine's refusal of the Workspace folder at Index of its lease, with Core's code.
type Rules ¶
type Rules struct {
Head string `json:"head"` // Blocked by Open Machine on <machine>
Foot string `json:"foot"` // who can change the rules
Commands []CommandRule `json:"commands"`
Files []FileRule `json:"files"`
Writes []Pattern `json:"writes"` // the commands that change the files they name
Uses []Pattern `json:"uses"` // those that may name a No access file
Copies []string `json:"copies"` // those that change only the last file they name
Lock *Lock `json:"lock"` // nil unless only listed commands run
}
Rules are what the target's account blocks on it. om checks every new session against them before Core runs it.
type Service ¶
type Service struct {
Port int `json:"port"`
Name string `json:"name"`
Web bool `json:"web"`
Models []Model `json:"models,omitzero"`
Addr netip.AddrPort `json:"-"` // where it listens: what a request for one of its models dials
}
Service is one program listening on this machine, as renewals report it: a model server with its models, which may be none.
type Source ¶
type Source struct {
DeviceID string `json:"device_id"`
NodeKey string `json:"node_key"`
GrantRevision int64 `json:"grant_revision"`
Allow []string `json:"allow"` // what it gets besides its sessions: github, their GitHub routing; models, this machine's AI models
Limit string `json:"limit,omitempty"` // read_only: its sessions run Read only, whatever the target's policy; models: it gets the AI models only
Home string `json:"home,omitempty"` // the key of its owner's sandbox home here, for Core; "" for the machine's own
}
Source is a device that may connect to this one. Its Code connections admitted under another grant revision or limit close, as do those of a source no longer listed.
type Stop ¶
type Stop struct {
Rule string // the title of the rule or the lock; "" for a line not checked
Lock bool
Message string // the lines its stderr gets
}
Stop is what stops a session: a rule, the lock, or a line too long or too nested to check.
type Target ¶
type Target struct {
GrantID string `json:"grant_id"`
GrantRevision int64 `json:"grant_revision"`
Policy json.RawMessage `json:"policy"` // Cloud's device policy, or null when unreadable
Rules *Rules `json:"rules"` // what the account blocks here; nil from a Cloud without rules
// Record is null, or {"notice": …} where the account records the commands
// run here; a Cloud without logs sends none.
Record json.RawMessage `json:"record,omitempty"`
}
Target is this device's own authority. Code connections admitted under another grant revision or policy close; a change of Rules closes nothing, and the next session is checked under the lease current then.
type ViewDevice ¶
type ViewDevice struct {
DeviceID string `json:"device_id"`
Name string `json:"name"`
Mode *string `json:"mode"`
Alias *string `json:"alias"` // its display alias, else its canonical one, else nil
State string `json:"state"`
LastSeenAt *int64 `json:"last_seen_at"`
CoreVersion *string `json:"core_version"`
Team *struct {
Slug string `json:"slug"`
Name string `json:"name"`
} `json:"team,omitempty"` // of a team's machine
}
ViewDevice is a device as the account view lists it: one of the account, or a team's machine this device's owner reaches. It is display data: nothing is admitted or closed by it.
type Visit ¶
type Visit struct {
// contains filtered or unexported fields
}
Visit is one open connection: one source's app on this machine, from its first transport until it has had none for 10 minutes, or a lease or going offline ends it. A nil Visit records nothing.
func (*Visit) Notice ¶
Notice returns what a session of kind is told before it runs, where the account records commands and tells people so with text: each shell, and an exec once for each text. SFTP runs no command.