docs(gateway): gateway 剩余文件注释改中文(逐行 1:1,代码零字节改动)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

主人 2026-10-03 拍板「注释一律中文」;gateway 至此整包注释中文化完成(本会话共 3 批:
已推库 16 个文件 + 本批剩余文件)。
校验:机械校验(非注释改动行)= 空;剥注释后代码文本逐行比对全等(不一致文件数 0);
全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
This commit is contained in:
AskaEth committed 2026-10-03 22:28:25 +08:00
1 parent 91e8d7a029
commit 074ffc4ebf
73 files changed
+2529 -2529

No files matched your search

+67 -67
View File
@@ -10,99 +10,99 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/model"
)
// Deps carries the gateway's injected dependencies. Every field is nil-tolerant
// except Auth, which is required (authentication backs login and every RBAC
// decision). Registry/Loop are satisfied by the concrete *capability.Registry and
// *loop.Loop; Sessions/Personas/Memories are satisfied by the concrete session
// manager, persona registry and memory store, and the handlers return [] only
// when a dependency is left nil.
// Deps 承载网关被注入的依赖。除 Auth 外每个字段都容忍
// nil,Auth 是必需的(认证支撑登录与每一个 RBAC
// 决策)。Registry/Loop 由具体的 *capability.Registry 与
// *loop.Loop 满足;Sessions/Personas/Memories 由具体的会话
// 管理器、人格注册表与记忆存储满足,只有当依赖留为
// nil 时 handler 才返回 []。
type Deps struct {
// Log is the base logger. Nil uses a discard logger.
// Log 是基础 logger。为 nil 时使用丢弃型 logger。
Log *slog.Logger
// Auth is the JWT/RBAC service. Required.
// Auth 是 JWT/RBAC 服务。必需。
Auth Authenticator
// Bus is the in-process event bus the WS hub subscribes to. Optional.
// Bus 是 WS hub 所订阅的进程内事件总线。可选。
Bus bus.Bus
// Registry enumerates capabilities/plugins/channels. Optional.
// Registry 枚举能力/插件/渠道。可选。
Registry CapabilityStore
// Loop runs chat turns. Optional (chat returns an error when unset).
// Loop 运行聊天回合。可选(未设置时 chat 返回错误)。
Loop Chatter
// Session lists channel sessions. Optional.
// Session 列出渠道会话。可选。
Session SessionStore
// Personas lists personas. Optional.
// Personas 列出人格。可选。
Personas PersonaStore
// Memories lists memory entries. Optional.
// Memories 列出记忆条目。可选。
Memories MemoryStore
// History is the persistent chat-history store (design/16). Optional; when nil the
// session/message endpoints degrade (list falls back to channel sessions, others 501).
// History 是持久化聊天历史存储(design/16)。可选;为 nil 时
// 会话/消息端点退化(列出回退到渠道会话,其余 501)。
History HistoryStore
// IoT lists IoT devices. Optional.
// IoT 列出 IoT 设备。可选。
IoT IoTStore
// Scheduler audits sub-agent context for the subagent_ask WS route.
// Optional (subagent_ask returns a clear error when unset).
// Scheduler 为 subagent_ask WS 路由审计子代理上下文。
// 可选(未设置时 subagent_ask 返回明确的错误)。
Scheduler SubagentAuditor
// Tasks queries task output for the task_output_query WS route.
// Optional (task_output_query returns a clear error when unset).
// Tasks 为 task_output_query WS 路由查询任务输出。
// 可选(未设置时 task_output_query 返回明确的错误)。
Tasks TaskOutputStore
// Automations lists automations and reminders. Optional.
// Automations 列出自动化与提醒。可选。
Automations AutomationStore
// Users lists accounts and API keys. Optional (falls back to the configured
// single admin account).
// Users 列出账号与 API key。可选(回退到已配置的
// 单个管理账号)。
Users UserStore
// Refresh is the opaque refresh-token store. Optional: when nil login omits
// refreshToken and /auth/refresh + /auth/logout answer not-configured.
// Refresh 是非透明 refresh token 存储。可选:为 nil 时登录省略
// refreshToken,/auth/refresh + /auth/logout 返回 not-configured。
Refresh RefreshGrantStore
// Backthink lists background-think records. Optional.
// Backthink 列出后台思考记录。可选。
Backthink BackthinkStore
// RAG backs the admin knowledge-base RAG module. Optional; list/search
// return empty when unset, and write endpoints report a clear 501.
// RAG 支撑管理侧知识库 RAG 模块。可选;未设置时列出/搜索
// 返回空,写端点报告明确的 501。
RAG RagStore
// LLM is the hot-swappable provider stack (models.json, design/04 §3.1).
// Optional: when nil the admin /llm endpoints fall back to the env config so
// pre-existing gateway tests keep working.
// LLM 是可热切换的 provider 栈(models.json,design/04 §3.1)。
// 可选:为 nil 时管理 /llm 端点回退到环境配置,使
// 既有的网关测试继续可用。
LLM *model.RuntimeLLM
// Channels is the runtime-editable channel-adapter config (channels.json).
// Optional: when nil the admin /channels/config endpoints return a clear
// not-configured error, matching how the LLM stack behaves when unset.
// Channels 是运行时可编辑的渠道适配器配置(channels.json)。
// 可选:为 nil 时管理 /channels/config 端点返回明确的
// not-configured 错误,与 LLM 栈未设置时的行为一致。
Channels ChannelConfigStore
// Plugins is the runtime-installable external tool provider manager
// (plugins.json + live MCP servers). Optional: when nil install answers a
// clear not-implemented error and uninstall falls back to a plain capability
// removal, so pre-existing gateway tests keep working.
// Plugins 是运行时可安装的外部工具 provider 管理器
// (plugins.json + 活的 MCP server)。可选:为 nil 时安装返回
// 明确的 not-implemented 错误,卸载回退为普通的能力
// 移除,使既有的网关测试继续可用。
Plugins *pluginmgr.Manager
// OwnerRegistrar stamps a scan-login's bound owner id into the owner
// whitelist (configs/users/owner.yaml) and hot-updates the live profile.
// Optional: when nil the weixin confirm flow still persists channels.json but
// skips the whitelist registration (best-effort by design).
// OwnerRegistrar 把扫码登录绑定的主人 id 盖进主人
// 白名单(configs/users/owner.yaml)并热更新活的 profile。
// 可选:为 nil 时 weixin 确认流程仍会持久化 channels.json,但
// 跳过白名单登记(按设计即为尽力而为)。
OwnerRegistrar OwnerRegistrar
// AuditStore persists the admin audit trail (observability → audit). When nil
// the gateway degrades to an in-memory store so the endpoint still returns
// data; the composition root injects NewSQLiteAuditStore over a.db for real
// persistence. Optional.
// AuditStore 持久化管理审计链(observability → audit)。为 nil 时
// 网关退化为内存存储,使端点仍能返回
// 数据;组合根注入基于 a.db 的 NewSQLiteAuditStore 以获得真实
// 持久化。可选。
AuditStore AuditStore
// DatabasePath is the resolved path of the SQLite database file the
// composition root actually opened (the value derived by resolveSQLitePath,
// which may differ from cfg.DB.SQLitePath when the data dir default applies).
// It backs the admin backup/restore endpoints. Optional; when empty those
// endpoints answer honestly with a clear not-configured error.
// DatabasePath 是组合根实际打开的 SQLite 数据库文件解析后
// 路径(由 resolveSQLitePath 推导的值,当数据目录默认值
// 生效时可能与 cfg.DB.SQLitePath 不同)。它支撑
// 管理备份/恢复端点。可选;为空时那些端点诚实作答,
// 返回明确的 not-configured 错误。
DatabasePath string
// DataDir is the resolved data directory (the value resolveDataDir returns,
// which may differ from cfg.DataDir when the OS default applies). It backs
// the image-upload store (<DataDir>/uploads) and its static route. Optional;
// when empty the upload handlers fall back to cfg.DataDir.
// DataDir 是解析后的数据目录(resolveDataDir 返回的值,当操作系统
// 默认值生效时可能与 cfg.DataDir 不同)。它支撑
// 图片上传存储(<DataDir>/uploads)及其静态路由。可选;
// 为空时上传 handler 回退到 cfg.DataDir。
DataDir string
// Streaming marks the injected Loop as streaming-capable (its OnStream is
// wired to publish ws.stream_chunk). When set the hub skips its own single
// final stream_chunk emission, since deltas already stream through OnStream.
// Streaming 标记注入的 Loop 具备流式能力(其 OnStream
// 已接线为发布 ws.stream_chunk)。设置后 hub 会跳过它自己的
// 单次最终 stream_chunk 发送,因为增量已通过 OnStream 流出。
Streaming bool
// Frontend is the SPA filesystem served for all non-API, non-WS routes.
// When nil the gateway serves no static assets (API and WS only). The
// embedded dist (internal/webui) or an external dist directory is used.
// Frontend 是为所有非 API、非 WS 路由提供的 SPA 文件系统。
// 为 nil 时网关不提供任何静态资产(只有 API 与 WS)。
// 使用内嵌的 dist(internal/webui)或外部 dist 目录。
Frontend fs.FS
// Webhooks are externally-mounted inbound HTTP handlers (endpoint path →
// handler), typically from channel adapters that receive webhook callbacks
// (e.g. webhook). Each is mounted on the ServeMux without gateway auth; the
// handler itself enforces its own signature/authorization (webhook HMAC).
// Optional.
// Webhooks 是外部挂载的入站 HTTP handler(端点路径 →
// handler),通常来自接收 webhook 回调的渠道适配器
// (例如 webhook)。每个都挂到 ServeMux 上且不经网关认证;
// handler 自身强制其签名/授权(webhook HMAC)。
// 可选。
Webhooks map[string]http.Handler
}