agentlink

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConnectionInfo added in v0.23.0

func GetConnectionInfo() (server, token string, err error)

func GetSpaceId added in v0.25.0

func GetSpaceId() (string, error)

func IsAgentRunning added in v0.21.0

func IsAgentRunning() bool

func NewScriptLogger added in v0.28.0

func NewScriptLogger(service string) logger.Logger

NewScriptLogger returns the appropriate logger for an interactive CLI sub-process running inside a space: an UplinkLogger (with stderr fallback) when the agent daemon is reachable, otherwise a plain stderr logger for standalone use.

func NewUplinkLogger added in v0.28.0

func NewUplinkLogger(service string) logger.Logger

NewUplinkLogger returns a logger that streams to the agent daemon. Callers should generally use NewScriptLogger, which falls back to a plain stderr logger when no agent is running.

func SendWithResponseMsg

func SendWithResponseMsg(commandType CommandType, payload interface{}, response interface{}) error

func SetMethodsScriptRunner added in v0.28.0

func SetMethodsScriptRunner(fn func(content string, args []string) error)

SetMethodsScriptRunner installs the daemon-side script runner used by handleRegisterMethodsScript. The agent daemon calls this at startup with a closure that creates a scriptling env, wires knot.methods.SetMethodsRegistrar to agentClient.RegisterMethods, and evaluates the supplied script content.

func StartCommandSocket

func StartCommandSocket(agentClientObj *agent_client.AgentClient) chan struct{}

func StopCommandSocket

func StopCommandSocket()

Types

type CommandMsg

type CommandMsg struct {
	Command CommandType `msgpack:"c"`
	Payload []byte      `msgpack:"p"`
}

func (*CommandMsg) Unmarshal

func (c *CommandMsg) Unmarshal(v interface{}) error

type CommandType

type CommandType int
const (
	CommandNil CommandType = iota
	CommandConnect
	CommandSpaceNote
	CommandSpaceSetField
	CommandSpaceGetField
	CommandSpaceStop
	CommandSpaceRestart
	CommandForwardPort
	CommandListPortForwards
	CommandStopPortForward
	CommandRegisterMethods
	CommandRegisterMethodsTOML
	CommandRegisterMethodsScript
	CommandUnregisterMethods
	CommandLog
	CommandStartTunnel
	CommandStopTunnel
	CommandListTunnels
	CommandThrottlePort
)

type ConnectResponse

type ConnectResponse struct {
	Success bool   `msgpack:"s"`
	Server  string `msgpack:"sv"`
	Token   string `msgpack:"t"`
	SpaceID string `msgpack:"sid"`
}

type ForwardPortRequest added in v0.22.0

type ForwardPortRequest struct {
	LocalPort  uint16 `json:"local_port" msgpack:"local_port"`
	Space      string `json:"space" msgpack:"space"`
	RemotePort uint16 `json:"remote_port" msgpack:"remote_port"`
	Persistent bool   `json:"persistent" msgpack:"persistent"`
	Force      bool   `json:"force" msgpack:"force"`
}

type ListPortForwardsResponse added in v0.22.0

type ListPortForwardsResponse struct {
	Forwards []PortForwardInfo `json:"forwards" msgpack:"forwards"`
}

type ListTunnelsResponse added in v0.29.0

type ListTunnelsResponse struct {
	Tunnels []TunnelInfo `json:"tunnels" msgpack:"tunnels"`
}

type LogRequest added in v0.28.0

type LogRequest struct {
	Service string `json:"service" msgpack:"service"`
	Level   byte   `json:"level" msgpack:"level"`
	Message string `json:"message" msgpack:"message"`
}

LogRequest carries a single log line from a CLI sub-process (e.g. `knot run-script`) to the agent daemon, which forwards it upstream via the agent client's log channel. Level is a msg.LogLevel byte value.

type PortForwardInfo added in v0.22.0

type PortForwardInfo struct {
	LocalPort   uint16 `json:"local_port" msgpack:"local_port"`
	Space       string `json:"space" msgpack:"space"`
	RemotePort  uint16 `json:"remote_port" msgpack:"remote_port"`
	Persistent  bool   `json:"persistent" msgpack:"persistent"`
	Mode        string `json:"mode" msgpack:"mode"`
	LatencyMs   int    `json:"latency_ms" msgpack:"latency_ms"`
	JitterMs    int    `json:"jitter_ms" msgpack:"jitter_ms"`
	BandwidthKB int    `json:"bandwidth_kb" msgpack:"bandwidth_kb"`
	TimeoutMs   int    `json:"timeout_ms" msgpack:"timeout_ms"`
	Down        bool   `json:"down" msgpack:"down"`
}

type RegisterMethodsFileRequest added in v0.28.0

type RegisterMethodsFileRequest struct {
	Content string   `json:"content" msgpack:"content"`
	Args    []string `json:"args,omitempty" msgpack:"args,omitempty"`
}

