Documentation
¶
Overview ¶
Package daemon assembles the agentred daemon: state, gateway, rpc server, handlers, notifier. Lives one level up from sub-packages to avoid import cycles (state/handlers/rpc don't depend on daemon).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildIdentity ¶
func BuildIdentity() string
BuildIdentity returns the version and commit injected into the agentred binary.
func InstallCtlTools ¶
InstallCtlTools 装 agrctl 并铺 ctlskill,返回装好的 agrctl 路径。没有随包的 agrctl 时 什么都不装(返回空路径):技能文档里写的是 agrctl 的绝对路径,指向一个不存在的文件 只会让 agent 白跑一趟。安装本身与桌面端共用 agrctlinstall / ctlskill,不另起一份。
func InstallCtlToolsOnBoot ¶
InstallCtlToolsOnBoot 是 `agentred run` 启动时的那一次安装:路径按本机现取,失败只记 warn —— 没装上 agrctl 不妨碍 daemon 执行会话,只是会话里用不了 agrctl。AGENTRE_ENV=test 时跳过(与桌面端 ctlskill_svc.InstallOnBoot 同一道闸),测试进程不写用户 home。
func ValidAdvertiseAddr ¶
ValidAdvertiseAddr rejects an Options.AdvertiseAddr no other machine could reach. Getting it wrong is silent otherwise: the address is dropped and all that is left is "direct never connects to this host", so the caller that reads the operator's configuration refuses at startup instead. An empty value is the automatic behavior and is accepted.
Types ¶
type CtlTools ¶
type CtlTools struct {
// Home 是主机用户的 home 目录(ctlskill 的两种形态都在它下面)。
Home string
// AppDataDir 是 Agentre 桌面端的数据目录;agrctl 装到 <AppDataDir>/bin/agrctl,
// 与桌面端同一个位置。
AppDataDir string
// Source 是随发布包放在 agentred 旁边的 agrctl;空 = 这份构建没带它,什么都不装。
Source string
// Version 是安装标记里的版本,变了才重装。
Version string
}
CtlTools 是一次 agrctl + ctlskill 安装的全部输入(规格 2026-09-22 agrctl-resource-management「Executors / agentred」:agentred 启动时把 agrctl 和 ctlskill 装到该主机用户的目录下,与桌面端的安装位置相同)。
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon assembles and runs all agentred sub-systems.
func New ¶
New constructs a Daemon from Options. It loads persistent state, creates sub-systems, and registers all static (non-per-conn) RPC methods.
func (*Daemon) DBStat ¶
DBStat 交出库文件的路径与体量,喂给两处状态查询(IPC 的 /local/status 与 RPC 的 health.ping)。统计不到的文件按 0 计:体量是给人看的参考值,读不到某个旁文件不该 让一次状态查询失败。
func (*Daemon) Run ¶
Run starts the HTTP gateway, IPC unix socket, and LAN WebSocket server, blocking until ctx is canceled or a fatal error occurs.
func (*Daemon) SocketPath ¶
SocketPath returns the daemon's platform-local IPC endpoint. The method name remains stable for existing status JSON and Unix callers.
type Options ¶
type Options struct {
DataDir string
LANHost string
LANPort int
// TLS keeps the LAN port wss-only. Without TLSCertFile/TLSKeyFile it serves
// the certificate lancert persists in DataDir, and Run fails when that
// certificate cannot be persisted.
TLS bool
TLSCertFile string
TLSKeyFile string
// AdvertiseAddr is the address this daemon is reached at from other
// machines — both the one `agentred pair` prints and the one automatic
// direct connections dial — instead of the ones it sees on its own
// interfaces. A daemon behind NAT (a container on a bridge network, a
// published port) can derive neither the reachable host nor the mapped port
// from the inside, so the operator states it. Empty keeps the automatic
// behavior.
AdvertiseAddr string
// AccountServerURL is the account server base URL used for the daemon's
// outbound relay connection. An empty URL leaves LAN-only operation intact.
AccountServerURL string
// CCUsageFetcher 注入 claudecode.usage handler 用的 OAuth 拉取函数。
// 留空 → 走 ccoauth.NewLocalFetcher()(从当前机器环境读 token + 调真实 endpoint);
// 集成测试传入 stub 屏蔽真实网络 / 真实 keychain。
CCUsageFetcher handlers.CCUsageFetcher
// contains filtered or unexported fields
}
Options configures the Daemon at construction time.
type ProviderLookup ¶
type ProviderLookup struct {
// contains filtered or unexported fields
}
ProviderLookup implements httpgateway.ProviderLookup: given a stable provider key, return the full LLMProvider entity from agentred state.
func NewProviderLookup ¶
func NewProviderLookup(s *state.State) *ProviderLookup
NewProviderLookup constructs a ProviderLookup backed by the given state.
func (*ProviderLookup) FindByKey ¶
func (l *ProviderLookup) FindByKey(ctx context.Context, key string) (*llm_provider_entity.LLMProvider, error)
FindByKey satisfies httpgateway.ProviderLookup and handlers.LLMProviderLookupPort. It errors when the key has no metadata in state.
func (*ProviderLookup) ResolveModel ¶
func (l *ProviderLookup) ResolveModel(ctx context.Context, providerKey, modelKey string) (handlers.EffectiveModel, error)
ResolveModel satisfies handlers.LLMProviderLookupPort: resolve the provider's execution model from the daemon's own catalog (decision 11).
- modelKey 空 → provider-default:必须解析出 Provider 当前启用的默认模型。 Provider 存在但无合法启用默认模型(无默认 / 默认缺失 / 默认停用)按配置损坏 严格阻止——绝不回落到旧单模型字段或空值静默执行。只有 Provider 本身缺失/停用 才走 resolveTarget 的 provider-default 回退语义(回退 agent 绑定或 CLI 登录态)。
- modelKey 非空 → fixed-model:精确查 Models 里启用模型,缺失/停用返回 error, 由调用方严格阻止本轮 —— 绝不静默降级为默认模型。
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package enginesnapshot pulls the account engine subset needed by agentred.
|
Package enginesnapshot pulls the account engine subset needed by agentred. |
|
Package handlers implements each daemon RPC method as a thin function.
|
Package handlers implements each daemon RPC method as a thin function. |
|
mock_handlers
Package mock_handlers is a generated GoMock package.
|
Package mock_handlers is a generated GoMock package. |
|
Package identity owns protocol-neutral daemon identity derivation.
|
Package identity owns protocol-neutral daemon identity derivation. |
|
Package lancert owns the self-signed certificate agentred serves on its LAN port when the operator configured none.
|
Package lancert owns the self-signed certificate agentred serves on its LAN port when the operator configured none. |
|
Package migrations 汇总并执行 agentred 自己的 SQLite 数据库迁移。
|
Package migrations 汇总并执行 agentred 自己的 SQLite 数据库迁移。 |
|
Package pairing implements one-shot pairing-code generation, deviceToken minting, and per-IP rate-limiting for agentred's auth handshake.
|
Package pairing implements one-shot pairing-code generation, deviceToken minting, and per-IP rate-limiting for agentred's auth handshake. |
|
Package portforward 是端口转发在**被访问的那台设备**上的判定面:这台机器允许把 哪些目标转出去(声明族),以及一次 open 该不该落地(授权闸门)。
|
Package portforward 是端口转发在**被访问的那台设备**上的判定面:这台机器允许把 哪些目标转出去(声明族),以及一次 open 该不该落地(授权闸门)。 |
|
Package remotefs 是 agentred daemon 端 remotefs.* RPC 的 handler 实现。
|
Package remotefs 是 agentred daemon 端 remotefs.* RPC 的 handler 实现。 |
|
repository
|
|
|
session_repo
Package session_repo 提供 agentred 侧 daemon_sessions 表的持久化访问 —— 会话在这台 daemon 上的**身份与生命周期**:「这条会话是谁的、在跑什么、处于哪一步」。
|
Package session_repo 提供 agentred 侧 daemon_sessions 表的持久化访问 —— 会话在这台 daemon 上的**身份与生命周期**:「这条会话是谁的、在跑什么、处于哪一步」。 |
|
session_repo/mock_session_repo
Package mock_session_repo is a generated GoMock package.
|
Package mock_session_repo is a generated GoMock package. |
|
Package sessions owns the daemon-level ownership of in-flight runtime generations.
|
Package sessions owns the daemon-level ownership of in-flight runtime generations. |
|
Package state owns agentred's single persistent JSON file.
|
Package state owns agentred's single persistent JSON file. |
|
Package transcriptimport 是 agentred daemon 端 transcriptimport.* RPC 的 handler 实现:发现候选、打开元信息、分页取回轮次(本文件),以及在本机执行一次导入 (execute.go —— 这一族里唯一写库的一条路径)。
|
Package transcriptimport 是 agentred daemon 端 transcriptimport.* RPC 的 handler 实现:发现候选、打开元信息、分页取回轮次(本文件),以及在本机执行一次导入 (execute.go —— 这一族里唯一写库的一条路径)。 |
|
Package workspacefs 是 agentred daemon 端 workspacefs.* RPC 的 handler 实现。
|
Package workspacefs 是 agentred daemon 端 workspacefs.* RPC 的 handler 实现。 |