Documentation
¶
Index ¶
- Variables
- func CheckTailnet(ctx context.Context) error
- func ConfigureDetached(command *exec.Cmd)
- func ConsoleSize(input, _ *os.File) (int, int, error)
- func EnsureNode(ctx context.Context, home, executable string) error
- func EnsurePrivateDirectory(path string) error
- func FolderIdentity(directory string) (string, error)
- func ForgetRecent(home string, info SessionInfo) error
- func GatewayEnabled(home string) (bool, error)
- func GatewayURL(home string) (string, error)
- func NodeRequest(ctx context.Context, home, method, path string) ([]byte, error)
- func RecordSessionEnvironment(home, id, digest string) error
- func RegisterPresence(home string, info SessionInfo, process *os.Process) (func(), error)
- func RestartWorker(ctx context.Context, home, id, operationID string) error
- func RunTerminal(ctx context.Context, home, id string, input *os.File, output io.Writer) (int, error)
- func RunWorker(ctx context.Context, home string, launch WorkerLaunch, ...) (int, error)
- func ServeGateway(ctx context.Context, options GatewayOptions) error
- func SessionEnvironment(home, id string) (string, error)
- func SetGatewayEnabled(home string, enabled bool) error
- func SignalConsole(uint32) error
- func StartWorker(ctx context.Context, home, executable string, launch WorkerLaunch) (string, error)
- func StopWorker(ctx context.Context, home, id string) error
- func WebAssets() http.Handler
- func WriteSharingConfig(home string, config SharingConfig) error
- type Attachment
- type Gateway
- type GatewayMCP
- type GatewayOptions
- type RecentFolder
- type Replay
- type Session
- func (session *Session) Attach(local bool) (*Attachment, Replay, error)
- func (session *Session) AttachmentError(attachment *Attachment) error
- func (session *Session) Detach(attachment *Attachment)
- func (session *Session) MarkRestarting() error
- func (session *Session) ReleaseControl(attachment *Attachment, epoch uint64) error
- func (session *Session) Resize(attachment *Attachment, epoch uint64, rows, columns uint16) error
- func (session *Session) State() TerminalState
- func (session *Session) Stop(ctx context.Context) error
- func (session *Session) TakeControl(attachment *Attachment) (TerminalState, error)
- func (session *Session) Wait(ctx context.Context) (int, error)
- func (session *Session) WriteInput(attachment *Attachment, epoch uint64, data []byte) error
- type SessionInfo
- type SharingConfig
- type TailnetNode
- type TerminalOutput
- type TerminalState
- type WorkerHTTP
- type WorkerLaunch
- type WorkerRecord
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotOwner = errors.New("terminal input belongs to another attachment") ErrStaleControl = errors.New("terminal control has changed; refresh before sending input") ErrSessionEnded = errors.New("terminal session has ended") ErrSlowObserver = errors.New("terminal observer fell behind; reconnect to recover available history") ErrUnsupportedTerminal = errors.New("terminal sharing is not supported on this platform") )
var ErrGatewayDisabled = errors.New("gateway is stopped; run agentpack gateway start to enable sharing")
Functions ¶
func CheckTailnet ¶
CheckTailnet verifies the machine can use local Tailscale identity services.
func ConfigureDetached ¶
ConfigureDetached isolates workers from the launching terminal's lifetime.
func EnsurePrivateDirectory ¶
EnsurePrivateDirectory protects both newly created and existing directories.
func FolderIdentity ¶
func ForgetRecent ¶
func ForgetRecent(home string, info SessionInfo) error
func GatewayEnabled ¶
func GatewayURL ¶
func RegisterPresence ¶
func RegisterPresence(home string, info SessionInfo, process *os.Process) (func(), error)
RegisterPresence advertises a native-stdio launch without changing its pipes. Its process is owned by the caller; the node only receives public metadata.
func RunTerminal ¶
func RunTerminal(ctx context.Context, home, id string, input *os.File, output io.Writer) (int, error)
RunTerminal attaches directly to the worker, so gateway shutdown cannot interrupt the local terminal. Ctrl+] releases or reclaims input ownership.
func RunWorker ¶
func RunWorker(ctx context.Context, home string, launch WorkerLaunch, ready func(string) error) (int, error)
RunWorker owns a restartable PTY independently of a gateway. ready receives only the non-secret worker ID, which survives supervised child restarts.
func ServeGateway ¶
func ServeGateway(ctx context.Context, options GatewayOptions) error
func SessionEnvironment ¶
SessionEnvironment records only the effective content hash, never configuration or credentials.
func SetGatewayEnabled ¶
func SignalConsole ¶
func StartWorker ¶
func WriteSharingConfig ¶
func WriteSharingConfig(home string, config SharingConfig) error
Types ¶
type Attachment ¶
type GatewayMCP ¶
type GatewayMCP struct {
// contains filtered or unexported fields
}
func NewGatewayMCP ¶
func NewGatewayMCP(gateway *Gateway) (*GatewayMCP, error)
func (*GatewayMCP) Close ¶
func (m *GatewayMCP) Close() error
func (*GatewayMCP) ServeHTTP ¶
func (m *GatewayMCP) ServeHTTP(w http.ResponseWriter, r *http.Request)
type GatewayOptions ¶
type RecentFolder ¶
type RecentFolder struct {
SessionInfo
Available bool `json:"available"`
}
func RecentFolders ¶
func RecentFolders(home string) ([]RecentFolder, error)
Availability is current filesystem state, never a persisted authorization grant.
type Replay ¶
Replay is a byte stream, not a terminal screen snapshot. Offset > 0 means earlier bytes were discarded, including potentially required ANSI state.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session owns a single child and PTY. Gateway handlers only attach to it; closing an attachment never signals the child.
func (*Session) Attach ¶
func (session *Session) Attach(local bool) (*Attachment, Replay, error)
Attach atomically captures history and subscribes to all subsequent bytes. Only the private local transport may identify an attachment as local.
func (*Session) AttachmentError ¶
func (session *Session) AttachmentError(attachment *Attachment) error
func (*Session) Detach ¶
func (session *Session) Detach(attachment *Attachment)
func (*Session) MarkRestarting ¶
MarkRestarting lets attachments distinguish a supervised restart from an exit.
func (*Session) ReleaseControl ¶
func (session *Session) ReleaseControl(attachment *Attachment, epoch uint64) error
func (*Session) Resize ¶
func (session *Session) Resize(attachment *Attachment, epoch uint64, rows, columns uint16) error
func (*Session) State ¶
func (session *Session) State() TerminalState
func (*Session) TakeControl ¶
func (session *Session) TakeControl(attachment *Attachment) (TerminalState, error)
TakeControl never steals a writer lease. The local terminal may explicitly reclaim control; browser attachments must wait for the current owner to release.
func (*Session) WriteInput ¶
func (session *Session) WriteInput(attachment *Attachment, epoch uint64, data []byte) error
type SessionInfo ¶
type SessionInfo struct {
LastUsed time.Time `json:"last_used,omitzero"`
FolderID string `json:"folder_id,omitempty"`
ID string `json:"id"`
Directory string `json:"directory"`
DefinitionRoot string `json:"definition_root,omitempty"`
Harness string `json:"harness"`
Mode string `json:"mode"`
State TerminalState `json:"state"`
}
func Recent ¶
func Recent(home string) ([]SessionInfo, error)
type SharingConfig ¶
SharingConfig contains explicit machine/tag exceptions to personal identity. It does not change Tailscale ACLs or expose anything outside the tailnet.
func ReadSharingConfig ¶
func ReadSharingConfig(home string) (SharingConfig, error)
ReadSharingConfig defaults to sharing on, like Agentnet's tailnet discovery: peers still need your own untagged identity or an explicit allow entry.
type TailnetNode ¶
type TailnetNode struct {
ID string `json:"id"`
Name string `json:"name"`
Address string `json:"-"`
Online bool `json:"online"`
}
func TailnetNodes ¶
func TailnetNodes(ctx context.Context, home string) ([]TailnetNode, error)
TailnetNodes probes only allowed, online peers learned from the local daemon.
type TerminalOutput ¶
type TerminalOutput struct {
Offset uint64 `json:"offset"`
NextOffset uint64 `json:"next_offset"`
Output string `json:"output"`
Truncated bool `json:"truncated"`
State TerminalState `json:"state"`
}
type TerminalState ¶
type TerminalState struct {
Interactive bool `json:"interactive"`
Running bool `json:"running"`
Restarting bool `json:"restarting"`
Owner uint64 `json:"owner"`
Epoch uint64 `json:"epoch"`
Rows uint16 `json:"rows"`
Columns uint16 `json:"columns"`
ExitCode int `json:"exit_code"`
}
TerminalState contains no command arguments, environment, or credentials.
type WorkerHTTP ¶
type WorkerHTTP struct {
// contains filtered or unexported fields
}
func WorkerHandler ¶
func WorkerHandler(session *Session, secret string) (*WorkerHTTP, error)
WorkerHandler is private IPC. The gateway authenticates its own callers, then attaches using this worker's secret. Never expose the secret to browsers.
func (*WorkerHTTP) Restart ¶
func (worker *WorkerHTTP) Restart(ctx context.Context, operationID string) (result error)
Restart keeps the private endpoint stable while the original launch pipeline rebuilds staging and starts a fresh agent. Old attachments receive an ended notice with Restarting=true and reconnect to the new PTY.
func (*WorkerHTTP) ServeHTTP ¶
func (worker *WorkerHTTP) ServeHTTP(w http.ResponseWriter, r *http.Request)
type WorkerLaunch ¶
type WorkerLaunch struct {
Session SessionInfo `json:"session"`
Program string `json:"program"`
Arguments []string `json:"arguments"`
Directory string `json:"directory"`
Environment []string `json:"environment"`
Rows uint16 `json:"rows"`
Columns uint16 `json:"columns"`
}
WorkerLaunch is delivered through a private startup pipe, never HTTP or disk. Launching agentpack itself here keeps staging, auth and cleanup in the CLI.
type WorkerRecord ¶
type WorkerRecord struct {
Session SessionInfo `json:"session"`
ID string `json:"id"`
PID int `json:"pid"`
Address string `json:"address"`
Secret string `json:"secret"`
}
WorkerRecord is private connection material, readable only by the local OS user. Public node listings must use a separate allowlisted session view.