RegisterMethodsFileRequest ships a raw file from the CLI to the agent daemon for processing. Content is the file body. Args is optional and only used by the script variant (passed in as sys.argv).

type RegisterMethodsRequest added in v0.28.0

type RegisterMethodsRequest struct {
	Registration methods.Registration `json:"registration" msgpack:"registration"`
}

type RegisterMethodsResponse added in v0.28.0

type RegisterMethodsResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error,omitempty" msgpack:"error,omitempty"`
}

type RunCommandRequest added in v0.19.0

type RunCommandRequest struct {
	Command string `json:"command" msgpack:"command"`
	Timeout int    `json:"timeout" msgpack:"timeout"`
	Workdir string `json:"workdir" msgpack:"workdir"`
}

type RunCommandResponse added in v0.19.0

type RunCommandResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error" msgpack:"error"`
}

type SpaceFieldRequest added in v0.21.5

type SpaceFieldRequest struct {
	Name  string `json:"name" msgpack:"name"`
	Value string `json:"value" msgpack:"value"`
}

type SpaceGetFieldRequest added in v0.21.5

type SpaceGetFieldRequest struct {
	Name string `json:"name" msgpack:"name"`
}

type SpaceGetFieldResponse added in v0.21.5

type SpaceGetFieldResponse struct {
	Value string `json:"value" msgpack:"value"`
}

type SpaceNoteRequest

type SpaceNoteRequest struct {
	Note string `json:"note" msgpack:"note"`
}

type StartTunnelRequest added in v0.29.0

type StartTunnelRequest struct {
	Protocol      string `json:"protocol" msgpack:"protocol"`
	Port          uint16 `json:"port" msgpack:"port"`
	Name          string `json:"name" msgpack:"name"`
	TlsName       string `json:"tls_name,omitempty" msgpack:"tls_name,omitempty"`
	TlsSkipVerify bool   `json:"tls_skip_verify,omitempty" msgpack:"tls_skip_verify,omitempty"`
}

type StartTunnelResponse added in v0.29.0

type StartTunnelResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error,omitempty" msgpack:"error,omitempty"`
	URL     string `json:"url,omitempty" msgpack:"url,omitempty"`
}

type StopPortForwardRequest added in v0.22.0

type StopPortForwardRequest struct {
	LocalPort uint16 `json:"local_port" msgpack:"local_port"`
}

type StopTunnelRequest added in v0.29.0

type StopTunnelRequest struct {
	Name string `json:"name" msgpack:"name"`
}

type ThrottlePortRequest added in v0.31.0

type ThrottlePortRequest struct {
	LocalPort   uint16 `json:"local_port" msgpack:"local_port"`
	LatencyMs   int    `json:"latency_ms" msgpack:"latency_ms"`
	JitterMs    int    `json:"jitter_ms" msgpack:"jitter_ms"`
	BandwidthKB int    `json:"bandwidth_kb" msgpack:"bandwidth_kb"`
	TimeoutMs   int    `json:"timeout_ms" msgpack:"timeout_ms"`
	Down        bool   `json:"down" msgpack:"down"`
	Reset       bool   `json:"reset" msgpack:"reset"`
}

type TunnelInfo added in v0.29.0

type TunnelInfo struct {
	Port     uint16 `json:"port" msgpack:"port"`
	Protocol string `json:"protocol" msgpack:"protocol"`
	Name     string `json:"name" msgpack:"name"`
	URL      string `json:"url" msgpack:"url"`
}

type UplinkLogger added in v0.28.0

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

UplinkLogger is a logger.Logger that forwards log lines from a CLI sub-process (e.g. `knot run-script`) to the agent daemon over the command socket; the daemon then ships them upstream to the knot server via the agent client's log channel. If the uplink is unavailable, lines are written to stderr so logs are never silently lost.

func (*UplinkLogger) Debug added in v0.28.0

func (l *UplinkLogger) Debug(message string, keysAndValues ...any)

func (*UplinkLogger) Error added in v0.28.0

func (l *UplinkLogger) Error(message string, keysAndValues ...any)

func (*UplinkLogger) Fatal added in v0.28.0

func (l *UplinkLogger) Fatal(message string, keysAndValues ...any)

func (*UplinkLogger) Info added in v0.28.0

func (l *UplinkLogger) Info(message string, keysAndValues ...any)

func (*UplinkLogger) Trace added in v0.28.0

func (l *UplinkLogger) Trace(message string, keysAndValues ...any)

func (*UplinkLogger) Warn added in v0.28.0

func (l *UplinkLogger) Warn(message string, keysAndValues ...any)

func (*UplinkLogger) With added in v0.28.0

func (l *UplinkLogger) With(key string, value any) logger.Logger

func (*UplinkLogger) WithError added in v0.28.0

func (l *UplinkLogger) WithError(err error) logger.Logger

func (*UplinkLogger) WithGroup added in v0.28.0

func (l *UplinkLogger) WithGroup(group string) logger.Logger

Jump to

Keyboard shortcuts

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