Documentation
¶
Overview ¶
Package terminal 实现 RelayMesh 的 Web 终端 Hub: 接收主机上常驻 Agent 的通用入口连接,管理「发现 → 启用 → 备注」流程,并把浏览器与 Agent 上的持久化 PTY 会话连接起来。
安全模型的三道闸门(任何一道不满足,终端功能对外完全不可达):
- 总闸(gate.go):已设置 Web 密码 ∧ JWT 签名密钥强度合格 ∧ 未被 RELAYMESH_TERMINAL=off 强制关闭;
- 人类身份:终端 REST / WebSocket 只接受登录 JWT,MCP 凭据一律不被接受;
- 解锁令牌:启用主机、开会话、发票据、终止会话等高危操作需要再次输入密码换取短期令牌。
Index ¶
- Constants
- Variables
- func ClassifyLauncherExec(command string) (string, error)
- func FindGuardPresetByWorkflow(launchers []store.TerminalLauncher, workflowID string) *store.TerminalLauncher
- func HostDisplayName(r model.TerminalHost) string
- func ParseAutoResumeBackoff(raw string) []time.Duration
- func ResolveDiscovery(raw string) (always bool, warning string)
- func ResolveExec(raw string) (on bool, warning string)
- func ResolveFiles(raw string) (on bool, warning string)
- func ResolveRecord(raw string) (off bool, warning string)
- type AgentOpenError
- type AgentPresetLastRun
- type AgentPresetView
- type AgentRunActor
- type AgentRunError
- type AgentRunLimits
- type AgentRunLimitsView
- type AgentRunResult
- type AgentStateEvent
- type Authenticator
- type AutoCheckView
- type AutoGrantView
- type AutoResumeEvent
- type AutoResumeView
- type CredentialSource
- type Decision
- type DiscoveryView
- type ErrGatewayInUse
- type ExecService
- func (s *ExecService) ActiveOnHost(machine string) int
- func (s *ExecService) Approve(ctx context.Context, runID, actor, ip string) (*model.TerminalRun, error)
- func (s *ExecService) CancelByHuman(ctx context.Context, runID, actor, ip string) (*model.TerminalRun, error)
- func (s *ExecService) Exec(ctx context.Context, c termexec.Caller, req termexec.ExecRequest) (any, error)
- func (s *ExecService) Files(ctx context.Context, c termexec.Caller, req termexec.FileRequest) (any, error)
- func (s *ExecService) MCPCredentialChanged(ctx context.Context, id uint, reason string)
- func (s *ExecService) ModelSettings(ctx context.Context, machine string, upd store.HostModelUpdate, ...) (*model.TerminalHost, error)
- func (s *ExecService) ReadOutput(ctx context.Context, runID, stream string, off uint64, limit int) (*RunPage, string, error)
- func (s *ExecService) Reject(ctx context.Context, runID, actor, ip string) (*model.TerminalRun, error)
- func (s *ExecService) Run(ctx context.Context, c termexec.Caller, req termexec.RunRequest) (any, error)
- func (s *ExecService) SetPaused(ctx context.Context, scope, machine string, paused bool, actor, ip string) error
- func (s *ExecService) Status(ctx context.Context) ExecStatus
- func (s *ExecService) Targets(ctx context.Context, c termexec.Caller, target string) (any, error)
- func (s *ExecService) Threads(ctx context.Context, f store.ThreadFilter) ([]ThreadView, error)
- type ExecStatus
- type FileService
- type FileSlice
- type Gate
- type GuardAlert
- type GuardHeadlessView
- type GuardItem
- type GuardOpenWork
- type GuardState
- type GuardVerdict
- type GuardView
- type GuardWakePlan
- type GuardWakeView
- type HolderView
- type HostView
- type Hub
- func (h *Hub) AgentPresetStatus(ctx context.Context, actor AgentRunActor, ref string) (*AgentPresetView, error)
- func (h *Hub) AgentPresets(ctx context.Context, actor AgentRunActor) ([]AgentPresetView, error)
- func (h *Hub) AgentRunLimitsView() AgentRunLimitsView
- func (h *Hub) AgentRunPreset(ctx context.Context, actor AgentRunActor, ref string) (*AgentRunResult, error)
- func (h *Hub) CredentialRevealed(actor, ip, result, detail string)
- func (h *Hub) CredentialsChanged(actor, ip string)
- func (h *Hub) Enabled(ctx context.Context) bool
- func (h *Hub) Exec() *ExecService
- func (h *Hub) Executor() termexec.Executor
- func (h *Hub) Files() *FileService
- func (h *Hub) FilesScopeChanged(actor, ip, result, detail string)
- func (h *Hub) GuardView(ctx context.Context) (GuardView, error)
- func (h *Hub) MCPCredentialChanged(id uint, reason string)
- func (h *Hub) Mount(engine *gin.Engine)
- func (h *Hub) RecordOAuthAudit(event, result, detail string)
- func (h *Hub) RequireFreshUnlock(c *gin.Context, subject string) bool
- func (h *Hub) RequireUnlock(c *gin.Context) bool
- func (h *Hub) SSHAdd(ctx context.Context, req SSHAddRequest, actor, ip string) (*HostView, *store.HostGrantResult, error)
- func (h *Hub) SSHProbe(ctx context.Context, address, actor, ip string) (*SSHProbeResult, error)
- func (h *Hub) SSHProbeHost(ctx context.Context, code, actor, ip string) (*SSHProbeResult, error)
- func (h *Hub) SSHProbeVia(ctx context.Context, address, gateway, actor, ip string) (*SSHProbeResult, error)
- func (h *Hub) SSHRekey(ctx context.Context, code, fingerprint, actor, ip string) (*HostView, error)
- func (h *Hub) SSHTest(ctx context.Context, code, actor, ip string) (*SSHTestResult, error)
- func (h *Hub) SSHUpdateConn(ctx context.Context, code string, req SSHConnUpdateRequest, actor, ip string) (*HostView, error)
- func (h *Hub) SetAgentStateHook(fn func(AgentStateEvent))
- func (h *Hub) SetAutoResumeHook(fn func(AutoResumeEvent))
- func (h *Hub) SetFreshUnlockWindow(d time.Duration)
- func (h *Hub) SetGuardHook(fn func(GuardAlert))
- func (h *Hub) SetGuardWakePermit(ctx context.Context, presetID string, permit int, by, note string) (*store.GuardWakePermitState, error)
- func (h *Hub) SetHTTPSPort(port int)
- func (h *Hub) SetRunEndHook(fn func(RunEndEvent))
- func (h *Hub) SetScreenHook(fn func(ScreenEvent))
- func (h *Hub) SetTLSPin(pin string)
- func (h *Hub) SetTLSSPKI(pin string)
- func (h *Hub) SetWakeHook(fn func(workflowID string))
- func (h *Hub) Shutdown(ctx context.Context)
- func (h *Hub) Start()
- type InstallStatus
- type LauncherOtherRun
- type LauncherRunPlan
- type LauncherRunView
- type Limiter
- type Mode
- type Options
- type PendingView
- type PrefsLimits
- type PrefsView
- type Reason
- type RecordLinesCoverage
- type RecordPage
- type RetentionView
- type RunEndEvent
- type RunExit
- type RunExitClass
- type RunFailureView
- type RunPage
- type SSHAddRequest
- type SSHConnUpdateRequest
- type SSHError
- type SSHProbeResult
- type SSHStatus
- type SSHTestResult
- type SSHView
- type ScreenEvent
- type SessionEnablePreset
- type SessionEnablePreview
- type SessionLauncherSuggest
- type SessionLauncherView
- type SessionLaunchersView
- type SessionRunHost
- type SessionRunIssue
- type SessionRunPreview
- type ThreadView
- type UninstallOutcome
- type UpgradeJobView
- type UpgradeWindowView
- type WebUpgradeSessions
Constants ¶
const ( EvGateDenied = "gate_denied" // 总闸关闭时有人访问终端接口 EvGateChanged = "gate_changed" // 总闸状态翻转 EvUnlockOK = "unlock_ok" // 解锁成功 EvUnlockFail = "unlock_fail" // 解锁失败(密码错误) EvUnlockLocked = "unlock_locked" // 解锁尝试过多被临时锁定 EvLock = "lock" // 主动上锁 EvDiscoveryOpen = "discovery_open" // 打开发现窗口 EvDiscoveryClose = "discovery_close" // 关闭发现窗口(手动或到期) EvUpgradeWindow = "upgrade_window" // 某台主机的 Agent 升级窗口:开启 / 延时 / 结束 / 到期 / 检测到升级后自动关闭(详情里说明) EvWebUpgrade = "agent_web_upgrade" // 管理员在 Web 上请某台主机的 Agent 自己升级:请求 / 交接 / 完成 / 失败(详情里说明,含目标版本与确认过的会话数) EvHostPending = "host_pending" // 出现新的待启用主机 EvHostEnabled = "host_enabled" // 启用主机 EvHostIgnored = "host_ignored" // 忽略主机 EvHostUnignored = "host_unignored" // 取消忽略 EvHostDisabled = "host_disabled" // 停用主机 EvHostDeleted = "host_deleted" // 删除主机 EvHostRemark = "host_remark" // 修改备注 EvAgentConnected = "agent_connected" // 已启用主机的 Agent 上线 EvAgentHandshakeBad = "agent_handshake_bad" // Agent 握手失败(签名 / 版本 / 格式) EvSessionOpen = "session_open" // 新建会话 EvSessionKill = "session_kill" // 终止会话 EvSessionAttach = "session_attach" // 浏览器附着会话 EvSessionDetach = "session_detach" // 浏览器断开会话 EvHolderState = "holder_state" // 主机上的会话守护进程可用性变化 EvSessionsLost = "sessions_lost" // 守护进程重启后报告:有会话已不存在(含原因) EvRecordRead = "record_read" // 人类查看了某个会话在主机上的记录(只记录谁看了哪个会话,不含内容) EvRecordDownload = "record_download" // 人类下载了某个会话的记录 EvRecordPolicy = "record_policy" // 修改主机的录制策略 EvLifecycle = "lifecycle_changed" // 修改主机默认或某个会话的生命周期(永久保持 / 空闲回收) EvLauncherSave = "launcher_save" // 新建或修改了终端启动预设(只记预设编号与主机,不含命令内容——命令里可能带令牌) EvLauncherDelete = "launcher_delete" // 删除了终端启动预设 EvGuardWake = "guard_wake" // 人类点了「唤醒」:让浏览器把一句提示词输入到预设的会话里(或重新拉起它);只记预设编号、方式与第几次,不含提示词与命令 EvGuardPermit = "guard_permit" // 唤醒许可切换:只记预设编号、permit 值与 by,不含备注 EvLauncherRun = "launcher_run" // 人类点了「非交互续聊」预设的「运行」:只记预设编号与权限姿态(运行编号在 run_id 里),不含提示词与命令 EvLauncherAutoRun = "launcher_auto_run" // 系统按预设里打开的「异常退出时自动续跑」发起了一次运行(#151):只记预设编号与第几次(运行编号在 run_id 里),不含提示词与命令 EvLauncherAutoStop = "launcher_auto_stop" // 人类取消了一次排期中的自动续跑(#151):只记预设编号(出事的运行编号在 run_id 里) EvLauncherAgentRun = "launcher_agent_run" // 项目管理 Agent 经 MCP 运行了一条预设(#179):只记谁(身份编号)、预设编号、目标工作流与权限姿态(运行编号在 run_id 里),不含提示词与命令;被拒绝的尝试记成 deny / fail EvSessionEnable = "session_enable" // 人类在「待接入」会话页点了「启用 Agent」(#176):只记工作流、预设编号、权限姿态与是否新开对话(运行编号在 run_id 里),不含提示词与命令 EvSessionRun = "session_run" // 人类经 session-run 接口发起了会话页运行(#128;Web 从 #140 起改走预设运行 launcher_run,接口保留):只记工作流与权限姿态(运行编号在 run_id 里),不含提示词与命令 EvCredentialsChange = "credentials_changed" // 登录凭据变更,全部终端凭据与连接被撤销 EvCredentialReveal = "credential_reveal" // 人类在设置页重新输入 Web 密码后查看 MCP 令牌(成功 / 密码错误 / 被锁定);只记哪个令牌,绝不含令牌内容 EvFilesScope = "files_scope" // 人类开启 / 关闭了某把令牌的「允许整个文件系统」(或因没有刚刚重新验证密码而被拒);只记哪个令牌与动作 // Agent 自动升级(#142)。只记版本号与原因,不含任何下载地址或票据。 EvAutoUpgradeSwitch = "agent_auto_upgrade_switch" // 管理员打开 / 关闭 Hub 的「Agent 自动升级」总闸(详情里是新状态) // 静默自动升级的生命周期(主机自己发起,所以没有操作人,Actor 是 system): EvAutoUpgradeStart = "agent_auto_upgrade_start" // Hub 批准了一台主机的静默升级请求(版本、升级时有多少运行中的会话 / 模型运行在详情里) EvAutoUpgradeOK = "agent_auto_upgrade_ok" // 升级完成:主机带着新版本重新上线了 EvAutoUpgradeFail = "agent_auto_upgrade_fail" // 升级失败(原因代码与说明在详情里,含发布签名验证失败) EvAutoUpgradeRollback = "agent_auto_upgrade_rollback" // 新版本没有连上服务端,已自动还原成旧版本 // 模型执行(M6)。命令文本与输出从不写入审计,只记录谁在哪台主机上做了什么类型的事。 EvExecStart = "exec_start" // 模型发起一次运行(含需批准模式下提交的请求) EvExecDenied = "exec_denied" // 模型的请求被闸门拒绝 EvExecCancel = "exec_cancel" // 运行被取消(模型 / 人 / 暂停 / 系统) EvExecApprove = "exec_approve" // 人批准了一次待批准的运行 EvExecReject = "exec_reject" // 人拒绝了一次待批准的运行,或批准超时 EvExecPause = "exec_pause" // 暂停模型执行(全局 / 某台主机) EvExecResume = "exec_resume" // 恢复模型执行 EvHostModel = "host_model" // 修改主机的模型访问设置(允许 / 执行模式 / 新模型默认态) EvModelGrant = "model_host_grant" // 把一台主机写入模型令牌的主机名单(新增主机时按默认态授予,或管理员手动「授予现有模型」);只记数量与令牌名 EvRunLost = "run_lost" // 运行结果无法确认(主机重启 / 守护进程消失) EvExecRead = "exec_output_read" // 人类查看了某次运行的完整输出 // SSH 主机(M10)。凭据与私钥从不写入审计,只记录地址、用户、认证方式与主机密钥指纹。 EvSSHProbe = "ssh_probe" // 探测了某个地址的主机密钥指纹(尚未登记) EvSSHAdd = "ssh_host_add" EvSSHTest = "ssh_host_test" EvSSHConn = "ssh_host_conn" // 修改了地址 / 用户 / 凭据 EvSSHRekey = "ssh_host_rekey" // 重新固定了主机密钥(管理员核对了新指纹) // EvSSHCredSync:网关(重新)就绪时 Hub 与它对账了登录凭据;只记主机数、缺失数与被回收数,从不记任何凭据内容。 EvSSHCredSync = "ssh_cred_sync" // OAuth 授权服务器(不含授权码、令牌与验证码)。 EvOAuthConsentGranted = "oauth_consent_granted" EvOAuthConsentDenied = "oauth_consent_denied" EvOAuthTokenIssued = "oauth_token_issued" EvOAuthTokenRefresh = "oauth_token_refresh" EvOAuthRefreshReplay = "oauth_refresh_replay" EvOAuthCodeReplay = "oauth_code_replay" EvOAuthRevoke = "oauth_revoke" EvOAuthClientRegister = "oauth_client_register" EvOAuthPolicyChanged = "oauth_policy_changed" )
审计事件名(稳定的机器可读值)。
const ( ActorHuman = "human" ActorModel = "model" ActorSystem = "system" )
审计操作者类型。
const ( ResultOK = "ok" ResultFail = "fail" ResultDeny = "deny" )
审计结果。
const ( EvFileOp = "file_op" // stat / hash EvFilePull = "file_pull" // 签发了一张拉取票据 EvFileDownload = "file_download" // 票据被使用,文件被下载 EvFilePush = "file_push" // push_url 写入了文件 )
审计事件名(文件内容、票据与网址的查询串从不写入)。
const ( GuardWakeNone = "none" // 现在没法唤醒 GuardWakeType = "type" // 把提示词输入到存活的会话里 GuardWakeRelaunch = "relaunch" // 会话已经结束:新开一个会话,重新拉起智能体并带上提示词 )
唤醒方式。
const ( // OtherRunSessionRun 是旧的会话页运行接口(POST /terminal/session-run)提交的运行:新页面走预设,但旧页面与脚本还在用它。 OtherRunSessionRun = "session_run" // OtherRunWake 是会话守护的「非交互唤醒」提交的运行。 OtherRunWake = "wake" // OtherRunDeletedPreset 是所属预设已经被删除的预设运行。 OtherRunDeletedPreset = "deleted_preset" )
「其他非交互运行」的来源:Hub 自己提交的非交互运行里,预设清单没有地方放的那几类。
const ( // DefaultDiscoveryWindow 是管理员打开发现窗口时的默认时长。 DefaultDiscoveryWindow = 10 * time.Minute // MaxDiscoveryWindow 是发现窗口的时长上限。 MaxDiscoveryWindow = 60 * time.Minute )
const ( // TempHostMaxAge 是临时启用的最长有效期(自启用起)。 TempHostMaxAge = 24 * time.Hour // TempHostIdle 是临时主机断线后仍保留启用状态的宽限期(应对网络抖动)。 TempHostIdle = 10 * time.Minute )
const ( // DefaultUpgradeWindow 是升级窗口的默认时长,也是每次「延时」增加的时长。 DefaultUpgradeWindow = 10 * time.Minute // MaxUpgradeWindow 是窗口剩余时间的上限。 MaxUpgradeWindow = 60 * time.Minute )
升级窗口:给「某一台」主机的 Agent 升级用的、限时的安装源访问权。
为什么需要它:Agent 的升级始终是「主机自己去取」,服务端从不向主机推送可执行内容——那等于给每台主机开一个远程代码执行面。 两种升级都走这条拉取通道:一是主机的主人在主机上执行一条命令(这条命令要从服务端取安装脚本与新版 Agent); 二是主人在主机上明确允许后,管理员在 Web 点「一键升级」,由 Agent 自己用同一张票据去取(见 web_upgrade.go)。 而 /i/ 平时只在「发现窗口」开着时才放行。升级窗口就是为这一台主机单独开一小段时间:
- 每台主机最多一个窗口,默认 10 分钟,可延时(每次 +10 分钟,剩余时间不超过 60 分钟)、可提前结束;
- 票据 128 位随机,仅存于内存(服务端重启即全部关闭),常量时间比较,/i/ 对所有失败仍然只回同一个 404;
- 它只放行 /i/ 里本来就公开的文件(安装脚本、校验文件、各平台 Agent 二进制),不放行别的任何东西;
- 窗口到期、被手动结束、主机被停用 / 删除,或检测到这台主机的 Agent 已经换了版本(升级成功)时自动关闭。
const ( UpgradeJobRequested = "requested" // 已发出请求,等待 Agent 应答 UpgradeJobDownloading = "downloading" // Agent 已接受,正在下载并校验 UpgradeJobHandoff = "handoff" // 已交给升级进程;Agent 即将被重启,随后以新版本重新上线 UpgradeJobDone = "done" // 主机带着新版本重新上线了 UpgradeJobFailed = "failed" // 被拒绝、失败,或新版本没有连上服务端而被还原 )
升级请求的状态。
const EvInstallServe = "install_serve"
EvInstallServe 记录服务端分发了安装文件(或拒绝了一次带错误票据的请求)。
const FreshUnlockWindow = 2 * time.Minute
FreshUnlockWindow 是「刚刚重新输入过密码」的时间窗口:授予式的高风险操作(开启「允许整个文件系统」) 要求解锁令牌创建于此窗口之内。
const GuardWakeHeadless = "headless"
GuardWakeHeadless 是非交互唤醒的方式名。
const MaxPendingPerIP = 8
MaxPendingPerIP 限制同一来源地址占用的待启用条目数,防止单一来源把列表灌满。
const UpgradeOriginAuto = "auto"
UpgradeOriginAuto 标记由主机自己发起的静默自动升级(缺省 / 空表示管理员在 Web 上点的一键升级)。 两种来源共用这套请求状态机(认领 / 推进 / 上线结算 / 回滚识别),只在审计事件与界面文案上区分。
Variables ¶
var ( // ErrRunNotFound 表示运行不存在(或已被清理)。 ErrRunNotFound = errors.New("run not found") // ErrRunNotAwaiting 表示运行不在待批准状态。 ErrRunNotAwaiting = errors.New("run is not awaiting approval") )
var DefaultAgentRunLimits = AgentRunLimits{MaxConcurrent: 3, MaxPerHour: 10, MaxPerDay: 30, PresetGap: 5 * time.Minute}
DefaultAgentRunLimits 是设计稿 8.4 的默认值。
var ( // ErrHostNotFound 表示机器码不存在(或不处于该操作适用的状态)。 ErrHostNotFound = errors.New("host not found") )
Functions ¶
func ClassifyLauncherExec ¶
ClassifyLauncherExec 见 store.ClassifyLauncherExec(前后端表驱动用例一致)。
func FindGuardPresetByWorkflow ¶
func FindGuardPresetByWorkflow(launchers []store.TerminalLauncher, workflowID string) *store.TerminalLauncher
FindGuardPresetByWorkflow 返回绑定该工作流且开启守护的第一个预设。
func HostDisplayName ¶
func HostDisplayName(r model.TerminalHost) string
HostDisplayName 是一台主机对外的名字:管理员写的备注优先,没有备注才用主机名。 给包外需要「写一句人话」的地方用(比如推送里的主机名),规则与界面和 MCP 里一致。
func ParseAutoResumeBackoff ¶
ParseAutoResumeBackoff 解析 RELAYMESH_TERMINAL_AUTORESUME_BACKOFF_SEC:逗号分隔的秒数(如 "3,6,9")。 只供实验与端到端测试缩短退避;不合法的项(不是正整数、超过一天)整个丢掉,全不合法返回 nil(用默认退避)。
func ResolveDiscovery ¶
ResolveDiscovery 规范化 RELAYMESH_TERMINAL_DISCOVERY: window(默认)表示只在管理员手动开启「发现窗口」期间接受未知主机;always 表示常开(不建议暴露在公网)。 无法识别的取值回落到更安全的 window 并返回提示。
func ResolveExec ¶
ResolveExec 规范化 RELAYMESH_TERMINAL_EXEC,返回「是否允许模型执行」与需要提示给运维的警告。
- 空 / off / false / 0 / no:关闭(默认)。模型执行是比人工终端更大的授权面(令牌可以代表一个不在场的执行者), 所以需要运维显式开启,且仍受终端总闸与逐主机授权约束;
- on / true / 1 / yes:开启;
- 其他取值:保持关闭并给出警告(fail-closed)。
func ResolveFiles ¶
ResolveFiles 规范化 RELAYMESH_TERMINAL_FILES,返回「是否允许模型访问主机上的文件」与需要提示给运维的警告。
- 空 / off / false / 0 / no:关闭(默认)。文件能力让模型可以读取主机上的内容、在主机上写入文件, 和执行命令一样是需要运维显式开启的授权面;
- on / true / 1 / yes:开启(还需要 RELAYMESH_TERMINAL_EXEC=on 与终端总闸,以及令牌的文件权限与允许目录);
- 其他取值:保持关闭并给出警告(fail-closed)。
func ResolveRecord ¶
ResolveRecord 规范化 RELAYMESH_TERMINAL_RECORD:auto(默认)表示各主机按本机与主机级策略记录终端显示内容; off 表示服务端全局关闭记录(下发给每台 Agent,本机无法覆盖)。 无法识别的取值按 off 处理并返回提示:记录是否关闭关乎隐私,配置写错时宁可不记,也不能让管理员以为已关而实际在记。
Types ¶
type AgentOpenError ¶
AgentOpenError 表示 Agent 拒绝新建会话。Code 是稳定的失败码(SSH 目标专用,本地 shell 与旧版本 Agent 为空)。
func (*AgentOpenError) Error ¶
func (e *AgentOpenError) Error() string
type AgentPresetLastRun ¶
type AgentPresetLastRun struct {
RunID string `json:"run_id"`
State string `json:"state"`
Active bool `json:"active"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
EndedAt *time.Time `json:"ended_at,omitempty"`
DurationMS int64 `json:"duration_ms,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
Reply string `json:"reply,omitempty"`
Silent bool `json:"silent,omitempty"`
Why string `json:"why,omitempty"`
By string `json:"by,omitempty"`
}
AgentPresetLastRun 是一条预设最近一次运行的现状。Reply 是从输出末尾提取、已脱敏限长的最后一条回复—— 它来自另一个智能体的输出,读的人要当数据看,不要当指令执行。
type AgentPresetView ¶
type AgentPresetView struct {
Preset string `json:"preset"`
Name string `json:"name"`
WorkflowID string `json:"workflow_id"`
WorkflowTitle string `json:"workflow_title,omitempty"`
Host string `json:"host"`
Posture string `json:"posture"`
Model string `json:"model,omitempty"`
MaxRunMinutes int `json:"max_run_minutes"`
AutoResume bool `json:"auto_resume,omitempty"`
NewConversation bool `json:"new_conversation,omitempty"`
// Origin 是预设的来源:enable_agent = 网页上「启用 Agent」建的;空 = 用户手工建的。
Origin string `json:"origin,omitempty"`
// CanRun 是此刻能不能运行(沿用网页「运行」按钮预览的那套检查,再加上频率账本);不能时 WhyNot 是一句中文原因、WhyCode 是稳定的代码。
CanRun bool `json:"can_run"`
WhyNot string `json:"why_not,omitempty"`
WhyCode string `json:"why_code,omitempty"`
LastRun *AgentPresetLastRun `json:"last_run,omitempty"`
}
AgentPresetView 是项目管理 Agent 能看到的一条预设。
type AgentRunActor ¶
type AgentRunActor struct {
// IdentityID 是调用方的身份编号:频率账本按它分;审计里记它,不记目录路径。
IdentityID uint
// Label 是写进审计说明、运行说明与聊天系统行里的名字(身份标签)。
Label string
// WorkflowID 是调用方自己的工作流:它不能运行自己所在工作流的预设。
WorkflowID string
// ProjectID 是调用方作为管理 Agent 所在的项目:资格按这个项目的任务板限定。
ProjectID uint
}
AgentRunActor 是经 MCP 发起预设运行的调用方;MCP 一侧已经确认它是所在项目的管理 Agent。
type AgentRunError ¶
AgentRunError 是项目管理 Agent 运行预设被拒绝的原因:Code 稳定(给程序看),Message 是一句中文并带上下一步(给智能体看)。
func (*AgentRunError) Error ¶
func (e *AgentRunError) Error() string
func (*AgentRunError) ErrorCode ¶
func (e *AgentRunError) ErrorCode() string
ErrorCode 让 MCP 一侧不必引用这个包的类型就能取到稳定的拒绝码(见 mcp.PresetRunner)。
type AgentRunLimits ¶
type AgentRunLimits struct {
// MaxConcurrent:每个管理 Agent 同时最多几条自己发起的运行在进行。
MaxConcurrent int
// MaxPerHour:每个管理 Agent 每小时最多发起几次。
MaxPerHour int
// MaxPerDay:所有 Agent 发起的运行 24 小时合计最多几次(熔断:两个管理 Agent 互相唤醒形成循环时由它拦住)。
MaxPerDay int
// PresetGap:同一预设两次由 Agent 发起的运行之间至少隔多久。
PresetGap time.Duration
}
AgentRunLimits 是频率护栏。它们是代码常量(设计稿 8.4),写进工具说明与拒绝信息;以后需要再做成设置。
type AgentRunLimitsView ¶
type AgentRunLimitsView struct {
MaxConcurrent int `json:"max_concurrent"`
MaxPerHour int `json:"max_per_hour"`
MaxPerDay int `json:"max_per_day"`
PresetGapSeconds int `json:"preset_gap_seconds"`
}
AgentRunLimitsView 是回执里写给智能体看的护栏数字(与实际生效的一致),用来让它自己安排节奏。
type AgentRunResult ¶
type AgentRunResult struct {
Preset string `json:"preset"`
Name string `json:"name"`
WorkflowID string `json:"workflow_id"`
RunID string `json:"run_id"`
State string `json:"state"`
Posture string `json:"posture"`
Model string `json:"model,omitempty"`
MaxRunMinutes int `json:"max_run_minutes"`
NewConversation bool `json:"new_conversation,omitempty"`
Warnings []string `json:"warnings,omitempty"`
Message string `json:"message"`
}
AgentRunResult 是运行提交成功之后的回执。
type AgentStateEvent ¶
type AgentStateEvent struct {
WorkflowID string
IdentityID uint
SessionID uint
State string
Sub string
Source string // 现在这个状态是谁说的(hook / tui / run)
Since time.Time
}
AgentStateEvent 是 Hub 自己推进了某个 Agent 会话的状态之后对外报告的变化(Web 据此重新取状态)。
type Authenticator ¶
type Authenticator interface {
CredentialSource
// VerifyHumanJWT 只接受「人类登录」签发的 JWT,MCP 凭据一律返回 false。
VerifyHumanJWT(token string) (subject string, ok bool)
// IsMCPToken 判断 token 是否是一把有效的 MCP 令牌(环境变量令牌或凭据库令牌)。
// 终端 REST 只服务人类登录会话:拿 MCP 令牌来访问会得到明确的 403,而不是含糊的“需要登录”。
IsMCPToken(token string) bool
}
Authenticator 是 Hub 需要的身份能力,由 api.AuthHandler 实现(通过接口避免 terminal 反向依赖 api)。
type AutoCheckView ¶
type AutoCheckView struct {
// At 是 Hub 受理这次检查的时刻。
At time.Time `json:"at"`
// Status 是 Hub 的回答(termproto.AutoOffer*)。
Status string `json:"status"`
// Version 是 Hub 上最新的 Agent 版本(回答 available / up_to_date 时有)。
Version string `json:"version,omitempty"`
}
AutoCheckView 是一台主机最近一次自动升级检查的结果。只在内存里:Agent 重连后会重新检查。
type AutoGrantView ¶
type AutoGrantView struct {
// At 是 Hub 受理这次请求的时刻。
At time.Time `json:"at"`
// Status 是裁决(termproto.AutoGrant*)。
Status string `json:"status"`
// Version 是请求要升级到的版本。
Version string `json:"version,omitempty"`
}
AutoGrantView 是一台主机最近一次静默升级请求得到的裁决,供界面解释「它为什么没有(或已经)自动升级」。 只在内存里;不含凭据——批准的票据、校验值和签名只在发给 Agent 的那一帧里。
type AutoResumeEvent ¶
type AutoResumeEvent struct {
PresetID string
Name string
Machine string
WorkflowID string
// FromRun 是最后出事的那次运行(通知的去重键)。
FromRun string
// Reason 是它出事的原因,Why 是不再自动续跑的原因。
Reason string
Why string
}
AutoResumeEvent 是自动续跑要告诉你的事件。现在只有一种:系统决定不再自动续跑了(预算用完、连续没有进展、没法提交), 这时需要你出面。排期、开跑、作废都只写在聊天里,不推送:每次运行的结束本来就有「运行结束」推送。 纯事实:推不推、怎么写由接收方决定。
type AutoResumeView ¶
type AutoResumeView struct {
// Enabled 表示预设里开着自动续跑。
Enabled bool `json:"enabled"`
// Max 是 24 小时内最多自动续跑几次。
Max int `json:"max"`
// OKMinutes 是「续跑成功」的判定时长(分钟,不满 1 分钟的按 1 计;#172):续跑出来的运行连续跑满这么久,24 小时内累计的次数就清零。
OKMinutes int `json:"ok_minutes,omitempty"`
// Settled 表示这次运行本身是自动续跑出来的、而且已经连续跑满判定时长:算续跑成功,次数已经清零。
Settled bool `json:"settled,omitempty"`
// Attempt 大于 0 表示这次运行本身是自动续跑出来的:24 小时内的第几次。
Attempt int `json:"attempt,omitempty"`
// State 是这次运行出事之后系统的安排:pending / started / stopped / skipped / gaveup;没有安排就空。
State string `json:"state,omitempty"`
// NextAttempt 是安排里这次续跑排第几次。
NextAttempt int `json:"next_attempt,omitempty"`
// Due 是待开跑(pending)的开跑时间。
Due *time.Time `json:"due,omitempty"`
// Why 是作废 / 放弃 / 取消的原因。
Why string `json:"why,omitempty"`
// NextRunID 是续跑出来的新运行(started)。
NextRunID string `json:"next_run_id,omitempty"`
}
AutoResumeView 是一次预设运行相关的自动续跑现状:这次运行是不是自动续跑出来的、它出事之后系统怎么安排的。
type CredentialSource ¶
type CredentialSource interface {
EffectiveCredentials(ctx context.Context) (username string, password string, err error)
}
CredentialSource 读取当前生效的登录凭据(环境变量与数据库已合并后的结果)。
type DiscoveryView ¶
type DiscoveryView struct {
Open bool `json:"open"`
Always bool `json:"always"`
Until *time.Time `json:"until,omitempty"`
RemainingSeconds int `json:"remaining_seconds"`
}
DiscoveryView 是发现窗口的展示状态。
type ErrGatewayInUse ¶
type ErrGatewayInUse struct{ Count int64 }
ErrGatewayInUse 表示一台主机仍被 SSH 主机当作网关:先删除或改接它们,才能删除这台主机。
func (*ErrGatewayInUse) Error ¶
func (e *ErrGatewayInUse) Error() string
type ExecService ¶
type ExecService struct {
// contains filtered or unexported fields
}
ExecService 实现 termexec.Executor,并为 REST / 事件流提供人类侧的操作。
func (*ExecService) ActiveOnHost ¶
func (s *ExecService) ActiveOnHost(machine string) int
ActiveOnHost 返回某台主机上进行中的模型运行数(含待批准)。
func (*ExecService) Approve ¶
func (s *ExecService) Approve(ctx context.Context, runID, actor, ip string) (*model.TerminalRun, error)
Approve 由人类批准一次待批准的运行。批准时会重新检查全部闸门:授权可能在等待期间被收回或暂停。
func (*ExecService) CancelByHuman ¶
func (s *ExecService) CancelByHuman(ctx context.Context, runID, actor, ip string) (*model.TerminalRun, error)
CancelByHuman 由人类取消一次进行中(或待批准)的运行。
func (*ExecService) Exec ¶
func (s *ExecService) Exec(ctx context.Context, c termexec.Caller, req termexec.ExecRequest) (any, error)
func (*ExecService) Files ¶
func (s *ExecService) Files(ctx context.Context, c termexec.Caller, req termexec.FileRequest) (any, error)
Files 让 Hub.Executor() 同时满足 termexec.FileExecutor:MCP 层只需要一个执行器。
func (*ExecService) MCPCredentialChanged ¶
func (s *ExecService) MCPCredentialChanged(ctx context.Context, id uint, reason string)
MCPCredentialChanged 在 MCP 令牌被修改、停用、删除或重新生成之后调用:它名下仍在进行的运行, 按新的状态已经不会被允许的,就取消(令牌可能已经泄露,进行中的命令不应该比令牌活得更久)。 reason 为 deleted / regenerated 时无条件取消;为 updated 时按新配置重新评估。
func (*ExecService) ModelSettings ¶
func (s *ExecService) ModelSettings(ctx context.Context, machine string, upd store.HostModelUpdate, actor, ip string) (*model.TerminalHost, error)
ModelSettings 修改一台主机的模型访问设置(G2 与执行模式);收回授权时立即取消该主机上的模型运行。
func (*ExecService) ReadOutput ¶
func (s *ExecService) ReadOutput(ctx context.Context, runID, stream string, off uint64, limit int) (*RunPage, string, error)
ReadOutput 供人类读取某次运行的完整输出的一页(不经过数据库,原样来自主机;仅做 UTF-8 规整)。
func (*ExecService) Reject ¶
func (s *ExecService) Reject(ctx context.Context, runID, actor, ip string) (*model.TerminalRun, error)
Reject 由人类拒绝一次待批准的运行。
func (*ExecService) Run ¶
func (s *ExecService) Run(ctx context.Context, c termexec.Caller, req termexec.RunRequest) (any, error)
func (*ExecService) SetPaused ¶
func (s *ExecService) SetPaused(ctx context.Context, scope, machine string, paused bool, actor, ip string) error
SetPaused 暂停 / 恢复模型执行。scope 为 "all"(全局)或 "host"(machine 指定主机)。 暂停会立刻取消该范围内所有进行中的模型运行并作废待批准项;恢复不会让它们复活。
func (*ExecService) Status ¶
func (s *ExecService) Status(ctx context.Context) ExecStatus
Status 汇总模型执行的状态。
func (*ExecService) Threads ¶
func (s *ExecService) Threads(ctx context.Context, f store.ThreadFilter) ([]ThreadView, error)
Threads 汇总模型线程。线程按最近一次运行倒序,计数来自数据库(状态变更都先落库再广播)。
type ExecStatus ¶
type ExecStatus struct {
// Enabled 是服务端总开关(RELAYMESH_TERMINAL_EXEC);Available 还要求终端总闸开启。
Enabled bool `json:"enabled"`
FilesEnabled bool `json:"files_enabled"` // 文件能力(RELAYMESH_TERMINAL_FILES)是否开启
Available bool `json:"available"`
Reason string `json:"reason,omitempty"`
Paused bool `json:"paused"`
Active int `json:"active"`
Awaiting int `json:"awaiting"`
Subscribers int `json:"subscribers"`
RetentionDays int `json:"retention_days"`
}
ExecStatus 是模型执行的整体状态(供界面决定显示什么入口与提示)。
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
FileService 实现 termexec.FileExecutor:模型经 terminal_files 查看(stat / hash)、拉取(pull_prepare)与写入(push_url) 已授权主机上令牌允许目录内的文件。
闸门流水线与 ExecService 同源,在其后追加文件专属的几道(任何一道不通过都不会向主机发出请求):
RELAYMESH_TERMINAL_FILES=on ∧ G1(模型执行总开关 + 终端总闸) → 令牌:文件权限位 + 强度 + 非空 allowed_paths → G3 令牌主机白名单 → G2 主机允许模型 → G5 暂停 → 在线 → 主机具备文件能力 → G4 本机一票否决 → 执行模式:文件传输(拉取 / 写入)要求主机与令牌的有效模式都是 auto → 并发
路径授权(允许目录、符号链接、特殊文件、大小)由 Agent 强制执行——Hub 只转发令牌的 allowed_paths, 并把 Agent 的回包当作不可信输入校验。文件内容和票据从不进入数据库、审计与日志。
func (*FileService) Files ¶
func (s *FileService) Files(ctx context.Context, c termexec.Caller, req termexec.FileRequest) (any, error)
Files 是 terminal_files 的入口。
func (*FileService) MCPCredentialChanged ¶
func (s *FileService) MCPCredentialChanged(id uint) int
MCPCredentialChanged 在令牌被修改 / 停用 / 删除 / 重新生成时作废它名下的全部拉取票据。
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
Gate 是终端功能的总闸。
「可用 = 已设 Web 密码 ∧ JWT 签名密钥强度合格 ∧ 未被 RELAYMESH_TERMINAL=off」。 Evaluate 对每次请求实时判定(Strict);Watch 以固定间隔轮询,在状态翻转时立刻回调, 用于主动拆除已建立的 WebSocket 连接(没有新请求到来时 Strict 无法触发拆除)。
func NewGate ¶
func NewGate(mode Mode, jwtSecret string, creds CredentialSource) *Gate
NewGate 创建总闸。jwtSecret 只用于启动时的强度判定,不会被保存。
type GuardAlert ¶
type GuardAlert struct {
PresetID string
Name string
Machine string
WorkflowID string
State GuardState // crashed | stalled
Reason string
Since time.Time // 事件的起点;零值 = 不详
Episode string
// Reminder 为 0 表示首次通知;大于 0 表示同一次事件的第几次补发提醒。
Reminder int
}
GuardAlert 是守护要告知你的一次事件。纯事实:推不推、怎么写由接收方(ntfy)决定。
type GuardHeadlessView ¶
type GuardHeadlessView struct {
Enabled bool `json:"enabled"`
Posture string `json:"posture"`
// Ok 表示现在点它能行;不行时 Note 说明原因。
Ok bool `json:"ok"`
Note string `json:"note,omitempty"`
}
GuardHeadlessView 是预设的非交互唤醒现状(只在预设开启了它时才有)。
type GuardItem ¶
type GuardItem struct {
PresetID string `json:"preset_id"`
Name string `json:"name"`
Host string `json:"host"`
Enabled bool `json:"enabled"`
WorkflowID string `json:"workflow_id,omitempty"`
SilenceMinutes int `json:"silence_minutes"`
Verdict GuardVerdict `json:"verdict"`
// WakesInWindow 是滚动 24 小时内已经唤醒的次数;NoProgressStreak 是最近连续几次唤醒没有任何效果。
WakesInWindow int `json:"wakes_24h"`
NoProgressStreak int `json:"no_progress_streak"`
// PermitMarked 表示已标记「任务全部完成」(唤醒许可为 0)。
PermitMarked bool `json:"permit_marked,omitempty"`
LastWake *GuardWakeView `json:"last_wake,omitempty"`
// WakeMode 是现在点「唤醒」会怎么做;none 时 WakeNote 说明原因。
WakeMode string `json:"wake_mode"`
WakeNote string `json:"wake_note,omitempty"`
// ChatKnown 表示已经知道智能体的对话编号(hook 汇报过),重新拉起时能接着原来的对话。
ChatKnown bool `json:"chat_known"`
// Headless 是非交互唤醒的现状;预设没有开启它时没有这一项。
Headless *GuardHeadlessView `json:"headless,omitempty"`
}
GuardItem 是一个预设的守护概况。
type GuardOpenWork ¶
type GuardOpenWork struct {
UnreadReply bool `json:"unread_reply"` // 你已经回复了,但智能体没有读取
PollLost bool `json:"poll_lost"` // 智能体在等待你回复的轮询中途没了动静
InboxUnread int `json:"inbox_unread"` // 没被读取的追加指令条数
DoingTasks int `json:"doing_tasks"` // 进行中的任务个数
}
GuardOpenWork 是「RelayMesh 里有没有该有人处理的事」。
type GuardState ¶
type GuardState string
GuardState 是守护对一个预设会话的判断。
const ( GuardWorking GuardState = "working" // 在干活:近期有活动(或刚收尾、还在观察) GuardWaiting GuardState = "waiting" // 在等你回复:合法等待,无需处理 GuardPresent GuardState = "present" // 有人正连着,不打扰 GuardIdle GuardState = "idle" // 没有待处理的事,无需处理 GuardEnded GuardState = "ended" // 会话已结束,且是正常的结束(手动结束、空闲回收、命令正常退出……) GuardCrashed GuardState = "crashed" // 会话意外结束:需要处理 GuardStalled GuardState = "stalled" // 会话还在,但智能体停摆了:需要处理 GuardOffline GuardState = "offline" // 主机离线,看不到会话的情况 GuardUnknown GuardState = "unknown" // 缺少判断依据 )
const (
GuardDone GuardState = "done" // 已标记全部完成,按约定不唤醒、不推送
)
func (GuardState) Alerting ¶
func (s GuardState) Alerting() bool
Alerting 表示这个状态需要打扰你(推送、界面上的红点)。其余状态都是「无需处理」或「无法判断」。
type GuardVerdict ¶
type GuardVerdict struct {
State GuardState `json:"state"`
Reason string `json:"reason"` // 一句人话
Detail []string `json:"detail,omitempty"` // 判断依据,给界面的「为什么这么判断」展开用
// Since 是进入这个状态的起点(停摆是静默的起点,意外结束是结束的时间)。
Since *time.Time `json:"since,omitempty"`
// Episode 标识「同一次事件」:它不变,就不会重复推送;变了才是新的事。只有需要打扰的状态才有。
Episode string `json:"-"`
// Cause 说明停摆是怎么发现的:error(一轮对话以出错结束)/ silence(长时间没有活动);其他状态为空。
Cause string `json:"cause,omitempty"`
OpenWork GuardOpenWork `json:"open_work"`
}
GuardVerdict 是一次判断的结论。
type GuardView ¶
type GuardView struct {
Items []GuardItem `json:"items"`
WakeMax int `json:"wake_max"`
WakeWindowHours int `json:"wake_window_hours"`
ProgressMinutes int `json:"progress_minutes"`
At time.Time `json:"at"`
}
GuardView 是 GET /guard 的返回。
type GuardWakePlan ¶
type GuardWakePlan struct {
Mode string `json:"mode"` // type | relaunch
Name string `json:"name"` // 预设名
Host string `json:"host"` // 机器码
// SessionSID 是 type 方式要连上去输入的存活会话。
SessionSID string `json:"session_sid,omitempty"`
// Prompt 是要输入的提示词(含固定的「【系统唤醒 …】」开头);它不含任何 shell 特殊字符。
Prompt string `json:"prompt"`
// Command、Dir、Resume 只用于 relaunch:在 Dir 里新开会话并运行 Command;Resume 表示接着原来的对话(否则是新对话)。
// AppendPrompt 表示可以把 Prompt 放进引号、追加在 Command 后面一起启动;否则只启动命令,提示词要另行发给它。
Command string `json:"command,omitempty"`
Dir string `json:"dir,omitempty"`
Resume bool `json:"resume,omitempty"`
AppendPrompt bool `json:"append_prompt,omitempty"`
// N 是这次是滚动 24 小时内的第几次唤醒(含本次),Max 是参考上限;OverBudget 表示这次已经超过上限。
N int `json:"n"`
Max int `json:"max"`
OverBudget bool `json:"over_budget"`
Warnings []string `json:"warnings,omitempty"`
// RunID、RunState、Posture 只用于 headless(非交互唤醒):已经提交的运行、它当前的状态与权限姿态。
// 这种方式由服务端直接执行,浏览器不需要再做什么,只提示去哪里看运行。
RunID string `json:"run_id,omitempty"`
RunState string `json:"run_state,omitempty"`
Posture string `json:"posture,omitempty"`
}
GuardWakePlan 是一次唤醒要执行的内容,由浏览器照着做。
type GuardWakeView ¶
type GuardWakeView struct {
At time.Time `json:"at"`
Mode string `json:"mode"`
Reason string `json:"reason"`
Progress string `json:"progress"` // progress(之后有了动静)| none(观察窗口过完仍没有)| pending(还在观察)
}
GuardWakeView 是最近一次唤醒的概况。
type HolderView ¶
type HolderView struct {
State string `json:"state"` // ready | unavailable
Persistent bool `json:"persistent"`
Version string `json:"version,omitempty"`
// Rev 是守护进程的「Agent 侧代码指纹」(空 = 旧版本守护进程)。与主机 Agent 的指纹比较,就能精确知道守护进程跑的是不是旧代码,
// 而不是靠版本号(Agent 升级后版本号总是不同,哪怕守护进程的代码一模一样)。
Rev string `json:"rev,omitempty"`
Started int64 `json:"started,omitempty"`
Reason string `json:"reason,omitempty"`
Lost []termproto.LostSession `json:"lost,omitempty"`
// Caps 是守护进程的能力清单;DenyExec 表示本机用 --deny-model-exec 拒绝一切模型运行;Exec 是模型运行的执行环境。
Caps []string `json:"caps,omitempty"`
DenyExec bool `json:"deny_exec,omitempty"`
Exec *termproto.ExecInfo `json:"exec,omitempty"`
}
HolderView 是主机上会话守护进程的状态(供界面标注「重启不中断」/「重启会中断」与解释会话为什么消失)。
type HostView ¶
type HostView struct {
MachineCode string `json:"machine_code"`
Remark string `json:"remark"`
Status string `json:"status"` // enabled | disabled | blocked
Temporary bool `json:"temporary"` // 仅内存的临时启用
Online bool `json:"online"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Arch string `json:"arch"`
AgentVersion string `json:"agent_version"`
// AgentRev 是主机上 Agent 的「Agent 侧代码指纹」(空 = 旧版本 / 非发布构建)。版本号跟着整个仓库的构建走,指纹只在 Agent 代码真的变了才变。
AgentRev string `json:"agent_rev,omitempty"`
Privilege string `json:"privilege"`
LastIP string `json:"last_ip"`
LastSeenAt *time.Time `json:"last_seen_at,omitempty"`
EnabledAt *time.Time `json:"enabled_at,omitempty"`
Sessions []termproto.SessionInfo `json:"sessions"`
// RecOff 是管理员在这台主机上关闭终端记录的开关;RecServerOff 表示服务端全局关闭(此时单机开关不起作用)。
RecOff bool `json:"rec_off"`
RecServerOff bool `json:"rec_server_off,omitempty"`
// IdleSec 是这台主机上会话的默认生命周期(秒):连续没有交互这么久才回收;0 表示永久保持。
IdleSec int `json:"idle_sec"`
// 模型访问(M6):AllowModel 是 G2(管理员允许模型使用这台主机,默认关闭);ExecMode 为空表示 auto;
// ModelPaused 是这台主机的暂停开关;ModelRunning 是此刻进行中的模型运行数(含待批准)。
AllowModel bool `json:"allow_model"`
ExecMode string `json:"exec_mode"`
ModelPaused bool `json:"model_paused"`
ModelRunning int `json:"model_running"`
// DefaultForNewModels 是这台主机对「新建模型授权」的默认态:allow(新建令牌时预先授予,新增主机时授予现有令牌)/ deny(默认)。
// 只是预填规则:令牌能否使用主机始终只看令牌自己的主机名单。
DefaultForNewModels string `json:"default_for_new_models"`
// Holder 是会话守护进程的状态;nil 表示 Agent 没有报告(旧版本,会话随 Agent 进程结束)。
Holder *HolderView `json:"holder,omitempty"`
DuplicateName bool `json:"duplicate_name,omitempty"` // 与其他主机同名,请以机器码为准
// Kind 是主机类型:agent(装了 Agent)或 ssh(只经 SSH 供模型执行,没有人工终端与文件)。
Kind string `json:"kind"`
SSH *SSHView `json:"ssh,omitempty"`
// CanUninstall:在线的 Agent 声明了「删除主机时可以同时卸载设备端」的能力(装成常驻服务运行、版本足够新、系统受支持)。
// 离线、旧版本、前台运行 / 临时 Agent 一律为 false,界面据此决定是否提供「同时卸载设备端」。
CanUninstall bool `json:"can_uninstall,omitempty"`
// 升级提醒(只对装了 Agent 的持久主机):LatestAgentVersion 是本服务端自带的 Agent 版本;
// LatestAgentRev 是自带这批 Agent 的代码指纹(分发目录的 REV 文件,没有则为空)。
// 两边都有指纹时只比指纹:指纹不同才算 UpgradeAvailable(能从版本号确定更旧的 UpgradeKind = older,否则 = changed),
// 指纹一致则 UpToDateByRev = true(版本号不同只是构建号不同,Agent 代码一致);任一边没有指纹时回退到比版本号,
// UpgradeKind 区分「能确定更旧」(older)与「不同但无法比较新旧」(different)。
// UpgradeWindow 非空表示这台主机的升级窗口正开着(含供界面拼出升级命令的票据)。
LatestAgentVersion string `json:"latest_agent_version,omitempty"`
LatestAgentRev string `json:"latest_agent_rev,omitempty"`
UpgradeAvailable bool `json:"upgrade_available,omitempty"`
UpgradeKind string `json:"upgrade_kind,omitempty"`
UpToDateByRev bool `json:"up_to_date_by_rev,omitempty"`
UpgradeWindow *UpgradeWindowView `json:"upgrade_window,omitempty"`
// Web 一键升级:WebUpgrade 是在线 Agent 声明的能力(空 = 不支持;off = 支持但主机所有者没有在本机允许;on = 已允许);
// UpgradeJob 是最近一次升级请求的进展(含结果);LastUpgrade 是主机本地记录的上一次升级结果(回滚后旧版本上线时会带回)。
WebUpgrade string `json:"web_upgrade,omitempty"`
UpgradeJob *UpgradeJobView `json:"upgrade_job,omitempty"`
LastUpgrade *termproto.UpgradeNote `json:"last_upgrade,omitempty"`
// 自动升级:AutoUpgrade 是在线 Agent 声明的模式(空 = 不提供:旧版本 / 前台运行 / 暂不支持的系统;off = 提供但主机所有者没有开启;
// notify / silent = 主机所有者已在本机开启);AutoCheck 是这台主机最近一次检查的结果(还没检查过则没有,Agent 重连后重新检查)。
AutoUpgrade string `json:"auto_upgrade,omitempty"`
AutoCheck *AutoCheckView `json:"auto_check,omitempty"`
// AutoWindow 是静默自动升级允许开始的时间段(主机本地时间,HH:MM-HH:MM,可跨午夜),只在 AutoUpgrade == "silent" 且设了时间段时有。
// 仅供界面展示:是否允许升级由 Agent 在本机判断,Hub 的裁决不看它。
AutoWindow string `json:"auto_window,omitempty"`
// AutoGrant 是这台主机最近一次静默升级请求得到的裁决(批准 / 没有签名 / 主机忙 …);还没请求过则没有,Agent 重连后重新来过。
AutoGrant *AutoGrantView `json:"auto_grant,omitempty"`
}
HostView 是返回给前端的主机视图。自报字段均已净化,界面只应按纯文本渲染。
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub 是终端功能的服务端中枢。
func (*Hub) AgentPresetStatus ¶
func (h *Hub) AgentPresetStatus(ctx context.Context, actor AgentRunActor, ref string) (*AgentPresetView, error)
AgentPresetStatus 看一条预设此刻的现状(用来等子会话做完);没有资格同样被拒绝。
func (*Hub) AgentPresets ¶
func (h *Hub) AgentPresets(ctx context.Context, actor AgentRunActor) ([]AgentPresetView, error)
AgentPresets 列出 actor 有资格运行的预设(每条带此刻能不能运行与最近一次运行)。没有资格的预设一概不出现。
func (*Hub) AgentRunLimitsView ¶
func (h *Hub) AgentRunLimitsView() AgentRunLimitsView
AgentRunLimitsView 返回此刻生效的频率护栏。
func (*Hub) AgentRunPreset ¶
func (h *Hub) AgentRunPreset(ctx context.Context, actor AgentRunActor, ref string) (*AgentRunResult, error)
AgentRunPreset 以 actor 的名义运行一条预设。顺序:资格 → 预设此刻的状态(主机在线、上一次运行没结束、对话没在跑……)→ 频率账本 → 经 runLauncherWith 提交(它会把全部闸门再走一遍)→ 记审计。每一步被拒绝都记一条审计(拒绝的尝试按调用方限流,防刷屏)。
func (*Hub) CredentialRevealed ¶
func (*Hub) CredentialsChanged ¶
CredentialsChanged 在登录凭据被修改或重置后调用:撤销全部解锁令牌与票据,并断开所有浏览器终端连接。 Agent 连接是机器身份,不受管理员密码影响;若密码被清空,总闸监视会随后拆除 Agent 连接。
func (*Hub) FilesScopeChanged ¶
FilesScopeChanged 记录「允许整个文件系统」的变化:result=ok 表示开启 / 关闭已生效,deny 表示因没有刚刚重新验证 密码而被拒。detail 只含令牌编号、名称与动作。开启与关闭都逐条落盘(每一条都改变了授权边界);被拒绝的尝试 是持有登录态的攻击者可以反复触发的,按来源合并限流。nil 安全:没有终端子系统时什么也不做。
func (*Hub) MCPCredentialChanged ¶
MCPCredentialChanged 通知 Hub:某个 MCP 令牌被修改 / 停用 / 删除 / 重新生成。见 ExecService.MCPCredentialChanged。
func (*Hub) Mount ¶
Mount 注册全部终端路由到 /api/v1/terminal。
路由分三类:
- 自带鉴权的入口:/status(按需登录)、/agent/ws(通用 Agent 入口,多层预认证防护)、/ws(一次性票据);
- 「登录」类:只需人类登录 JWT,用于查看列表、改备注、看审计、上锁;
- 「解锁」类:还需 X-Terminal-Unlock,用于一切会扩大攻击面或终止会话的操作。
所有路由(/status 除外)在总闸关闭时一律拒绝(见 guard 与各入口的前置判定)。 另有两个挂在根路径、靠一次性 / 窗口票据保护的下载入口:/files/dl/:ticket(模型文件拉取)与 /i/:ticket/:name(Agent 安装源)。
func (*Hub) RecordOAuthAudit ¶
CredentialRevealed 记录一次「查看令牌」尝试(在设置页重新验证 Web 密码后读出某个 MCP 令牌)。 result 取 ok / fail / deny;detail 只含令牌编号与名称,令牌与密码从不进入审计。 失败与被锁定是持有登录态的攻击者可以反复触发的高频事件,按来源合并限流;成功则逐条落盘,因为每一条都是一次真实的泄露面。 RecordOAuthAudit 记录 OAuth 协议事件(event 为 oauth_* 常量名;detail 不得含机密)。
func (*Hub) RequireFreshUnlock ¶
RequireFreshUnlock 在 RequireUnlock 的基础上,要求解锁令牌是刚刚(FreshUnlockWindow 之内)才用密码换取的: 已经解锁了半天的令牌不能替「授予整个文件系统」这类操作代为确认。不满足时返回 403 unlock_fresh_required, 前端据此弹出密码框、换取新令牌后重试;这次被拒绝也会写一条(限流的)审计,subject 说明被拒绝的是什么操作。 不满足时已写入响应并返回 false。
func (*Hub) RequireUnlock ¶
RequireUnlock 供终端之外的管理接口(例如 MCP 令牌管理)在需要二次确认的操作里调用: 要求调用者是已登录的人类、终端总闸开启且持有有效的解锁令牌。不满足时已写入响应并返回 false。
func (*Hub) SSHAdd ¶
func (h *Hub) SSHAdd(ctx context.Context, req SSHAddRequest, actor, ip string) (*HostView, *store.HostGrantResult, error)
SSHAdd 登记一台 SSH 主机:重新探测并核对指纹 → 真实连接验证凭据 → 密封保存。 req.DefaultForNewModels 为 allow 时,新增之后把这台主机写入现有模型令牌的主机名单(返回授予结果供界面提示)。
func (*Hub) SSHProbeHost ¶
SSHProbeHost 对已登记主机的当前地址重新探测(用于「重新确认指纹」前展示新的指纹)。
func (*Hub) SSHProbeVia ¶
func (h *Hub) SSHProbeVia(ctx context.Context, address, gateway, actor, ip string) (*SSHProbeResult, error)
SSHProbeVia 与 SSHProbe 相同,但可以指定由网关主机(机器码)出站探测:目标只在网关的网络里才够得着时使用。 gateway 为空即 Hub 直连。
func (*Hub) SSHUpdateConn ¶
func (h *Hub) SSHUpdateConn(ctx context.Context, code string, req SSHConnUpdateRequest, actor, ip string) (*HostView, error)
SSHUpdateConn 修改连接信息(地址 / 用户 / 凭据)。新信息先用**已固定的主机密钥**真实连一次,通过才保存: 因此改地址不会绕过密钥固定(连到别的机器会因密钥不一致而失败),填错凭据也不会把主机弄成连不上。
func (*Hub) SetAgentStateHook ¶
func (h *Hub) SetAgentStateHook(fn func(AgentStateEvent))
SetAgentStateHook 接入「Hub 推进了 Agent 会话状态」的通知;启动时调用一次,传 nil 表示摘掉。 fn 在监视协程里同步调用,必须立即返回;里面的 panic 会被截住。
func (*Hub) SetAutoResumeHook ¶
func (h *Hub) SetAutoResumeHook(fn func(AutoResumeEvent))
SetAutoResumeHook 接入自动续跑的通知;启动时调用一次,传 nil 表示摘掉。 fn 在判断协程里被同步调用,必须立即返回,不能在里面做网络请求;fn 里的 panic 会被截住。
func (*Hub) SetFreshUnlockWindow ¶
SetFreshUnlockWindow 调整这个窗口(仅供测试:把它压到负数就能模拟「很久以前解锁的令牌」, 不必真的等待两分钟)。d==0 恢复默认的 FreshUnlockWindow。
func (*Hub) SetGuardHook ¶
func (h *Hub) SetGuardHook(fn func(GuardAlert))
SetGuardHook 接入守护事件通知;启动时调用一次,传 nil 表示摘掉。 fn 在守护的判断协程里被同步调用(此时事件标识已落库),必须立即返回,不能在里面做网络请求;fn 里的 panic 会被截住。
func (*Hub) SetGuardWakePermit ¶
func (h *Hub) SetGuardWakePermit(ctx context.Context, presetID string, permit int, by, note string) (*store.GuardWakePermitState, error)
SetGuardWakePermit 设置预设的唤醒许可(MCP / REST 共用)。
func (*Hub) SetHTTPSPort ¶
SetHTTPSPort 设置内置 HTTPS 监听端口,供「安装 Agent」命令拼出正确的服务端地址。
func (*Hub) SetRunEndHook ¶
func (h *Hub) SetRunEndHook(fn func(RunEndEvent))
SetRunEndHook 接入运行终结通知;启动时调用一次,传 nil 表示摘掉。
fn 在终结运行的协程里被同步调用(此时状态已落库、事件已发布,不持有任何锁),所以必须立即返回, 不能在里面做网络请求;需要慢操作的接收方自己入队。fn 里的 panic 会被截住,不影响运行的收尾。
func (*Hub) SetScreenHook ¶
func (h *Hub) SetScreenHook(fn func(ScreenEvent))
SetScreenHook 接入屏幕事件通知;启动时调用一次,传 nil 表示摘掉。 fn 在清单处理协程里被同步调用,必须立即返回,不能做网络请求。
func (*Hub) SetTLSSPKI ¶
SetTLSSPKI 设置内置 HTTPS 叶子证书的公钥指纹("sha256//<base64>",即 curl --pinnedpubkey 的参数格式), 供自签名证书场景下校验「从服务端下载安装文件」这一步:Agent 自己用证书指纹(SetTLSPin)校验连接,下载则用公钥指纹。
func (*Hub) SetWakeHook ¶
SetWakeHook 接入「聊天里多了一条唤醒系统行」的通知;启动时调用一次,传 nil 表示摘掉。fn 必须立即返回。
type InstallStatus ¶
type InstallStatus struct {
// Available 表示分发目录里至少有一个 Agent 二进制:为 false 时前端应回退为 GitHub Release 来源的命令。
Available bool `json:"available"`
// Ticket 是当前发现窗口的安装票据,只在窗口开启期间返回。
Ticket string `json:"ticket,omitempty"`
// Platforms 是可分发的平台(如 linux-amd64)。
Platforms []string `json:"platforms,omitempty"`
// SPKIPin 是内置 HTTPS 叶子证书的公钥指纹(curl --pinnedpubkey 格式),用于自签名证书场景下校验下载。
SPKIPin string `json:"spki_pin,omitempty"`
// Version 是这个 Hub 对应的 GitHub Release 标签(vX.Y.Z 或 vX.Y.Z-rc.N);开发版与未知版本为空。
// 不论有没有安装源都返回:没有安装源(单二进制、go run)时,前端回退到 GitHub 来源的命令,必须据此把脚本地址与
// RELAYMESH_VERSION 固定成这个版本——脚本默认取「最新正式版」,预览期间那里没有 Agent,命令会失败。
// 值经 buildinfo.ReleaseTag 重新拼出,只含数字、点、连字符、小写字母与前缀 v。
Version string `json:"version,omitempty"`
}
InstallStatus 是 /status 里的「安装源」部分。
type LauncherOtherRun ¶
type LauncherOtherRun struct {
LauncherRunView
// Source 是这次运行的来源,见 OtherRun* 常量。
Source string `json:"source"`
// WorkflowID 是这次运行续聊的对话所在的工作流(可能为空)。
WorkflowID string `json:"workflow_id,omitempty"`
// Host 是运行所在主机的机器码;界面按它换成主机名。
Host string `json:"host"`
// Dir 是运行的工作目录(主机上的路径),界面据此判断它属不属于「本项目」。
Dir string `json:"dir,omitempty"`
// Description 是提交时写下的一句话说明(例如「会话页运行:接着对话 chat-s1 的非交互续聊」)。
Description string `json:"description,omitempty"`
}
LauncherOtherRun 是一次不属于任何预设的 Hub 提交的非交互运行。 预设清单只认「预设自己的最近一次运行」,这类运行在那里没有位置,以前只能到 ExecMesh 里翻; 启动器弹窗把它们单列出来,免得「明明有会话在运行,弹窗里却什么都看不到」,进行中的还可以取消。
type LauncherRunPlan ¶
type LauncherRunPlan struct {
Name string `json:"name"`
Host string `json:"host"`
RunID string `json:"run_id"`
RunState string `json:"run_state"`
Posture string `json:"posture"`
Model string `json:"model,omitempty"`
ConversationID string `json:"conversation_id"`
// NewConversation 表示这次运行是新开对话(#176):命令里没有 --resume,ConversationID 为空——
// 对话编号要等智能体启动后从它的输出里学到(见 run_watch.go 的 learn)。
NewConversation bool `json:"new_conversation,omitempty"`
// MaxRunSeconds 是这次运行的最长运行时间(秒):预设里设的值,没设就是平台上限 7 天。
MaxRunSeconds int `json:"max_run_seconds"`
Warnings []string `json:"warnings,omitempty"`
}
LauncherRunPlan 是点「运行」之后返回给界面的结果:运行已经由服务端提交,浏览器不需要再做什么。
type LauncherRunView ¶
type LauncherRunView struct {
RunID string `json:"run_id"`
// ThreadKey 是这条运行记录所在的 ExecMesh 线程键:界面据此链到 ExecMesh 里看完整输出(/exec/r/<键>)。
ThreadKey string `json:"thread_key,omitempty"`
// State 是运行记录里的状态(running / awaiting_approval / succeeded / failed / timeout / cancelled / rejected / denied / lost)。
State string `json:"state"`
// Active 表示还没结束(含待批准);残留超过它自己的超时加宽限(runStaleAfter)的记录不再算进行中。
Active bool `json:"active"`
ExitCode *int `json:"exit_code,omitempty"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
EndedAt *time.Time `json:"ended_at,omitempty"`
DurationMS int64 `json:"duration_ms,omitempty"`
// TimeoutSec 是这次运行的最长运行时间(秒):到点主机强制结束它(状态 timeout,界面写「达到运行时长上限」)。
// 旧记录没有这个值(0 = 不知道)。
TimeoutSec int `json:"timeout_sec,omitempty"`
// Reply 是从输出末尾提取的最后一条回复(或没有结构化回复时的输出末行),已脱敏、限长、压成一行;提取不到是空。
Reply string `json:"reply,omitempty"`
// Silent 表示这次运行成功了、但期间智能体没有向 RelayMesh 发出任何消息(空转退出)。
Silent bool `json:"silent,omitempty"`
// Why 是运行没有正常结束(被取消 / 被拒绝 / 启动失败 / 丢失)时的原因,一句中文;有退出码的失败与正常结束没有它。
Why string `json:"why,omitempty"`
// Failure 是异常退出(失败 / 崩溃)时的失败说明:Cursor CLI 自己报的错误类别(可重试 / 需要你处理 / 不可重试)、错误码与一句中文,
// 认不出时是「未知」。取消、到时长上限、成功、没执行的运行没有它(#151,见 run_exit.go)。
Failure *RunFailureView `json:"failure,omitempty"`
// Auto 是自动续跑的现状(只有预设的运行才有,见 auto_resume.go):这次运行是不是自动续跑出来的、它出事之后系统怎么安排的。
Auto *AutoResumeView `json:"auto,omitempty"`
// By 不为空表示这次运行是项目管理 Agent 经 MCP 发起的(#179,见 agent_run.go):写的是它的名字;人点的运行与自动续跑没有它。
By string `json:"by,omitempty"`
}
LauncherRunView 是一个「非交互续聊」预设最近一次运行的现状(给启动器清单用;运行记录本身在 ExecMesh 里)。
type Limiter ¶
type Limiter interface {
CheckLocked(key string) (bool, time.Duration)
RecordFailure(key string, maxAttempts int, lockout time.Duration) (bool, time.Duration)
RecordSuccess(key string)
}
Limiter 是解锁尝试限流所需的最小接口(api.RateLimiter 满足)。
type Mode ¶
type Mode string
Mode 是 RELAYMESH_TERMINAL 的解析结果。
type Options ¶
type Options struct {
Auth Authenticator
Store *store.Store
Limiter Limiter
// JWTSecret 只用于启动时判定强度(总闸条件之一),Hub 不会保存或使用它签发任何内容。
JWTSecret string
Mode Mode
// DiscoveryAlways 为 true 时发现窗口常开(RELAYMESH_TERMINAL_DISCOVERY=always)。
DiscoveryAlways bool
// AllowedOrigins 是除「同源」之外额外允许发起终端 WebSocket 的 Origin(完整形式,如 https://relay.example.com)。
AllowedOrigins []string
// 终端记录的服务端策略(RELAYMESH_TERMINAL_RECORD*):下发给每台主机的 Agent,只能让本机配置更严格。
// RecordOff 全局关闭录制;其余三项在大于 0 时给保留天数、单会话 MiB、整机 MiB 设上限。
RecordOff bool
RecordRetentionDays int
RecordSessionMB int
RecordHostMB int
// ExecEnabled 是 G1:RELAYMESH_TERMINAL_EXEC=on 才允许模型经 MCP 在已授权的主机上执行命令(默认关闭)。
ExecEnabled bool
// FilesEnabled 是文件能力的服务端开关:RELAYMESH_TERMINAL_FILES=on 才允许模型经 MCP 查看 / 拉取 / 写入已授权主机上
// 令牌允许目录内的文件(默认关闭;还要求 ExecEnabled,因为所有闸门都复用模型执行这一套)。
FilesEnabled bool
// AgentDistDir 是 Agent 二进制的分发目录(RELAYMESH_AGENT_DIST_DIR 或自动探测的结果,见 installer.ResolveDir)。
// 为空或目录里没有 Agent 时,服务端不提供安装源,Web 回退为 GitHub Release 来源的安装命令。
AgentDistDir string
// Version 是 Hub 自己的版本号(构建时注入,或由 internal/buildinfo 从模块版本得出)。只用来在 /status 的 install 字段里
// 告诉前端「这个 Hub 对应哪个 GitHub Release」:没有 Agent 安装源时,前端据此把 GitHub 来源的命令固定到同一个版本
// (而不是最新正式版)。开发版与未知版本换算不出 Release 标签,前端会改为提示。
Version string
// SSHSecretKey 是 SSH 后端保存凭据所用的主密钥(RELAYMESH_SSH_SECRET_KEY);缺失或过弱时 SSH 主机功能整体关闭。
// 它独立于 JWT 密钥:Hub 只用它加密 / 解密保存的 SSH 凭据,不会用于签发或校验任何其他内容。
SSHSecretKey string
// 以下字段主要用于测试,零值取生产默认值。
Now func() time.Time
WatchInterval time.Duration // 总闸轮询间隔,默认 2 秒
UnlockIdle time.Duration // 解锁令牌空闲失效,默认 15 分钟
UnlockAbsolute time.Duration // 解锁令牌绝对失效,默认 8 小时
// HandshakeTimeout 是 Agent 完成 hello 的期限,默认 termproto.HandshakeTimeout(10 秒)。
HandshakeTimeout time.Duration
// OpenTimeout / AttachTimeout 是等待 Agent 应答新建会话 / 附着的期限,默认 10 秒。
OpenTimeout time.Duration
AttachTimeout time.Duration
// GuardTickEvery 是会话守护与自动续跑检查的间隔,默认 1 分钟;AutoResumeBackoff 是自动续跑的退避(第 n 次续跑前等多久),
// 默认 5 分钟 / 20 分钟 / 60 分钟。二者只用来让实验与端到端测试不必真等几分钟(RELAYMESH_TERMINAL_GUARD_TICK_SEC /
// RELAYMESH_TERMINAL_AUTORESUME_BACKOFF_SEC),生产不设。
GuardTickEvery time.Duration
AutoResumeBackoff []time.Duration
// AutoResumeOK 非零时覆盖预设里的「续跑成功」判定时长(默认 10 分钟,#172),同样只供实验与端到端测试
// (RELAYMESH_TERMINAL_AUTORESUME_OK_SEC):让「跑满判定时长」在秒级发生;生产不设,按预设里的分钟数。
AutoResumeOK time.Duration
}
Options 是 Hub 的依赖与配置。
type PendingView ¶
type PendingView struct {
MachineCode string `json:"machine_code"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Arch string `json:"arch"`
AgentVersion string `json:"agent_version"`
Privilege string `json:"privilege"`
Kind string `json:"kind"` // persistent | temporary
IP string `json:"ip"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
Online bool `json:"online"`
DuplicateName bool `json:"duplicate_name,omitempty"`
}
PendingView 是发现列表中的待启用主机。
type PrefsLimits ¶
type PrefsLimits struct {
FixedColsMin int `json:"fixed_cols_min"`
FixedColsMax int `json:"fixed_cols_max"`
RecordMaxLinesMin int `json:"record_max_lines_min"`
RecordMaxLinesMax int `json:"record_max_lines_max"`
// 终端启动器预设:数量与各字段的最大长度(按字符数)。
LauncherMax int `json:"launcher_max"`
LauncherNameMax int `json:"launcher_name_max"`
LauncherDirMax int `json:"launcher_dir_max"`
LauncherCommandMax int `json:"launcher_command_max"`
// 预设里的会话守护(D-214):停摆判定时长的范围与默认值(分钟)、各文本字段的上限(按字符数)、
// 唤醒提示词里不允许出现的字符、一天参考的唤醒次数上限。
GuardSilenceMin int `json:"guard_silence_min"`
GuardSilenceMax int `json:"guard_silence_max"`
GuardSilenceDefault int `json:"guard_silence_default"`
GuardWorkflowMax int `json:"guard_workflow_max"`
GuardPromptMax int `json:"guard_prompt_max"`
GuardPromptUnsafe string `json:"guard_prompt_unsafe"`
GuardWakeMax int `json:"guard_wake_max"`
// GuardPromptDefault 是没写自定义提示词时服务端用的默认正文(占位符原样保留),表单里展示出来方便照着改。
GuardPromptDefault string `json:"guard_prompt_default"`
// 「非交互续聊」预设(#126):各文本字段的上限(按字符数)与默认提示词(%workflow 原样保留)。
// 旧版 Hub 没有这几项——界面据此判断这台 Hub 认不认识这种预设。
LauncherRunPromptMax int `json:"launcher_run_prompt_max"`
LauncherRunModelMax int `json:"launcher_run_model_max"`
LauncherRunBinMax int `json:"launcher_run_bin_max"`
LauncherRunPromptDefault string `json:"launcher_run_prompt_default"`
// LauncherRunNewPromptDefault 是「新开对话」(#176)没写自定义提示词时服务端用的默认正文(%workflow 原样保留);
// 旧版 Hub 没有它——界面据此判断这台 Hub 认不认识「新开对话」与「启用 Agent」。
LauncherRunNewPromptDefault string `json:"launcher_run_new_prompt_default"`
// LauncherRunMaxMinutes 是预设「最长运行时间」(#141)的上限,也是没填时的默认值(分钟):平台单次运行上限 7 天;下限固定 1 分钟。
// 旧版 Hub 没有这一项——界面据此决定要不要显示这个输入框。
LauncherRunMaxMinutes int `json:"launcher_run_max_minutes"`
}
PrefsLimits 是各项偏好的取值范围,界面据此校验输入。
type PrefsView ¶
type PrefsView struct {
FixedCols int `json:"fixed_cols"`
RecordMaxLines int `json:"record_max_lines"`
Limits PrefsLimits `json:"limits"`
// AgentAutoUpgrade 是「Agent 自动升级」总闸(默认关)。旧版 Hub 没有这一项——界面据此判断这台 Hub 认不认识自动升级。
AgentAutoUpgrade bool `json:"agent_auto_upgrade"`
// RecordLines 仅在设了行数上限时返回。
RecordLines *RecordLinesCoverage `json:"record_lines,omitempty"`
// Launchers 是终端启动器的预设(始终是数组,没有预设时为空数组)。它们另存一个键,随偏好一起返回,界面一次读取就够。
Launchers []store.TerminalLauncher `json:"launchers"`
}
PrefsView 是返回给界面的终端偏好。
type Reason ¶
type Reason string
Reason 是总闸的判定原因码(稳定的机器可读值,前端据此展示引导文案)。
const ( ReasonOK Reason = "ok" ReasonNoPassword Reason = "no_password" // 未设置 Web 登录密码:任何能到达服务的人都等同管理员,终端必须关闭 ReasonWeakJWTSecret Reason = "weak_jwt_secret" // JWT 签名密钥不合格:令牌可被伪造,终端必须关闭 ReasonDisabledByEnv Reason = "disabled_by_env" // 运维通过 RELAYMESH_TERMINAL=off 强制关闭 ReasonInternal Reason = "internal_error" // 无法确认前置条件(例如读取凭据失败):按关闭处理 )
type RecordLinesCoverage ¶
type RecordLinesCoverage struct {
// Online 是当前在线且已启用的主机数;Unsupported 是其中守护进程还不支持按行数限高的主机数。
Online int `json:"online"`
Unsupported int `json:"unsupported"`
}
RecordLinesCoverage 说明「终端限高」对在线主机的覆盖情况:升级只替换 Agent,不会重启会话守护进程, 而按行数丢弃是守护进程里的记录引擎做的,所以旧的守护进程会照旧只按字节配额滚动。
type RecordPage ¶
type RecordPage struct {
Data []byte
Seg uint32
Off uint32
NextSeg uint32
NextOff uint32
EOF bool
Skipped bool
}
RecordPage 是一次记录读取的结果:若干完整事件的原始编码与续读游标。
type RetentionView ¶
type RetentionView struct {
// RecordOff 为真表示服务端全局关闭终端记录(下发给每台主机的 Agent)。
RecordOff bool `json:"record_off"`
// RecordDays / RecordSessionMB / RecordHostMB 大于 0 时是服务端给主机记录加的上限,0 表示不额外限制(按主机本机配置)。
RecordDays int `json:"record_days"`
RecordSessionMB int `json:"record_session_mb"`
RecordHostMB int `json:"record_host_mb"`
// IndexDays 是已结束会话在清单里的保留天数;RunDays 是模型运行记录的保留天数。
IndexDays int `json:"index_days"`
RunDays int `json:"run_days"`
}
RetentionView 是服务端生效的记录与保留策略,供设置页只读展示。 这些值来自环境变量(RELAYMESH_TERMINAL_RECORD*),运行期间不能在界面里修改。
type RunEndEvent ¶
type RunEndEvent struct {
// Run 是终态记录的快照:命令是脱敏副本,预览是有界的;完整输出从不在这里。
Run model.TerminalRun
// CancelBy 是请求取消这次运行的来源(user / pause / revoked / system / model);
// 空表示没有任何人要求取消——取消状态加上空来源,就是「被主机侧中断」(典型是守护进程停了)。
CancelBy string
// Why 是终态原因的中文说明(如「主机重启,进程已丢失」);没有原因或原因码不认识时为空。
Why string
}
RunEndEvent 是一次模型运行终结时对外报告的事实。
type RunExit ¶
type RunExit struct {
Class RunExitClass
// Code 是 CLI 报出的 Connect 错误码(resource_exhausted、unavailable……);没有就空。
Code string
// Text 是一句中文:发生了什么、属于哪一类。
Text string
// Raw 是错误行的原文(取自已脱敏的输出预览,压成一行、限长);没有就空。
Raw string
// Retry 表示值得自动续跑。
Retry bool
}
RunExit 是对一次已终结运行的分辨结果。
type RunExitClass ¶
type RunExitClass string
RunExitClass 是一次已终结运行的退出类别。
const ( // ExitOK:正常结束(运行记录的状态是成功)。 ExitOK RunExitClass = "ok" // ExitCancelled:被取消(你、暂停、撤销授权……)。取消是意图,永远不自动续跑。 ExitCancelled RunExitClass = "cancelled" // ExitTimedOut:到了这次运行的最长运行时间,被主机强制结束。也是意图(预设里设的上限),不自动续跑。 ExitTimedOut RunExitClass = "timeout" // ExitNotRun:被拒绝 / 被闸门否决,根本没有执行。 ExitNotRun RunExitClass = "not_run" // ExitLost:运行状态丢失(主机重启或掉线):没法确认结果,只通知。 ExitLost RunExitClass = "lost" // ExitRetriable:CLI 自报「可重试」(服务端限流、连接失败……)。值得退避之后自动续跑。 ExitRetriable RunExitClass = "retriable" // ExitActionRequired:CLI 自报「要你处理」(登录失效、额度用尽、需要确认……)。重试没有用,要通知你。 ExitActionRequired RunExitClass = "action_required" // ExitNonRetriable:CLI 自报「不可重试」。不自动续跑。 ExitNonRetriable RunExitClass = "non_retriable" // ExitCrashed:进程被信号终止。SIGKILL / SIGSEGV 这类崩溃(常见于内存不足被系统杀掉)值得续跑一次; // SIGTERM / SIGINT 这类像是被人或系统有意结束的不续跑。 ExitCrashed RunExitClass = "crashed" // ExitUnknown:退出码非 0,但输出末尾没有认得出的 CLI 错误类别。只通知,不自动续跑。 ExitUnknown RunExitClass = "unknown" )
type RunFailureView ¶
type RunFailureView struct {
// Class 是 retriable / action_required / non_retriable / crashed / unknown。
Class string `json:"class"`
// Code 是 CLI 报出的 Connect 错误码;没有就不出现。
Code string `json:"code,omitempty"`
// Text 是一句中文。
Text string `json:"text"`
// Raw 是错误行原文(已脱敏)。
Raw string `json:"raw,omitempty"`
// Retry 表示这类失败值得(自动)重试。
Retry bool `json:"retry,omitempty"`
}
RunFailureView 是界面上显示的「这次运行为什么失败」:只给异常退出的运行。
type RunPage ¶
type RunPage struct {
Data []byte
Off uint64 // 第一个字节在该路输出中的位置
Next uint64 // 继续读取应使用的偏移
Total uint64 // 该路输出到目前为止产生的总字节数
Gap bool
EOF bool
Running bool
}
RunPage 是一次运行输出读取的结果。
type SSHAddRequest ¶
type SSHAddRequest struct {
Remark string `json:"remark"`
Address string `json:"address"`
User string `json:"user"`
AuthType string `json:"auth_type"`
Password string `json:"password"`
PrivateKey string `json:"private_key"`
Passphrase string `json:"passphrase"`
Fingerprint string `json:"fingerprint"`
// DefaultForNewModels 是这台主机对新建模型授权的默认态(allow / deny,缺省 deny),只在新增主机时生效。
DefaultForNewModels string `json:"default_for_new_models"`
// Gateway 非空表示经网关主机(机器码)接入:由它出站连接目标、持有人工终端会话,并把登录凭据保存在自己的存储里
// (Hub 不保存凭据、不直连)。目标是 POSIX 环境时模型也能通过它执行。空串即 Hub 直连(凭据由 Hub 密封保存,仅供模型执行)。
Gateway string `json:"gateway"`
}
SSHAddRequest 是登记一台 SSH 主机的请求。Fingerprint 必须是管理员核对过的、探测阶段给出的指纹。
type SSHConnUpdateRequest ¶
type SSHConnUpdateRequest struct {
Address string `json:"address"`
User string `json:"user"`
AuthType string `json:"auth_type"`
Password string `json:"password"`
PrivateKey string `json:"private_key"`
Passphrase string `json:"passphrase"`
// Gateway 改变接入方式:nil 表示不改;空串表示改为由 Hub 直连;机器码表示改接到那台网关主机。
// 新的连接途径同样要先真实连通一次才会保存。
Gateway *string `json:"gateway"`
}
SSHConnUpdate 是对已登记 SSH 主机连接信息的修改:Address / User 为空表示不改;AuthType 为空表示不改凭据。
type SSHProbeResult ¶
type SSHProbeResult struct {
Address string `json:"address"`
KeyType string `json:"key_type"`
Fingerprint string `json:"fingerprint"`
}
SSHProbeResult 是探测到的主机密钥,供管理员核对指纹。
type SSHStatus ¶
type SSHStatus struct {
Enabled bool `json:"enabled"`
Reason string `json:"reason,omitempty"` // no_secret_key | weak_secret_key
Message string `json:"message,omitempty"`
Max int `json:"max_hosts"`
}
SSHStatus 是 SSH 后端的启用状态。
type SSHTestResult ¶
type SSHTestResult struct {
OK bool `json:"ok"`
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Hostname string `json:"hostname,omitempty"`
OS string `json:"os,omitempty"`
Arch string `json:"arch,omitempty"`
User string `json:"user,omitempty"`
Home string `json:"home,omitempty"`
LatencyMS int64 `json:"latency_ms,omitempty"`
}
SSHTestResult 是一次连接测试的结果(失败也以 200 返回,错误码与消息在字段里)。
type SSHView ¶
type SSHView struct {
Address string `json:"address"`
User string `json:"user"`
Auth string `json:"auth"`
KeyType string `json:"key_type"`
Fingerprint string `json:"fingerprint"`
KeyState string `json:"key_state,omitempty"` // mismatch:出现过密钥不一致,需要管理员重新确认指纹
HasSecret bool `json:"has_secret"`
Error string `json:"error,omitempty"`
CheckedAt *time.Time `json:"checked_at,omitempty"`
OKAt *time.Time `json:"ok_at,omitempty"`
Backend bool `json:"backend_enabled"`
// Gateway 非空表示经网关主机(机器码)接入:由网关出站连接目标并保存登录凭据;GatewayReady 是网关此刻是否在线且开启了网关能力。
Gateway string `json:"gateway,omitempty"`
GatewayReady bool `json:"gateway_ready,omitempty"`
// CredOnGateway 表示登录凭据保存在网关自己的存储里(Hub 没有副本,也就不需要 SSH 主密钥);
// CredMissing 表示已确认网关上没有这台主机的凭据,需要管理员重新填写。
CredOnGateway bool `json:"cred_on_gateway,omitempty"`
CredMissing bool `json:"cred_missing,omitempty"`
// TermOnly 表示这台经网关接入的主机登记时探测不出 POSIX 环境,只能当人工终端用。
TermOnly bool `json:"term_only,omitempty"`
// GatewayDenied 表示承载这台主机的网关在本机用 --deny-model-exec 一票否决了模型执行(服务端无法更改)。
GatewayDenied bool `json:"gateway_denied,omitempty"`
}
SSHView 是主机视图里 SSH 相关的部分:不含任何凭据。
type ScreenEvent ¶
type ScreenEvent struct {
PresetID string
Name string // 预设名
Machine string // 主机码
WorkflowID string
// Approval 为 true 表示刚进入审批等待,false 表示审批等待结束(批准、跳过或中断)。
Approval bool
// Episode 标识同一次审批等待(预设 + 会话 + 开始时间),用来给通知去重。
Episode string
// Reminder 为 0 表示首次;大于 0 表示同一次审批等待没人处理,第几次提醒(通知 ID 带上它,闸才不会当作重复丢掉)。
Reminder int
// 状态机记录结果:IdentityID 为 0 表示没有可归属的 Agent 会话(还没有 hook 事件),此时只有通知,没有状态变化。
IdentityID uint
SessionID uint
State string
Sub string
Source string // 现在这个状态是谁说的(hook / tui / run)
Since time.Time
}
ScreenEvent 是托管终端屏幕上出现的值得上层关心的变化(目前只有审批等待的开始 / 结束)。
type SessionEnablePreset ¶
SessionEnablePreset 是这个工作流已有的「启用 Agent」预设(再次启用会复用它)。
type SessionEnablePreview ¶
type SessionEnablePreview struct {
WorkflowID string `json:"workflow_id"`
Title string `json:"title,omitempty"`
// Pending 表示这个工作流还是「待接入」(会话行全是网页新建的占位):只有这样的才能被启用。
Pending bool `json:"pending"`
// BoundDir 是网页新建这个会话时绑定的项目目录(#184;没绑定时为空)。绑定后智能体第一次汇报带的 project_directory
// 必须与它一致(D-161),所以没填运行目录时默认用它,填了不同的目录会报 dir_mismatch。
BoundDir string `json:"bound_dir,omitempty"`
// Host 是要运行的主机(机器码);没选、且没法自动选定时是空串,候选在 Hosts 里。
Host string `json:"host"`
Hosts []SessionRunHost `json:"hosts"`
Dir string `json:"dir"`
Bin string `json:"bin"`
Model string `json:"model"`
// Posture 是生效的权限姿态(allowlist / force)。
Posture string `json:"posture"`
// NewConversation 表示这次会新开对话(命令里没有 --resume);ConversationID 是续聊时要接着的对话,新开时为空。
NewConversation bool `json:"new_conversation"`
ConversationID string `json:"conversation_id"`
// Prompt 是实际交给智能体的提示词(%workflow 已替换);DefaultPrompt 是没填自定义提示词时的默认正文(%workflow 原样保留)。
Prompt string `json:"prompt"`
DefaultPrompt string `json:"default_prompt"`
// Command 是将要在主机上运行的完整命令(只读展示,方便核对);拼不出来时为空。
Command string `json:"command"`
MaxRunMinutes int `json:"max_run_minutes"`
AutoResume bool `json:"auto_resume"`
Warnings []string `json:"warnings"`
Issues []SessionRunIssue `json:"issues"`
CanRun bool `json:"can_run"`
// Preset / LastRun 在这个工作流之前启用过时有:预设(再次启用复用它)与它最近一次运行的现状。
Preset *SessionEnablePreset `json:"preset,omitempty"`
LastRun *LauncherRunView `json:"last_run,omitempty"`
}
SessionEnablePreview 是弹窗里的只读预览:不产生任何记录,也不需要解锁。
type SessionLauncherSuggest ¶
type SessionLauncherSuggest struct {
Name string `json:"name"`
Host string `json:"host,omitempty"`
HostTitle string `json:"host_title,omitempty"`
Dir string `json:"dir"`
WorkflowID string `json:"workflow_id"`
Posture string `json:"posture"`
// NeedsHost 表示主机没法唯一确定(会话没上报主机名,或有多台同名主机):界面要让人先选一台,不能一键创建。
NeedsHost bool `json:"needs_host,omitempty"`
}
SessionLauncherSuggest 是没有对应预设时的一份预填:启动器「本项目」标签顶部据此给「为这个会话创建续聊预设」。
type SessionLauncherView ¶
type SessionLauncherView struct {
ID string `json:"id"`
Name string `json:"name"`
Host string `json:"host"`
HostTitle string `json:"host_title,omitempty"`
Dir string `json:"dir"`
// ConversationID 是这次运行实际要接着的对话(预设里固定的,或工作流里最近一个有动静的);还不知道是空。
ConversationID string `json:"conversation_id,omitempty"`
Model string `json:"model,omitempty"`
Posture string `json:"posture"`
// MaxRunSeconds 是这次运行的最长运行时间(秒)。
MaxRunSeconds int `json:"max_run_seconds"`
// Command 是拼出的整行命令(只读预览;缺对话编号时为空)。
Command string `json:"command,omitempty"`
Issues []SessionRunIssue `json:"issues,omitempty"`
Warnings []string `json:"warnings,omitempty"`
CanRun bool `json:"can_run"`
// Busy 表示现在不能运行,是因为对话还在运行或这个预设上一次运行没结束(run_active / conversation_live):
// 界面在这种时候不显示「运行」按钮(状态块已经在说它正在工作),而不是显示一个灰掉的按钮。
Busy bool `json:"busy"`
// LastRun 是这个预设最近一次运行的现状(没运行过是 null)。
LastRun *LauncherRunView `json:"last_run"`
}
SessionLauncherView 是一条与会话对应的非交互续聊预设:确认窗要展示的内容,以及此刻能不能运行。
type SessionLaunchersView ¶
type SessionLaunchersView struct {
WorkflowID string `json:"workflow_id"`
ConversationID string `json:"conversation_id,omitempty"`
// SessionHost 是会话上报的主机名;Host 是对上主机清单后唯一确定的机器码(没法唯一确定时为空)。
SessionHost string `json:"session_host,omitempty"`
Host string `json:"host,omitempty"`
// Hosts 是名字与会话上报的主机一致的主机(机器码):启动器「本项目」标签按它筛预设;空表示不按主机筛。
Hosts []string `json:"hosts"`
// Dir 是会话上报的项目目录(主机上的绝对路径);没有或不是绝对路径时为空。
Dir string `json:"dir,omitempty"`
Presets []SessionLauncherView `json:"presets"`
// Suggest 只在没有对应预设、又足以建议时给出;建议不出来时 Reason 说明为什么。
Suggest *SessionLauncherSuggest `json:"suggest,omitempty"`
Reason string `json:"reason,omitempty"`
}
SessionLaunchersView 是 GET /launchers/for-session 的返回。
type SessionRunHost ¶
type SessionRunHost struct {
MachineCode string `json:"machine_code"`
Hostname string `json:"hostname"`
Remark string `json:"remark,omitempty"`
OS string `json:"os,omitempty"`
Online bool `json:"online"`
// Matched 表示这台主机的名字(备注,没有备注时是主机名;主机自报的主机名作别名)与会话上报的一致,口径同 terminal_exec 的 matchHosts。
Matched bool `json:"matched"`
}
SessionRunHost 是面板里「在哪台主机上运行」的一个候选。
type SessionRunIssue ¶
SessionRunIssue 是此刻点「运行」会被拒绝的一个原因(预览里列出,真正点运行时服务端再判断一次,口径相同)。
type SessionRunPreview ¶
type SessionRunPreview struct {
WorkflowID string `json:"workflow_id"`
ConversationID string `json:"conversation_id,omitempty"`
// ClientKind 是这个对话来自哪个客户端(cli / ide);IDE 里的对话 `agent --resume` 多半找不到。
ClientKind string `json:"client_kind,omitempty"`
// SessionHost 是会话上报的主机名。
SessionHost string `json:"session_host,omitempty"`
// Host 是选中的机器码(没选中是空)。
Host string `json:"host,omitempty"`
Hosts []SessionRunHost `json:"hosts"`
Dir string `json:"dir,omitempty"`
Bin string `json:"bin"`
Model string `json:"model,omitempty"`
// Posture 是权限姿态:allowlist | force。
Posture string `json:"posture"`
// Prompt 是实际交给 agent 的提示词(%workflow 已替换);DefaultPrompt 是不改动时用的默认提示词。
Prompt string `json:"prompt"`
DefaultPrompt string `json:"default_prompt"`
// Command 是拼出的整行命令(只读预览;缺对话编号或目录时为空)。
Command string `json:"command,omitempty"`
Issues []SessionRunIssue `json:"issues,omitempty"`
Warnings []string `json:"warnings,omitempty"`
CanRun bool `json:"can_run"`
// LastRun 是这个工作流最近一次会话页运行的现状(没有运行过是 null)。
LastRun *LauncherRunView `json:"last_run"`
}
SessionRunPreview 是面板打开、或改动选项时的只读预览:会在哪台主机、哪个目录、接着哪个对话运行,拼出来的命令是什么, 现在能不能点「运行」、不能的原因。
type ThreadView ¶
type ThreadView struct {
Key string `json:"key"`
Target string `json:"target"`
CredentialID uint `json:"credential_id"`
CredentialName string `json:"credential_name"`
ClientName string `json:"client_name,omitempty"`
Thread string `json:"thread,omitempty"`
WorkflowID string `json:"workflow_id,omitempty"`
Total int `json:"total"`
Active int `json:"active"`
Awaiting int `json:"awaiting"`
FirstAt time.Time `json:"first_at"`
LastAt time.Time `json:"last_at"`
LastRunID string `json:"last_run_id"`
LastState string `json:"last_state"`
LastTitle string `json:"last_title"`
}
ThreadView 是模型线程的汇总(侧栏条目用)。线程键 = 凭据 × 主机 × 线程标签,混合令牌且带 workflow_id 时为 工作流 × 主机。
type UninstallOutcome ¶
type UninstallOutcome string
UninstallOutcome 是删除主机时「同时卸载设备端」的结果,原样返回给界面,让管理员知道设备上到底发生了什么。
const ( UninstallNone UninstallOutcome = "" // 没有请求卸载 UninstallRequested UninstallOutcome = "requested" // 已向在线的 Agent 下发卸载请求(卸载在设备上异步完成) UninstallOffline UninstallOutcome = "offline" // 主机不在线,没法下发——需要在设备上手动卸载 UninstallUnsupported UninstallOutcome = "unsupported" // 在线,但这个 Agent 不支持(旧版本 / 不是常驻服务 / 暂不支持的系统) UninstallFailed UninstallOutcome = "failed" // 下发时出错 )
type UpgradeJobView ¶
type UpgradeJobView struct {
ID string `json:"id"`
State string `json:"state"`
// Origin 为 "auto" 表示这次升级是主机自己发起的静默自动升级;缺省是管理员在 Web 上点的。
Origin string `json:"origin,omitempty"`
// Stalled 表示请求超过一段时间没有任何进展(仅对未结束的请求)。
Stalled bool `json:"stalled,omitempty"`
From string `json:"from"`
To string `json:"to"`
// Code / Detail 在失败时说明原因;RolledBack 表示新版本没有连上服务端,已经自动还原成旧版本。
Code string `json:"code,omitempty"`
Detail string `json:"detail,omitempty"`
RolledBack bool `json:"rolled_back,omitempty"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
}
UpgradeJobView 是返回给界面的升级请求状态。
type UpgradeWindowView ¶
type UpgradeWindowView struct {
Open bool `json:"open"`
Ticket string `json:"ticket"`
Until time.Time `json:"until"`
RemainingSeconds int `json:"remaining_seconds"`
// BaseVersion 是开窗时这台主机的 Agent 版本。
BaseVersion string `json:"base_version,omitempty"`
}
UpgradeWindowView 是返回给界面的升级窗口状态。Ticket 只在窗口开着时返回,界面据此拼出升级命令。
type WebUpgradeSessions ¶
type WebUpgradeSessions struct {
Running int `json:"running"` // 正在运行的会话数
Attached int `json:"attached"` // 其中此刻有人正在查看的
Alt int `json:"alt"` // 其中正在运行全屏程序(如 vim)的
ModelRunning int `json:"model_running"` // 进行中的模型运行数
// Persistent 表示会话由独立的守护进程持有:升级只重启 Agent,会话不受影响;
// 为 false 时会话与 Agent 同生共死,升级会结束它们。
Persistent bool `json:"persistent"`
}
WebUpgradeSessions 汇总一台主机上「升级会影响到的东西」,供界面在确认前提示,也是服务端要求确认的依据。
Source Files
¶
- access.go
- agent.go
- agent_run.go
- agent_version.go
- archive_rest.go
- attach.go
- audit.go
- auto_resume.go
- auto_upgrade.go
- config.go
- exec_agent.go
- exec_config.go
- exec_events.go
- exec_notify.go
- exec_peer.go
- exec_rest.go
- exec_result.go
- exec_runs.go
- exec_service.go
- exec_text.go
- files_agent.go
- files_config.go
- files_download.go
- files_service.go
- files_tickets.go
- gate.go
- guard.go
- guard_eval.go
- guard_headless.go
- guard_permit.go
- guard_rest.go
- handshake.go
- hosts.go
- hub.go
- hub_guard.go
- installer_rest.go
- launcher_exec.go
- launcher_run.go
- launchers.go
- lifecycle_rest.go
- localterm.go
- localterm_rest.go
- lost_rest.go
- prefs.go
- records.go
- records_rest.go
- registry.go
- rest.go
- run_exit.go
- run_watch.go
- screen.go
- session_enable.go
- session_index.go
- session_launchers.go
- session_run.go
- ssh_backend.go
- ssh_gateway.go
- ssh_gateway_creds.go
- ssh_peer.go
- ssh_rest.go
- streamjson.go
- upgrade_window.go
- web_upgrade.go