api

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CSPModeOff 关闭 CSP 头(仅用于排查兼容问题);其余安全头仍然下发。
	CSPModeOff = "off"
	// CSPModeReport 只上报不拦截(Content-Security-Policy-Report-Only),用于灰度观察。
	CSPModeReport = "report"
	// CSPModeEnforce 强制执行(默认)。
	CSPModeEnforce = "enforce"
)

Variables

This section is empty.

Functions

func BuildCSP

func BuildCSP(host string) string

BuildCSP 生成内容安全策略。

  • script-src 仅 'self':前端构建产物没有内联脚本(首屏主题脚本已外置为 /theme-init.js)。
  • style-src 保留 'unsafe-inline':Vue / 组件库会在运行时写入 style,CSP 对样式注入的风险远低于脚本。
  • 脚本、样式、字体等子资源只放行本站:页面不向任何第三方站点取资源(首屏不被外链阻塞,内网 / 离线可用,也不向第三方泄露访问者 IP)。 以前放行过 Google Fonts,实际上只有几处行内 code 用到其中一个字体;现在 Noto Sans Mono 的拉丁子集随应用自带(同源,font-src 'self' 已覆盖)。
  • connect-src 除 'self' 外显式列出当前主机的 ws/wss:部分浏览器的 'self' 不覆盖 WebSocket(终端依赖它)。
  • img-src 放开 http/https:Markdown 里允许引用外部图片;图片无法执行脚本。

func ConfigureTrustedProxies

func ConfigureTrustedProxies(engine *gin.Engine, raw string)

ConfigureTrustedProxies 按 RELAYMESH_TRUSTED_PROXIES 设置 Gin 的可信代理网段。

背景:Gin 默认信任全部代理,此时 c.ClientIP() 会采信客户端自带的 X-Forwarded-For 最左项, 而登录反爆破(RateLimiter)与终端预认证限流都以它为键,攻击者每次换一个头值即可绕过锁定。 配置错误时回退为默认网段(回环 + 私网)而不是 Gin 的「信任全部」,宁可少信任也不多信任。

func GzipMiddleware

func GzipMiddleware() gin.HandlerFunc

GzipMiddleware 为 HTTP 响应提供动态 Gzip 压缩,显著缩减大 JSON 和富文本在小带宽服务器上的网络传输体积

func PrecompressedAssets added in v2.1.0

func PrecompressedAssets(fsys fs.FS) gin.HandlerFunc

前端产物的 Brotli 预压缩(#186)。

前端构建(frontend/build.precompress.ts)在 /assets 下的每个 .js / .css 旁写一个同名加 .br 的文件(质量 11,只在构建时压一次,随 web/dist 一起提交并内嵌)。 浏览器的 Accept-Encoding 带 br 时,这里直接把 .br 当作响应正文发出去:比请求时的动态 gzip(gzip.go,级别 4)小约 19%, 而且不占 CPU。首屏 4 个脚本 + 1 个样式合计少下约 86 KB,生产带宽约 1~3 Mbps 时首访快约 0.2~0.7 秒。

只处理 GET / HEAD 请求的「带哈希的 /assets 产物」(isHashedAsset,缓存一年且 immutable):

  • 没有 .br、客户端不接受 br(Chrome 只在 HTTPS 下才声明 br)、不是带哈希的产物:原样放行,走后面的动态 gzip 与静态文件处理,行为与以前一致;
  • 命中时响应带 Content-Encoding: br 与 Vary: Accept-Encoding(缓存按编码分开存),Content-Type 取原文件的扩展名(不是 .br)。

必须挂在 GzipMiddleware 之前:命中后直接结束请求,不会被二次压缩。

func RedactRequestURI

func RedactRequestURI(uri string) string

RedactRequestURI 把访问日志里的凭据脱敏:

  • 查询参数 token / ticket / access_token / key / api_key / password 的值
  • /api/ 下的查询参数 q:用户敲的搜索原文
  • MCP 路径中内嵌的令牌:/mcp/token/<令牌>、/mcp/<令牌> 与能力 URL /mcp/c/<令牌>
  • 文件拉取票据:/files/dl/<票据>
  • Agent 安装源的窗口票据:/i/<票据>/<文件名>

func RedactingLogFormatter

func RedactingLogFormatter(param gin.LogFormatterParams) string

RedactingLogFormatter 与 Gin 默认日志格式一致,只是对请求 URI 做脱敏。

func RedactingRecovery

func RedactingRecovery() gin.HandlerFunc

RedactingRecovery 与 gin.Recovery 一样把 panic 转成 500,但日志里的请求行经过脱敏: gin 默认的恢复中间件会把完整的请求行(含 /mcp/c/<令牌> 这样的网址)连同请求头一起打进日志。

func ResolveCSPMode

func ResolveCSPMode(raw string) (mode string, warning string)

ResolveCSPMode 规范化 RELAYMESH_CSP。空值与非法值都回落到 enforce,并返回提示文案(非法时)。

func ResolveTrustedProxies

func ResolveTrustedProxies(raw string) (proxies []string, mode string, err error)

ResolveTrustedProxies 解析 RELAYMESH_TRUSTED_PROXIES,返回可直接传给 gin.Engine.SetTrustedProxies 的列表。

  • 空值:默认网段(回环 + 私网);
  • none:不信任任何代理,ClientIP() 恒为直连对端地址(返回 nil 列表);
  • *:信任全部代理(升级前的旧行为;X-Forwarded-For 可被任意客户端伪造,仅在明确知道后果时使用);
  • 其他:逗号 / 空白分隔的 IP 或 CIDR,关键字 default 展开为默认网段(例如 "default,203.0.113.0/24")。 显式列出即完全以所列为准,不会隐式追加默认网段。

none 与 * 必须单独出现。任何无法识别的条目都会返回错误,由调用方决定回退策略。

func SecurityHeadersMiddleware

func SecurityHeadersMiddleware(mode string) gin.HandlerFunc

SecurityHeadersMiddleware 下发基础安全响应头,并按模式附带 CSP。

Types

type APIHandler

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

func NewAPIHandler

func NewAPIHandler(cfg *config.Config, st *store.Store, mcpServer *mcp.Server, broker *SSEBroker) *APIHandler

func (*APIHandler) AckKeyNotice added in v2.2.0

func (h *APIHandler) AckKeyNotice(c *gin.Context)

「重点」级进度通知的确认接口(#275)。

POST /api/v1/sessions/:id/ack    确认「已收到」一条重点通知

规则:

  • 只有网页登录会话能调用:它挂在受保护的 /api/v1 分组下,认证中间件对管理类接口一律拒绝 MCP 令牌(V9,403 mcp_token_forbidden), 所以智能体既不能替用户确认,也看不到「是否被确认」这件事——确认不反向通知智能体;
  • 只对 kind = notice 且 notice_level = key 的会话有效:别的会话返回 400(code = not_key_notice),不存在返回 404;
  • 幂等:重复确认返回同一条会话、changed = false,不改写第一次确认的时间,也不重复广播;
  • 不改 updated_at、不进收件箱、不唤醒任何等待者、不改变回复窗口与收尾门。

确认之后广播两个事件:

  • session_updated:载荷是确认后的完整会话(带 acked_at),别的标签页据此把滑动条换成「已确认 · 时间」;
  • key_notice_updated:{workflow_id, unacked_key_notices},侧栏的「重点」徽标据此校准(不必重拉整张会话列表)。

func (*APIHandler) AckReports

func (h *APIHandler) AckReports(c *gin.Context)

func (*APIHandler) AddGroupMembers

func (h *APIHandler) AddGroupMembers(c *gin.Context)

AddGroupMembers POST /api/v1/groups/:id/members {workflow_ids[]}

func (*APIHandler) AddPageDiagReport added in v2.2.0

func (h *APIHandler) AddPageDiagReport(c *gin.Context)

AddPageDiagReport POST /api/v1/diag/page-reports {"kind","flags","payload"}

func (*APIHandler) AddProjectDir

func (h *APIHandler) AddProjectDir(c *gin.Context)

AddProjectDir POST /api/v1/projects/:id/dirs

func (*APIHandler) AnswerConfirm

func (h *APIHandler) AnswerConfirm(c *gin.Context)

AnswerConfirm POST /api/v1/workflows/:workflow_id/confirms/:ref/answer {options:[...], note?, custom?}

func (*APIHandler) AnswerConfirmBatch

func (h *APIHandler) AnswerConfirmBatch(c *gin.Context)

AnswerConfirmBatch POST /api/v1/workflows/:workflow_id/confirms/answer-batch {items:[{ref, options?, note?}], adopt_recommended?}:整批原子,任何一项不合格都不保存;L2 项不接受批量。

func (*APIHandler) AppendWorkflowFeedback

func (h *APIHandler) AppendWorkflowFeedback(c *gin.Context)

func (*APIHandler) ApplyProjectMigration

func (h *APIHandler) ApplyProjectMigration(c *gin.Context)

ApplyProjectMigration POST /api/v1/projects/:id/migration {hash} —— 确认迁移:带上 dry-run 的哈希。

func (*APIHandler) ArchiveProject

func (h *APIHandler) ArchiveProject(c *gin.Context)

ArchiveProject DELETE /api/v1/projects/:id

func (*APIHandler) ArchiveProjectDoc

func (h *APIHandler) ArchiveProjectDoc(c *gin.Context)

ArchiveProjectDoc POST /api/v1/workflows/:workflow_id/docs/:doc/archive

func (*APIHandler) ArchiveSession

func (h *APIHandler) ArchiveSession(c *gin.Context)

func (*APIHandler) CancelSession

func (h *APIHandler) CancelSession(c *gin.Context)

func (*APIHandler) ClearSemanticKey added in v2.2.0

func (h *APIHandler) ClearSemanticKey(c *gin.Context)

ClearSemanticKey DELETE /api/v1/search/semantic/key

func (*APIHandler) ClearSemanticVectors added in v2.2.0

func (h *APIHandler) ClearSemanticVectors(c *gin.Context)

ClearSemanticVectors DELETE /api/v1/search/semantic/vectors?confirm=1 删除全部向量并暂停(否则后台会立刻把它们嵌回来);勾选与设置保留。只撤某个项目的同意,取消勾选那个项目即可。

func (*APIHandler) CloseBranch added in v2.1.0

func (h *APIHandler) CloseBranch(c *gin.Context)

CloseBranch POST /api/v1/workflows/:workflow_id/branch/close (workflow_id 是分支自己的编号) 幂等:已经结束时返回 changed:false。

func (*APIHandler) ConversationSummaries

func (h *APIHandler) ConversationSummaries(c *gin.Context)

ConversationSummaries GET /api/v1/conversation-summaries?ids=wf:a,wf:b(或 workflow_ids=a,b)

func (*APIHandler) CreateAuthProfile

func (h *APIHandler) CreateAuthProfile(c *gin.Context)

CreateAuthProfile POST /api/v1/auth-profiles

func (*APIHandler) CreateCredential

func (h *APIHandler) CreateCredential(c *gin.Context)

func (*APIHandler) CreateGroup

func (h *APIHandler) CreateGroup(c *gin.Context)

CreateGroup POST /api/v1/groups {title, project_id?, workflow_ids[]}

func (*APIHandler) CreateNorm

func (h *APIHandler) CreateNorm(c *gin.Context)

func (*APIHandler) CreateProject

func (h *APIHandler) CreateProject(c *gin.Context)

CreateProject POST /api/v1/projects

func (*APIHandler) CreateProjectDoc

func (h *APIHandler) CreateProjectDoc(c *gin.Context)

CreateProjectDoc POST /api/v1/workflows/:workflow_id/docs

func (*APIHandler) CreateProjectGrant

func (h *APIHandler) CreateProjectGrant(c *gin.Context)

CreateProjectGrant POST /api/v1/projects/:id/grants —— 用户对任意范围授权(read / comment / edit)。

func (*APIHandler) CreateTask

func (h *APIHandler) CreateTask(c *gin.Context)

func (*APIHandler) CreateWorkItem

func (h *APIHandler) CreateWorkItem(c *gin.Context)

CreateWorkItem 新建任务(以「人」的身份)。

func (*APIHandler) CreateWorkModule

func (h *APIHandler) CreateWorkModule(c *gin.Context)

CreateWorkModule 新建模块或功能,排在同级最后。

func (*APIHandler) CreateWorkflow

func (h *APIHandler) CreateWorkflow(c *gin.Context)

CreateWorkflow 网页手动新建会话(#174 第一期):落一行占位会话,把「启动提示词」交给用户去发给智能体。 形态与取舍见 store/web_workflow.go。

POST /api/v1/workflows  {"title": "...", "workflow_id": "(可选)",
                         "first_message": "(可选)", "phase": "(可选)discuss|plan|dev",
                         "project_directory": "(可选)绝对路径", "host_name": "(可选)",
                         "resident": "(可选)常驻规则,≤1200 字,建好就是这个会话的常驻提示词 rev 1"}
201 {"status":"ok","workflow_id":"...","session":{占位会话},"start_prompt":"...",
     "applied":{…实际生效的高级选项,没填就没有这个字段…},"warnings":[…落库之后没做成的事,没有就没有这个字段…]}
400 名字 / 编号 / 阶段 / 首条指令 / 目录 / 主机不合规(都发生在落库之前,不会留下半个会话)   409 给定的编号已存在

高级选项(#184)全部可选,都不填时与改动前的请求 / 响应逐字节相同:

  • project_directory:占位会话(以及这个工作流)绑定到这个目录,D-161 从此要求智能体第一次汇报带同一个目录;
  • host_name:占位会话的归属主机标签(智能体接入后,凭据绑定的主机仍以凭据为准);
  • phase:起始阶段,按「人点的阶段」写入(同时是人工偏好阶段),广播 phase_changed;
  • first_message:首条指令,经现有的投递规则一律排进收件箱(占位会话已完成且已被消费),智能体接入后读到。
  • resident:常驻规则(#232),建好就是这个会话的常驻提示词(版本 1),与会话页「常驻」弹窗保存走同一条路径。
  • parent_workflow_id(#236,建分支):把新会话建成这个工作流的分支;关系与占位会话同事务落库,校验不过(主会话不存在 404、 已是别人的分支 / 数量上限 / 每小时限额 400 或 409)整个创建回滚。可带 expose_preset(visible | collab | managed,缺省 collab) 与 copy_user_notes(缺省 true);成功时响应多一个 branch 字段(关系与概况)。不带这三个字段时请求与响应与以前逐字节相同。 协作 / 托管预设含「改参数」与「启动」,相对「什么都没开放」是放宽,要终端解锁(#236 P3);终端不可用时这两项压回关闭、 其余照预设,响应多一个 clamped 字段列出被压回的项。

校验类错误一律发生在落库之前;会话建好之后,阶段 / 首条指令这两步若失败,会话仍然保留,原因写进 warnings (用户可以在会话页里再设一次阶段、再写一遍指令),不把整个请求判成失败。

func (*APIHandler) DeleteArtifactData

func (h *APIHandler) DeleteArtifactData(c *gin.Context)

DeleteArtifactData DELETE /api/v1/artifacts/:id/data/:key

func (*APIHandler) DeleteAuthProfile

func (h *APIHandler) DeleteAuthProfile(c *gin.Context)

DeleteAuthProfile DELETE /api/v1/auth-profiles/:id 默认档位不能删;选用了被删档位的工作流自动回落到默认档位(见 ResolveAuthProfile)。

func (*APIHandler) DeleteCredential

func (h *APIHandler) DeleteCredential(c *gin.Context)

func (*APIHandler) DeleteDraftImage

func (h *APIHandler) DeleteDraftImage(c *gin.Context)

DeleteDraftImage 删除一张草稿图片(从草稿里移除图片、草稿被销毁时由前端调用)。图片不存在也算成功。

func (*APIHandler) DeleteNorm

func (h *APIHandler) DeleteNorm(c *gin.Context)

func (*APIHandler) DeleteProjectDoc

func (h *APIHandler) DeleteProjectDoc(c *gin.Context)

DeleteProjectDoc DELETE /api/v1/workflows/:workflow_id/docs/:doc

func (*APIHandler) DeleteProjectModule

func (h *APIHandler) DeleteProjectModule(c *gin.Context)

DeleteProjectModule DELETE /api/v1/projects/:id/modules?path=

func (*APIHandler) DeleteSession

func (h *APIHandler) DeleteSession(c *gin.Context)

func (*APIHandler) DeleteWorkItem

func (h *APIHandler) DeleteWorkItem(c *gin.Context)

DeleteWorkItem 删除任务;子任务变成顶层任务,关联的会话不受影响。

func (*APIHandler) DeleteWorkModule

func (h *APIHandler) DeleteWorkModule(c *gin.Context)

DeleteWorkModule 删除模块(顶层模块连同它的功能)。任务不会被删:回到上一级,顶层模块被删时变成未归类。

func (*APIHandler) DeleteWorkflowDraft

func (h *APIHandler) DeleteWorkflowDraft(c *gin.Context)

func (*APIHandler) DismissConfirm

func (h *APIHandler) DismissConfirm(c *gin.Context)

DismissConfirm POST /api/v1/workflows/:workflow_id/confirms/:ref/dismiss {reason?}

func (*APIHandler) DownloadProjectArchive added in v2.2.0

func (h *APIHandler) DownloadProjectArchive(c *gin.Context)

DownloadProjectArchive GET /api/v1/archive/download?ticket=<票据>

MCP 令牌凭 export 返回的一次性票据取包。不走登录(它的调用方是脚本):自己做完整的鉴权—— Authorization: Bearer <令牌>(只认请求头)、令牌有归档位且项目在它的名单里、票据存在并且绑定的就是这把令牌、 没过期没用过——然后与登录的 REST 导出共用同一份流式打包代码与同一把「同一时刻只导一份」的闸。

func (*APIHandler) ExportAuditCSV

func (h *APIHandler) ExportAuditCSV(c *gin.Context)

ExportAuditCSV GET /api/v1/audit/export.csv(同样的筛选条件,最多 500 条一页,用 before 翻页)。

func (*APIHandler) ExportProjectArchive added in v2.2.0

func (h *APIHandler) ExportProjectArchive(c *gin.Context)

ExportProjectArchive GET /api/v1/projects/:id/archive?after_seq=N&group=<群编号>&group=…

把项目的过程信息(工作流、群聊、任务、确认项、用户追加、会话轮次、文档)打成一个 zip 流式返回。

  • after_seq:只导 seq 大于它的群消息(续导);其它类型每次导出整份。seq 是每个群各自的序号, 所以必须同时用 group 指明是哪个群,否则 400(同一个数字套在所有群上会悄悄漏掉序号较小的群的消息);
  • group:只导这些群(可重复);不给就是项目范围内的全部群(只能从头导);
  • 同一时刻 Hub 只允许一个导出在读库,其余请求得到 429(库只有一个连接,两个大导出会互相拖慢全站);
  • 审计只记范围与数量,不含正文;导出中途失败会中止连接(让浏览器看到下载失败,而不是一个「完整」的坏包)。

func (*APIHandler) ExportProjectDocsZip

func (h *APIHandler) ExportProjectDocsZip(c *gin.Context)

ExportProjectDocsZip GET /api/v1/workflows/:workflow_id/docs/export.zip

func (*APIHandler) ExportProjectKnowledgeZip

func (h *APIHandler) ExportProjectKnowledgeZip(c *gin.Context)

ListProjectKnowledge GET /api/v1/projects/:id/docs —— 项目里的全部文档(不含正文),给知识库的目录树用。 ExportProjectKnowledgeZip GET /api/v1/projects/:id/docs/export.zip 整个项目的文档(含已归档)打成一个压缩包;项目内路径唯一,所以不会重名。

func (*APIHandler) GetAgentSearchAccess added in v2.2.0

func (h *APIHandler) GetAgentSearchAccess(c *gin.Context)

GetAgentSearchAccess GET /api/v1/search/agent-access → {"keyword": true, "semantic": false} 全文默认开(只读本机索引、没有外发);语义默认关(每次查询都会把查询词外发给嵌入服务)。

func (*APIHandler) GetAgentSearchQuota added in v2.2.0

func (h *APIHandler) GetAgentSearchQuota(c *gin.Context)

GetAgentSearchQuota GET /api/v1/search/agent-quota → {"keyword_per_minute": 60, "semantic_per_minute": 6, "semantic_global_per_minute": 30, "defaults": {...}, "limits": {...}, "is_default": true}

func (*APIHandler) GetArtifact

func (h *APIHandler) GetArtifact(c *gin.Context)

GetArtifact GET /api/v1/artifacts/:id:聊天里的引用卡片和右侧预览用的摘要。HTML 的正文不在这里返回(走沙箱渲染页)。

func (*APIHandler) GetArtifactData

func (h *APIHandler) GetArtifactData(c *gin.Context)

GetArtifactData GET /api/v1/artifacts/:id/data/:key

func (*APIHandler) GetAsyncMode

func (h *APIHandler) GetAsyncMode(c *gin.Context)

GetAsyncMode GET /api/v1/workflows/:workflow_id/async-mode

func (*APIHandler) GetBranchFeed added in v2.1.0

func (h *APIHandler) GetBranchFeed(c *gin.Context)

GetBranchFeed GET /api/v1/workflows/:workflow_id/branch-feed?limit=

func (*APIHandler) GetBranchPrefs added in v2.1.0

func (h *APIHandler) GetBranchPrefs(c *gin.Context)

GetBranchPrefs GET /api/v1/branch/prefs

func (*APIHandler) GetConfirm

func (h *APIHandler) GetConfirm(c *gin.Context)

GetConfirm GET /api/v1/workflows/:workflow_id/confirms/:ref

func (*APIHandler) GetConfirmsBoard

func (h *APIHandler) GetConfirmsBoard(c *gin.Context)

GetConfirmsBoard GET /api/v1/workflows/:workflow_id/confirms/board 交流页「待答复」区的一次性数据:待处理的确认项(旧的在前),外加计数。

任务不再需要人逐条确认(#110,状态绑定智能体的开发流程),所以这里不再带「待验收的任务」; 会话守护下线之后(#245)也不再带「守护告警」; review_tasks / guard_alerts 与 counts 里对应的两个计数保留为恒空([] / 0),只为兼容还没刷新的旧页面,新页面不读。

func (*APIHandler) GetCredential

func (h *APIHandler) GetCredential(c *gin.Context)

func (*APIHandler) GetCurrentSession

func (h *APIHandler) GetCurrentSession(c *gin.Context)

func (*APIHandler) GetDiagConfig added in v2.2.0

func (h *APIHandler) GetDiagConfig(c *gin.Context)

GetDiagConfig GET /api/v1/diag/config —— 诊断面板的服务端状态(登录的人才能读)。

func (*APIHandler) GetDraftImage

func (h *APIHandler) GetDraftImage(c *gin.Context)

GetDraftImage 取回一张草稿图片(含正文),用于另一台设备 / 本机缓存被清理之后恢复草稿里的图片。

func (*APIHandler) GetGroup

func (h *APIHandler) GetGroup(c *gin.Context)

GetGroup GET /api/v1/groups/:id

func (*APIHandler) GetInboxConfig

func (h *APIHandler) GetInboxConfig(c *gin.Context)

GetInboxConfig 返回收件箱的手动开关。

func (*APIHandler) GetNorm

func (h *APIHandler) GetNorm(c *gin.Context)

func (*APIHandler) GetNotifyPrefs

func (h *APIHandler) GetNotifyPrefs(c *gin.Context)

GetNotifyPrefs 返回当前通知偏好。

func (*APIHandler) GetNtfy

func (h *APIHandler) GetNtfy(c *gin.Context)

GetNtfy 返回当前配置(不含凭据)与最近的推送情况。

func (*APIHandler) GetProject

func (h *APIHandler) GetProject(c *gin.Context)

GetProject GET /api/v1/projects/:id

func (*APIHandler) GetProjectDoc

func (h *APIHandler) GetProjectDoc(c *gin.Context)

GetProjectDoc GET /api/v1/workflows/:workflow_id/docs/:doc

func (h *APIHandler) GetProjectDocLinks(c *gin.Context)

GetProjectDocLinks GET /api/v1/workflows/:workflow_id/docs/content/links?path= 一篇文档的出链(含目标是否存在)与反链。

func (*APIHandler) GetProjectDocsBlueprint

func (h *APIHandler) GetProjectDocsBlueprint(c *gin.Context)

GetProjectDocsBlueprint GET /api/v1/workflows/:workflow_id/docs/blueprint

func (*APIHandler) GetSearchHints added in v2.2.0

func (h *APIHandler) GetSearchHints(c *gin.Context)

GetSearchHints GET /api/v1/search/hints → {"enabled": true, "max": 3, "threshold": 0.6, "session_threshold": 0.7, "per_hour": 30, "defaults": {...}, "limits": {...}, "is_default": true, "agent_semantic": true, "stats": {...}}

func (*APIHandler) GetSemantic added in v2.2.0

func (h *APIHandler) GetSemantic(c *gin.Context)

GetSemantic GET /api/v1/search/semantic 返回配置、密钥状态(不含明文)、今日与累计用量、默认值与取值范围、出站防护模式。

func (*APIHandler) GetSession

func (h *APIHandler) GetSession(c *gin.Context)

func (*APIHandler) GetSessionImage

func (h *APIHandler) GetSessionImage(c *gin.Context)

func (*APIHandler) GetSettings

func (h *APIHandler) GetSettings(c *gin.Context)

Settings APIs

func (*APIHandler) GetSidebarOrder added in v2.2.0

func (h *APIHandler) GetSidebarOrder(c *gin.Context)

GetSidebarOrder 返回侧栏当前的手动顺序。

func (*APIHandler) GetTask

func (h *APIHandler) GetTask(c *gin.Context)

func (*APIHandler) GetWakePromptDefaults added in v2.1.0

func (h *APIHandler) GetWakePromptDefaults(c *gin.Context)

GetWakePromptDefaults GET /api/v1/wake-prompts/defaults 各类唤醒词的内置默认、变量表与字数上限:设置页「查看默认 / 以默认为底稿」与变量参考用。

func (*APIHandler) GetWorkItem

func (h *APIHandler) GetWorkItem(c *gin.Context)

GetWorkItem 返回任务详情(含最近的时间线与关联会话)。

func (*APIHandler) GetWorkItemBySeq added in v2.1.0

func (h *APIHandler) GetWorkItemBySeq(c *gin.Context)

GetWorkItemBySeq 按「工作流 + 板内序号 #N」返回任务详情(响应形态与 GetWorkItem 相同)。

GET /api/v1/work-items/by-seq?workflow_id=&seq=

正文、汇报与链接里写的 #N 是板内序号:它在工作流所在的任务板内唯一(同一个项目的工作流共用一套 #N),和 /work-items/:id 用的 数据库编号是两回事——把 #N 当数据库编号用,打开的就是别的任务(#242)。任务页的 ?seq= 深链靠这个接口把序号解析成任务, 解析与智能体按 #N 取任务走同一条路(含合并任务板时改过号的旧序号),不依赖页面已加载的清单(已结束 / 已暂缓 / 很早以前的任务一样能开)。 这个板上没有这个序号 = 404。

func (*APIHandler) GetWorkflowDraft

func (h *APIHandler) GetWorkflowDraft(c *gin.Context)

Workflow Drafts Handlers

func (*APIHandler) GetWorkflowHost added in v2.2.0

func (h *APIHandler) GetWorkflowHost(c *gin.Context)

GetWorkflowHost GET /api/v1/workflows/:workflow_id/host 只读:这个会话当前的主机、用户固定的覆盖,以及清除覆盖之后会重新参与计算的来源(凭据绑定的主机、全局主机名)与所属项目。

func (*APIHandler) GetWorkflowInbox

func (h *APIHandler) GetWorkflowInbox(c *gin.Context)

GetWorkflowInbox 返回一个工作流收件箱的现状。

func (*APIHandler) GetWorkflowPhase

func (h *APIHandler) GetWorkflowPhase(c *gin.Context)

func (*APIHandler) GetWorkflowPrompts added in v2.1.0

func (h *APIHandler) GetWorkflowPrompts(c *gin.Context)

GetWorkflowPrompts GET /api/v1/workflows/:workflow_id/prompts

func (*APIHandler) GetWorkflowSessionBodies

func (h *APIHandler) GetWorkflowSessionBodies(c *gin.Context)

GetWorkflowSessionBodies 按 id 取一批会话的完整正文(轻量表里 body_omitted 的行用它补齐)。 范围限定在这个工作流里;不存在或不属于这个工作流的 id 直接略过;一次最多 sessionBodiesMaxIDs 个。 响应带弱 ETag:同一批 id 的内容没变时回 304(刷新页面再往上翻到同一批时省掉重传)。

func (*APIHandler) GetWorkflowSessions

func (h *APIHandler) GetWorkflowSessions(c *gin.Context)

func (*APIHandler) GetWorkflowSheet

func (h *APIHandler) GetWorkflowSheet(c *gin.Context)

func (*APIHandler) GetWorkflowUpdates

func (h *APIHandler) GetWorkflowUpdates(c *gin.Context)

GetWorkflowUpdates 返回一个工作流里智能体写下的任务进展(会话页的进展卡:每次更新一张,按提交时间升序)。 人在网页上的操作不在其中;since 是 RFC3339 时间,只要它之后的;limit 缺省取最新 60 条。

GET /api/v1/workflows/:workflow_id/work-updates?since=&limit=

func (*APIHandler) GroupCandidates

func (h *APIHandler) GroupCandidates(c *gin.Context)

GroupCandidates GET /api/v1/groups/candidates:列出可以拉进群的工作流(最近有动静的在前)。

func (*APIHandler) ImproveWorkItem

func (h *APIHandler) ImproveWorkItem(c *gin.Context)

ImproveWorkItem 在一个任务上发起改进需求(人的操作):验收后发现问题、想改成别的样子时,不用另起一个任务, 直接在原任务上说清楚——任务回到「进行中」并标为「改进」阶段,需求记在它的时间线上,同时把这段话交给工作流里的智能体 (与「追加指令」同一套投递:它正在等回复就是这一轮的回复,否则进收件箱排队)。

POST /api/v1/work-items/:id/improve   {"text": "导出的 CSV 在 Excel 里中文乱码"}

func (*APIHandler) KeepaliveSession

func (h *APIHandler) KeepaliveSession(c *gin.Context)

func (*APIHandler) LinkWorkItemSession

func (h *APIHandler) LinkWorkItemSession(c *gin.Context)

LinkWorkItemSession 把一个会话关联到任务。

func (*APIHandler) ListAgentIdentities

func (h *APIHandler) ListAgentIdentities(c *gin.Context)

ListAgentIdentities 返回全部 Agent 身份。

GET /api/v1/identities

func (*APIHandler) ListAgentSessions

func (h *APIHandler) ListAgentSessions(c *gin.Context)

ListAgentSessions 返回 Agent 会话与当前状态,最近有动静的在前。

GET /api/v1/agent-sessions?workflow_id=&identity_id=&limit=

func (*APIHandler) ListArtifactComments

func (h *APIHandler) ListArtifactComments(c *gin.Context)

ListArtifactComments GET /api/v1/artifacts/:id/comments?resolved=1

func (*APIHandler) ListArtifactData

func (h *APIHandler) ListArtifactData(c *gin.Context)

ListArtifactData GET /api/v1/artifacts/:id/data

func (*APIHandler) ListAudit

func (h *APIHandler) ListAudit(c *gin.Context)

ListAudit GET /api/v1/audit

func (*APIHandler) ListAuthProfiles

func (h *APIHandler) ListAuthProfiles(c *gin.Context)

ListAuthProfiles GET /api/v1/auth-profiles

func (*APIHandler) ListBranchParamEvents added in v2.1.0

func (h *APIHandler) ListBranchParamEvents(c *gin.Context)

ListBranchParamEvents GET /api/v1/workflows/:workflow_id/branch/params-events?limit= 默认 50 条、最多 200 条(库里每个分支本来就只留最近 200 条)。这个工作流不是任何会话的分支返回 404。

func (*APIHandler) ListBranches added in v2.1.0

func (h *APIHandler) ListBranches(c *gin.Context)

ListBranches GET /api/v1/branches

func (*APIHandler) ListConfirms

func (h *APIHandler) ListConfirms(c *gin.Context)

ListConfirms GET /api/v1/workflows/:workflow_id/confirms?status=&kind=&task_seq=&doc_id=&limit=&offset=

func (*APIHandler) ListConversationMessages

func (h *APIHandler) ListConversationMessages(c *gin.Context)

ListConversationMessages GET /api/v1/conversations/:id/messages?limit=&before=&after=&around=&q=&kinds=a,b

func (*APIHandler) ListCredentials

func (h *APIHandler) ListCredentials(c *gin.Context)

func (*APIHandler) ListDraftImages

func (h *APIHandler) ListDraftImages(c *gin.Context)

ListDraftImages 列出一个工作流的草稿图片(只有元数据):页面载入时一次请求就能知道哪些图片已经在服务器上。

func (*APIHandler) ListGroupTrash added in v2.2.0

func (h *APIHandler) ListGroupTrash(c *gin.Context)

ListGroupTrash GET /api/v1/trash/groups —— 群聊的「最近删除」:按删除时间倒序,不含快照正文。

func (*APIHandler) ListGroups

func (h *APIHandler) ListGroups(c *gin.Context)

ListGroups GET /api/v1/groups?archived=1[&project_id=<项目编号>]

project_id(#291,项目页的「群聊」页签):只要「有成员属于这个项目」的群,每个群多带 project_members; 项目不存在返回 404,编号不合法返回 400。不带时与以前一字不差。

func (*APIHandler) ListNorms

func (h *APIHandler) ListNorms(c *gin.Context)

func (*APIHandler) ListPageDiagReports added in v2.2.0

func (h *APIHandler) ListPageDiagReports(c *gin.Context)

ListPageDiagReports GET /api/v1/diag/page-reports?limit=20&kind=browser-crash —— 最新在前。 kind 不写 = 两类混在一起按时间排(页面自己交来的 + 浏览器自报的崩溃);写了就只列这一种(crash-suspect / manual / record / browser-crash)。 keep 是页面自己交来的那一类的保留条数(旧字段,保持不变),浏览器自报崩溃的保留条数在 browser_keep。

func (*APIHandler) ListProjectDocRevisions

func (h *APIHandler) ListProjectDocRevisions(c *gin.Context)

ListProjectDocRevisions GET /api/v1/workflows/:workflow_id/docs/:doc/revisions

func (*APIHandler) ListProjectDocs

func (h *APIHandler) ListProjectDocs(c *gin.Context)

ListProjectDocs GET /api/v1/workflows/:workflow_id/docs

默认只返回文档元数据,不带正文(items[].body 为空串,响应里 body_omitted=true):列表的使用方(目录树、链接索引、选择器) 从来不读正文,而正文是这张表最重的一列,每次开页面都带着全文太浪费(#177)。要正文请加 ?with_body=1, 或按路径取单篇(GET .../docs/content?path=…,那里一直带正文)。

func (*APIHandler) ListProjectGrants

func (h *APIHandler) ListProjectGrants(c *gin.Context)

ListProjectGrants GET /api/v1/projects/:id/grants?all=1 —— 默认只给有效的授权。

func (*APIHandler) ListProjectKnowledge

func (h *APIHandler) ListProjectKnowledge(c *gin.Context)

func (*APIHandler) ListProjects

func (h *APIHandler) ListProjects(c *gin.Context)

ListProjects GET /api/v1/projects?archived=1

func (*APIHandler) ListQueuedFeedbacks

func (h *APIHandler) ListQueuedFeedbacks(c *gin.Context)

func (*APIHandler) ListSessions

func (h *APIHandler) ListSessions(c *gin.Context)

func (*APIHandler) ListTasks

func (h *APIHandler) ListTasks(c *gin.Context)

Task APIs

func (*APIHandler) ListWorkItemAssignees

func (h *APIHandler) ListWorkItemAssignees(c *gin.Context)

ListWorkItemAssignees 返回一张任务板上能被指派的工作流(共享任务板,#175 B2b):详情里「指派」下拉按需取,不放进清单响应。 独立板(工作流不属于任何项目)没有可指派的对象,members 为空。

GET /api/v1/work-items/assignees?workflow_id=

func (*APIHandler) ListWorkItems

func (h *APIHandler) ListWorkItems(c *gin.Context)

ListWorkItems 返回任务列表,附各状态计数与「有任务的工作流」概况(任务页顶部的工作流切换用)。 指定了 workflow_id 时还附带这个工作流的规划树(modules)与未归类任务的汇总(unassigned)。

GET /api/v1/work-items?workflow_id=&state=todo,doing&kind=bug&stage=dev,none&session_id=&q=&parent_id=&module_id=&unassigned=1&top_level=1&closed_days=30&assignee=&limit=

assignee(共享任务板,#175 B2):只要指派给这个工作流的任务;none = 还没有指派的。注意它和 unassigned(没有归入模块)是两回事。

stage 可写多个(逗号分隔),none 表示「未标注」;带 session_id 时只返回与该会话关联的任务,并给每条任务附上 session_ctx(这个会话对它做了什么)。

func (*APIHandler) ListWorkModules

func (h *APIHandler) ListWorkModules(c *gin.Context)

ListWorkModules 返回工作流的规划树(按树的顺序拍平,含任务汇总)与未归类任务的汇总。

GET /api/v1/work-modules?workflow_id=

func (*APIHandler) ListWorkflowCheckpoints

func (h *APIHandler) ListWorkflowCheckpoints(c *gin.Context)

ListWorkflowCheckpoints 返回某工作流的恢复胶囊修订(只读,按修订号升序)。

func (*APIHandler) ListWorkflowTrash added in v2.2.0

func (h *APIHandler) ListWorkflowTrash(c *gin.Context)

ListWorkflowTrash GET /api/v1/trash/workflows —— 「最近删除」:按删除时间倒序,不含快照正文。

func (*APIHandler) MarkConversationRead

func (h *APIHandler) MarkConversationRead(c *gin.Context)

MarkConversationRead POST /api/v1/conversations/:id/read {cursor?}

func (*APIHandler) MoveWorkModule

func (h *APIHandler) MoveWorkModule(c *gin.Context)

MoveWorkModule 在同级里上移或下移一格,返回最新的规划树。

func (*APIHandler) PostArtifactComment

func (h *APIHandler) PostArtifactComment(c *gin.Context)

PostArtifactComment POST /api/v1/artifacts/:id/comments {anchor?, text} 评论存库(Agent 用 project_docs comments 读),同时给文档所属的工作流发一条追加消息,让负责的 Agent 在下次调用时收到。

func (*APIHandler) PostBrowserCrashReports added in v2.2.0

func (h *APIHandler) PostBrowserCrashReports(c *gin.Context)

PostBrowserCrashReports POST /api/v1/diag/browser-reports —— 浏览器的 Reporting API 把崩溃通知投到这里(匿名只写)。 能收下的、收不下被丢弃的、开关关着的,一律回 204:浏览器会为非 2xx 反复重试,没有必要让它重试,也不给探测的人任何反馈。 只有「请求体太大」(413)、「内容类型不对」(415)、「解析不了」(400)与「库写失败」(500)会如实回应。

func (*APIHandler) PostProjectDocComment

func (h *APIHandler) PostProjectDocComment(c *gin.Context)

PostProjectDocComment POST /api/v1/workflows/:workflow_id/docs/:doc/comments

func (*APIHandler) PreviewCredentialTools

func (h *APIHandler) PreviewCredentialTools(c *gin.Context)

PreviewCredentialTools 返回「具有给定权限的令牌将暴露哪些工具、收到哪一版指引」。 权限页在保存之前用它做预览:展示内容由服务端按真实逻辑算出,前端不重复实现一份。

func (*APIHandler) PreviewGroupTrash added in v2.2.0

func (h *APIHandler) PreviewGroupTrash(c *gin.Context)

PreviewGroupTrash GET /api/v1/groups/:id/trash-preview 只读:删除这个群的范围(消息、成员、体积)、将被撤销的群授权、未读 @ 提醒条数、确认框要求输入的名字,以及现在能不能删(blockers 非空 = 不能)。

func (*APIHandler) PreviewWakePrompt added in v2.1.0

func (h *APIHandler) PreviewWakePrompt(c *gin.Context)

PreviewWakePrompt POST /api/v1/wake-prompts/preview { "kind": "resume|new|web_start", "workflow_id"?: string, "template"?: string, "preset"?: bool } 不保存、不发送,只告诉用户「现在发出去会是什么样」:

  • 带 workflow_id:用这个会话此刻的真实现状渲染;不带:用示例值渲染(设置页里没有具体会话);
  • 带 template:渲染这份草稿(layer=draft);不带:渲染分层选出来的那一份(会话模板 > 全局覆盖 > 内置默认);
  • 带 template 且 preset=true:template 是启动器预设(或会话页运行配置)里自己写的正文,排在所有分层最前面(layer=preset)。 它按预设的规则校验(只有字数上限,不要求带 %workflow);正文为空时当作没写,渲染分层选出来的那一份。

模板草稿同样要过存库时的校验(字数上限、必须带 %workflow),不合规直接 400,免得用户预览通过、保存时才发现。

func (*APIHandler) PreviewWorkflowHost added in v2.2.0

func (h *APIHandler) PreviewWorkflowHost(c *gin.Context)

PreviewWorkflowHost POST /api/v1/workflows/:workflow_id/host/preview {"host_name": "…"} 只读预演:将改写多少行会话与排队中的追加、哪些轮仍在等回复,以及项目归属的前后对比(成员按「主机 + 目录」认,主机变了可能移出或加入项目)。

func (*APIHandler) PreviewWorkflowPrompts added in v2.1.0

func (h *APIHandler) PreviewWorkflowPrompts(c *gin.Context)

PreviewWorkflowPrompts POST /api/v1/workflows/:workflow_id/prompts/preview { "resident": string } 不保存,只返回「智能体在回执里实际看到的样子」(与回执头同一个格式化函数)、整理后的字数与会得到的版本号: 文字与已保存的一致就是当前版本,不一致就是保存后的下一个版本。

func (*APIHandler) PreviewWorkflowTrash added in v2.2.0

func (h *APIHandler) PreviewWorkflowTrash(c *gin.Context)

PreviewWorkflowTrash GET /api/v1/workflows/:workflow_id/trash-preview 只读:删除这条会话的范围(轮数、追加条数、截图张数、体积)、确认框要求输入的名字,以及现在能不能删(blockers 非空 = 不能)。

func (*APIHandler) ProjectBlueprint

func (h *APIHandler) ProjectBlueprint(c *gin.Context)

ProjectBlueprint GET /api/v1/projects/:id/blueprint?templates=1

func (*APIHandler) ProjectBoards added in v2.2.0

func (h *APIHandler) ProjectBoards(c *gin.Context)

ProjectBoards GET /api/v1/projects/:id/boards

项目页「任务」页签用(#291):项目自己的任务板,加上成员工作流名下任务所在的其它板;每张板给一个代表工作流, 任务清单的接口(/work-items?workflow_id=…)按它解析到板。只读,不合并板。

func (*APIHandler) ProjectMigration

func (h *APIHandler) ProjectMigration(c *gin.Context)

ProjectMigration GET /api/v1/projects/:id/migration —— dry-run,只读。

func (*APIHandler) ProjectModulePage

func (h *APIHandler) ProjectModulePage(c *gin.Context)

ProjectModulePage GET /api/v1/projects/:id/module-page?path=

func (*APIHandler) ProjectSuggestions

func (h *APIHandler) ProjectSuggestions(c *gin.Context)

ProjectSuggestions GET /api/v1/projects/suggestions

func (*APIHandler) PutArtifactData

func (h *APIHandler) PutArtifactData(c *gin.Context)

PutArtifactData PUT /api/v1/artifacts/:id/data/:key {value: <任意 JSON>, expected_version?: n}

func (*APIHandler) PutDiagConfig added in v2.2.0

func (h *APIHandler) PutDiagConfig(c *gin.Context)

PutDiagConfig PUT /api/v1/diag/config {"browser_reports_enabled": true|false} —— 开关浏览器自报崩溃。

func (*APIHandler) PutDraftImage

func (h *APIHandler) PutDraftImage(c *gin.Context)

PutDraftImage 上传(或重新确认)一张草稿图片。幂等:同一个内容键重复上传只刷新写入时间。

func (*APIHandler) PutSidebarOrder added in v2.2.0

func (h *APIHandler) PutSidebarOrder(c *gin.Context)

PutSidebarOrder 整表替换侧栏的手动顺序(乐观并发,见上)。

func (*APIHandler) ReadReports

func (h *APIHandler) ReadReports(c *gin.Context)

func (*APIHandler) ReadTaskFeedbacks

func (h *APIHandler) ReadTaskFeedbacks(c *gin.Context)

func (*APIHandler) RegenerateCredentialToken

func (h *APIHandler) RegenerateCredentialToken(c *gin.Context)

func (*APIHandler) ReleaseGate added in v2.1.0

func (h *APIHandler) ReleaseGate(c *gin.Context)

ReleaseGate POST /api/v1/workflows/:workflow_id/async-mode/release-gate 「本次放行」:这一轮回复窗口不再被未完成任务挡住、立刻恢复倒计时;任务一概不动,下次用户回复或窗口重新起算时自动复位。 没有窗口在等 / 门已关时返回 409 并说明原因。

func (*APIHandler) RemoveGroupMember

func (h *APIHandler) RemoveGroupMember(c *gin.Context)

RemoveGroupMember DELETE /api/v1/groups/:id/members/:ref

func (*APIHandler) RemoveProjectDir

func (h *APIHandler) RemoveProjectDir(c *gin.Context)

RemoveProjectDir DELETE /api/v1/projects/:id/dirs/:dir_id

func (*APIHandler) RenameSession

func (h *APIHandler) RenameSession(c *gin.Context)

func (*APIHandler) RenderArtifact

func (h *APIHandler) RenderArtifact(c *gin.Context)

RenderArtifact GET /api/v1/artifacts/:id/render?ticket=

func (*APIHandler) ReplyWindow

func (h *APIHandler) ReplyWindow(c *gin.Context)

ReplyWindow POST /api/v1/workflows/:workflow_id/reply-window { "kind": "plus" | "typing" } 用户在 Web 上告诉服务端「我还在」:plus 给回复窗口加 1 分钟(可连点),typing 是输入心跳(窗口等于暂停倒计时)。

func (*APIHandler) ResetNotifyConversation

func (h *APIHandler) ResetNotifyConversation(c *gin.Context)

ResetNotifyConversation 恢复一个会话的默认策略(没有设置过也算成功)。

func (*APIHandler) ResolveArtifactComment

func (h *APIHandler) ResolveArtifactComment(c *gin.Context)

ResolveArtifactComment POST /api/v1/artifacts/:id/comments/:cid/resolve {resolved: bool}

func (*APIHandler) RestoreGroupTrash added in v2.2.0

func (h *APIHandler) RestoreGroupTrash(c *gin.Context)

RestoreGroupTrash POST /api/v1/trash/groups/:id/restore —— 把一个群原样恢复(仍是已归档状态)。 群级授权不会被恢复:结果里的 revoked_grants 列出删除时被撤销的授权,由用户决定要不要重新授权。

func (*APIHandler) RestoreProjectDocRevision

func (h *APIHandler) RestoreProjectDocRevision(c *gin.Context)

RestoreProjectDocRevision POST /api/v1/workflows/:workflow_id/docs/:doc/revisions/:rev/restore 也走 …/docs/content/revisions/:rev/restore?path=(网页用这个):文档引用统一用 docPathParam 取(#214)。

func (*APIHandler) RestoreSession

func (h *APIHandler) RestoreSession(c *gin.Context)

func (*APIHandler) RestoreWorkflowPrompts added in v2.1.0

func (h *APIHandler) RestoreWorkflowPrompts(c *gin.Context)

RestoreWorkflowPrompts POST /api/v1/workflows/:workflow_id/prompts/restore { "revision_id": number } 把某个历史版本的文字存成新的当前版本(版本号继续往前走)。

func (*APIHandler) RestoreWorkflowTrash added in v2.2.0

func (h *APIHandler) RestoreWorkflowTrash(c *gin.Context)

RestoreWorkflowTrash POST /api/v1/trash/workflows/:id/restore —— 把一条原样恢复(仍是已归档状态,回到归档库)。

func (*APIHandler) RevertBranchParamEvent added in v2.1.0

func (h *APIHandler) RevertBranchParamEvent(c *gin.Context)

RevertBranchParamEvent POST /api/v1/workflows/:workflow_id/branch/params-events/:event_id/revert 只有人能撤销(登录令牌,actor 记登录者)。规则在 store:只能撤销主会话写入的、该字段最新一条未撤销的、当前值仍是它写入的值的修改, 否则 409 并写明原因;撤销与关系是否已结束无关。成功后广播 branch_changed(params_reverted) 与被改字段原有的刷新事件。

func (*APIHandler) RevokeProjectGrant

func (h *APIHandler) RevokeProjectGrant(c *gin.Context)

RevokeProjectGrant DELETE /api/v1/projects/:id/grants/:grant_id

func (*APIHandler) RevokeQueuedFeedback

func (h *APIHandler) RevokeQueuedFeedback(c *gin.Context)

func (*APIHandler) RevokeSession

func (h *APIHandler) RevokeSession(c *gin.Context)

func (*APIHandler) SaveWorkflowDraft

func (h *APIHandler) SaveWorkflowDraft(c *gin.Context)

func (*APIHandler) SaveWorkflowSheet

func (h *APIHandler) SaveWorkflowSheet(c *gin.Context)

func (*APIHandler) Search added in v2.2.0

func (h *APIHandler) Search(c *gin.Context)

Search GET /api/v1/search?q=&kinds=doc,task&project_id=&workflow_id=&include_archived=1&limit=&cursor=

全文检索(#266):文档、任务、确认项、会话轮次、群消息五类内容一起搜。这条路由在登录保护之下,调用者就是 Web 用户, 所以不带 project_id / workflow_id 就是全库。project_id 与 workflow_id 互斥。 不可走索引的查询(只剩单个汉字等)返回 200 与 too_short=true;索引关闭或不可用返回 503(reason 见响应)。

func (*APIHandler) SearchProjectDocs

func (h *APIHandler) SearchProjectDocs(c *gin.Context)

SearchProjectDocs GET /api/v1/workflows/:workflow_id/docs/search

func (*APIHandler) SearchProjectKnowledge

func (h *APIHandler) SearchProjectKnowledge(c *gin.Context)

SearchProjectKnowledge GET /api/v1/projects/:id/docs/search

func (*APIHandler) SearchStatus added in v2.2.0

func (h *APIHandler) SearchStatus(c *gin.Context)

SearchStatus GET /api/v1/search/status —— 全文索引的状态:开关、各类内容的回填进度、作废条目数。

func (*APIHandler) SearchWorkItems added in v2.2.0

func (h *APIHandler) SearchWorkItems(c *gin.Context)

SearchWorkItems 是任务页的服务端检索(#279):搜这张任务板的全部任务(不受任务清单「最近 500 条 / 已结束近 30 天」的限制), 按相关度排序(#编号精确命中 > 标题命中 > 其它栏命中,同档按最近更新),附命中片段与各状态的命中数量。

GET /api/v1/work-items/search?workflow_id=&q=&state=todo,doing&kind=bug&limit=50&offset=0

workflow_id 为空 = 全部任务板;q 必填;limit 缺省 50、最多 100。状态数量不受 state 筛选影响(与任务页的状态按钮同口径)。 它是管理接口,鉴权与 GET /work-items 相同(登录后的管理员);不改 GET /work-items 的 q,也不动 MCP 的任务列表。

func (*APIHandler) SemanticIncomplete added in v2.2.0

func (h *APIHandler) SemanticIncomplete(c *gin.Context)

SemanticIncomplete GET /api/v1/search/semantic/incomplete 没有被完整嵌入的条目明细(设置页「进度与存储」里的「查看明细」):每条给出类型、标题、所属项目与原因 (太长只嵌入了前面一部分 / 补后半部分时被服务拒绝 / 整条被服务拒绝 / 内容太短)。 只读、只给登录的人(V9:MCP 令牌进不来);最多列出前 200 条,总数与各原因的条数另给;不外发任何内容。

func (*APIHandler) SemanticQuery added in v2.2.0

func (h *APIHandler) SemanticQuery(c *gin.Context)

SemanticQuery GET /api/v1/search/semantic/query?q=&project_id=&workflow_id=&kinds=doc,task&limit=&min_score= 语义查询:与词法检索同形状的命中,外加 score;回执里的 state 不是 ok 时 hits 为空、reason 说明原因(调用方退回词法)。 只有范围本身不合法(项目不存在、project_id 与 workflow_id 同时给)或参数无效才返回 4xx。 min_score(-1~1)只覆盖这一次查询的相似度下限,给评测与阈值校准用(取 -1 就是不设下限);不给就用默认值,同意范围与回源核对都不受影响。

func (*APIHandler) SemanticRebuild added in v2.2.0

func (h *APIHandler) SemanticRebuild(c *gin.Context)

SemanticRebuild POST /api/v1/search/semantic/rebuild {"confirm": true} 嵌入模型或维度变了之后,旧向量已停用;确认后删掉它们并按新设置重新嵌入(会花 token——界面先回显预估再让人确认)。

func (*APIHandler) SemanticRun added in v2.2.0

func (h *APIHandler) SemanticRun(op string) gin.HandlerFunc

SemanticRun POST /api/v1/search/semantic/{pause|resume|rescan} 暂停(后台嵌入与语义查询都停,向量保留)、继续(同时清掉「自动暂停」的原因)、立即对账一次。

func (*APIHandler) SemanticStatus added in v2.2.0

func (h *APIHandler) SemanticStatus(c *gin.Context)

SemanticStatus GET /api/v1/search/semantic/status?detail=1 运行状态、块数与体积、最近错误;detail=1 时再给每个项目的范围、覆盖率与预计 token(设置页打开时才用,查询较重)。

func (*APIHandler) SemanticUsage added in v2.2.0

func (h *APIHandler) SemanticUsage(c *gin.Context)

SemanticUsage GET /api/v1/search/semantic/usage?days=14:最近 N 天(含今天)每天的用量,没有记录的日子不出现。

func (*APIHandler) SendConversationMessage

func (h *APIHandler) SendConversationMessage(c *gin.Context)

SendConversationMessage POST /api/v1/conversations/:id/messages 请求体:{text, images?, reply_to?, target?, draft_workflow_id?, host_name?, project_directory?}。 reply_to 形如 s:<session_id>:正文前加「【回复 <8 位哈希>】」;target 为 auto(默认,沿用投递规则)或 inbox(强制进收件箱)。

func (*APIHandler) SendTaskFeedback

func (h *APIHandler) SendTaskFeedback(c *gin.Context)

func (*APIHandler) ServeHookBinary

func (h *APIHandler) ServeHookBinary(c *gin.Context)

func (*APIHandler) ServeHookInstallPs1

func (h *APIHandler) ServeHookInstallPs1(c *gin.Context)

func (*APIHandler) ServeHookInstallSh

func (h *APIHandler) ServeHookInstallSh(c *gin.Context)

func (*APIHandler) SessionPresence

func (h *APIHandler) SessionPresence(c *gin.Context)

SessionPresence 是 Web 告诉服务端「用户还在」的入口(#121 收尾宽限): kind=plus 点「+1 分钟」;kind=typing 是输入时的心跳。只对正挂着的长轮询生效,没有就返回 active=false。

func (*APIHandler) SetAskNotifier added in v2.1.0

func (h *APIHandler) SetAskNotifier(n askNotifier)

SetAskNotifier 接入通知闸;NewServer 里接线。传 nil 表示不发通知(测试与精简装配)。

func (*APIHandler) SetDefaultAuthProfile

func (h *APIHandler) SetDefaultAuthProfile(c *gin.Context)

SetDefaultAuthProfile POST /api/v1/auth-profiles/:id/default

func (*APIHandler) SetGroupMemberPolicy

func (h *APIHandler) SetGroupMemberPolicy(c *gin.Context)

SetGroupMemberPolicy PUT /api/v1/groups/:id/members/:ref/policy {push_policy?, muted_until?, clear_mute?}

func (*APIHandler) SetNotifyConversation

func (h *APIHandler) SetNotifyConversation(c *gin.Context)

SetNotifyConversation 设置一个会话的通知策略。

func (*APIHandler) SetNtfy

func (h *APIHandler) SetNtfy(n *ntfy.Notifier)

SetNtfy 接入 ntfy 推送器;启动时调用一次。

func (*APIHandler) SetSemanticEnabled added in v2.2.0

func (h *APIHandler) SetSemanticEnabled(c *gin.Context)

SetSemanticEnabled PUT /api/v1/search/semantic/enabled {"enabled": true} 总开关。打开前要求 API Key 可用且维度已填(否则 409 + 原因);打开会清除暂停;关闭立即释放内存缓存,向量保留。

func (*APIHandler) SetSemanticKey added in v2.2.0

func (h *APIHandler) SetSemanticKey(c *gin.Context)

SetSemanticKey PUT /api/v1/search/semantic/key {"api_key": "..."} 校验、密封后存库(密钥绑定到当前配置的服务主机);替换已有的。响应不含明文。

func (*APIHandler) SetSemanticScope added in v2.2.0

func (h *APIHandler) SetSemanticScope(c *gin.Context)

SetSemanticScope PUT /api/v1/search/semantic/scope {"kinds": [...], "project_ids": [...]}(给哪个改哪个) 勾选哪些项目、允许哪些内容类型外发。范围缩小时,范围外的向量在响应返回之前就已删除(取消勾选 = 撤回同意)。

func (*APIHandler) SetTerminal

func (h *APIHandler) SetTerminal(hub *terminal.Hub)

SetTerminal 注入终端 Hub:令牌管理里涉及终端的操作需要它做二次解锁校验,令牌变更后也要通知它取消进行中的运行。

func (*APIHandler) SetWorkflowHost added in v2.2.0

func (h *APIHandler) SetWorkflowHost(c *gin.Context)

SetWorkflowHost PUT /api/v1/workflows/:workflow_id/host {"host_name": "…"} 固定(或用空串清除)这个会话的主机。固定时名下已有的会话与排队追加一并改成新主机;清除只是回到自动。幂等:重复提交同样的值是空操作(noop),不写审计、不广播。

func (*APIHandler) SetWorkflowPhase

func (h *APIHandler) SetWorkflowPhase(c *gin.Context)

func (*APIHandler) SubmitFeedback

func (h *APIHandler) SubmitFeedback(c *gin.Context)

func (*APIHandler) TestNtfy

func (h *APIHandler) TestNtfy(c *gin.Context)

TestNtfy 立刻发一条测试推送。请求体里的 draft(可选)是尚未保存的表单,叠加在已保存的配置上试发; 没有 draft 就用已保存的配置。kind(可选)是「各类消息的优先级」表里的类型:带上就按这一类此刻的优先级试发, 返回里的 priority 是实际用的级别;不带就是普通测试推送。不论推送成败,接口本身都返回 200,结果在 ok / error 里。

func (*APIHandler) TestSemantic added in v2.2.0

func (h *APIHandler) TestSemantic(c *gin.Context)

TestSemantic POST /api/v1/search/semantic/test {"draft": {...}}(请求体可省略) 用已保存的 API Key 与(草稿叠加后的)配置向服务发一句固定的英文,核对地址、鉴权、模型与维度。 draft 只含非机密字段,只对这一次测试有效,不保存;密钥只会发给它绑定的那台主机。 不论服务端成败,接口本身返回 200,结果在 result 里;草稿不合法 400,太频繁 429。

func (*APIHandler) TranscribeAudio

func (h *APIHandler) TranscribeAudio(c *gin.Context)

func (*APIHandler) TrashGroup added in v2.2.0

func (h *APIHandler) TrashGroup(c *gin.Context)

TrashGroup POST /api/v1/groups/:id/trash {"confirm_name": "…"} 把一个已归档的群整个移进回收站。confirm_name 必须与预览里给出的群名一致(服务端核对)。

func (*APIHandler) TrashWorkflow added in v2.2.0

func (h *APIHandler) TrashWorkflow(c *gin.Context)

TrashWorkflow POST /api/v1/workflows/:workflow_id/trash {"confirm_name": "…"} 把一条已归档的会话整个移进回收站。confirm_name 必须与预览里给出的名字一致(服务端核对)。

func (*APIHandler) UnarchiveSession

func (h *APIHandler) UnarchiveSession(c *gin.Context)

func (*APIHandler) UnlinkWorkItemSession

func (h *APIHandler) UnlinkWorkItemSession(c *gin.Context)

UnlinkWorkItemSession 解除任务与会话的关联。

func (*APIHandler) UpdateAgentIdentity

func (h *APIHandler) UpdateAgentIdentity(c *gin.Context)

UpdateAgentIdentity 给身份改名。

PUT /api/v1/identities/:id   {"name": "后端组"}

func (*APIHandler) UpdateAgentSearchAccess added in v2.2.0

func (h *APIHandler) UpdateAgentSearchAccess(c *gin.Context)

UpdateAgentSearchAccess PUT /api/v1/search/agent-access {"keyword": true|false, "semantic": true|false} 两项都可选、至少给一项;没给的一项不动。生效立即(下一次 search 调用就按新值判定),并记一条审计(search.agent_access)。

func (*APIHandler) UpdateAgentSearchQuota added in v2.2.0

func (h *APIHandler) UpdateAgentSearchQuota(c *gin.Context)

UpdateAgentSearchQuota PUT /api/v1/search/agent-quota

{"keyword_per_minute": n, "semantic_per_minute": n, "semantic_global_per_minute": n}   三项都可选、至少给一项,没给的不动
{"reset": true}                                                                       恢复默认(不能和具体数值一起给)

校验:每项在范围内,且语义合计不小于每个令牌的额度;不合法返回 400 与说明,库里不变。生效立即(下一次 search 调用就按新额度判定), 并记一条审计(search.agent_quota,只含被改项的新值或 reset: true)。

func (*APIHandler) UpdateAsyncMode

func (h *APIHandler) UpdateAsyncMode(c *gin.Context)

UpdateAsyncMode PUT /api/v1/workflows/:workflow_id/async-mode { "enabled"?: bool, "profile_id"?: number, "strict_wrapup"?: bool } 开启不要求先见过 hook(#271):没见过 hook 时开着只是「已开启、暂未生效」,hook 出现后自动生效;关闭永远允许。 strict_wrapup 开关「严格收尾门」(默认开;关掉后回复窗口回到老口径),见 asyncModeView 的说明。

func (*APIHandler) UpdateAuthProfile

func (h *APIHandler) UpdateAuthProfile(c *gin.Context)

UpdateAuthProfile PUT /api/v1/auth-profiles/:id

func (*APIHandler) UpdateBranch added in v2.1.0

func (h *APIHandler) UpdateBranch(c *gin.Context)

UpdateBranch PUT /api/v1/workflows/:workflow_id/branch { "expose_preset"?: "visible|collab|managed", "expose"?: {…}, "copy_user_notes"?: bool } workflow_id 是分支自己的工作流编号。预设与显式取值二选一;都不带也不带 copy_user_notes 视为空请求,返回 400。 放宽「改参数」档位或打开「启动」要终端解锁(终端不可用时压回当前取值,响应带 clamped);收紧与其它项只需登录。

func (*APIHandler) UpdateBranchPrefs added in v2.1.0

func (h *APIHandler) UpdateBranchPrefs(c *gin.Context)

UpdateBranchPrefs PUT /api/v1/branch/prefs { "l2_guard"?: bool, "escalate_minutes"?: int }

func (*APIHandler) UpdateCredential

func (h *APIHandler) UpdateCredential(c *gin.Context)

func (*APIHandler) UpdateGroup

func (h *APIHandler) UpdateGroup(c *gin.Context)

UpdateGroup PUT /api/v1/groups/:id {title?, project_id?, archived?}

func (*APIHandler) UpdateInboxConfig

func (h *APIHandler) UpdateInboxConfig(c *gin.Context)

UpdateInboxConfig 修改手动开关;只改请求里带了的字段。

func (*APIHandler) UpdateNorm

func (h *APIHandler) UpdateNorm(c *gin.Context)

func (*APIHandler) UpdateNotifyPrefs

func (h *APIHandler) UpdateNotifyPrefs(c *gin.Context)

UpdateNotifyPrefs 局部修改全局偏好:只改请求体里出现的字段。

func (*APIHandler) UpdateNtfy

func (h *APIHandler) UpdateNtfy(c *gin.Context)

UpdateNtfy 保存整张表单;凭据留空表示保持原值。

func (*APIHandler) UpdateProject

func (h *APIHandler) UpdateProject(c *gin.Context)

UpdateProject PUT /api/v1/projects/:id

func (*APIHandler) UpdateProjectDoc

func (h *APIHandler) UpdateProjectDoc(c *gin.Context)

UpdateProjectDoc PUT /api/v1/workflows/:workflow_id/docs/:doc

func (*APIHandler) UpdateSearchHints added in v2.2.0

func (h *APIHandler) UpdateSearchHints(c *gin.Context)

UpdateSearchHints PUT /api/v1/search/hints

{"enabled": bool, "max": n, "threshold": 0.6, "session_threshold": 0.7, "per_hour": n}   五项都可选、至少给一项,没给的不动
{"reset": true}                                                                          恢复默认(不能和具体数值一起给)

threshold 管文档 / 任务 / 确认项,session_threshold 只管会话汇报类线索(#304,各管各的)。 校验:每项在范围内(条数 1–5,两个相似度下限都是 0.30–0.95,每小时 1–600);不合法返回 400 与说明,库里不变。生效立即(下一条消息就按新设置算, 已经存下的线索在投递时也按新设置过滤开关与条数),并记一条审计(search.hints,只含被改项的新值或 reset: true)。

func (*APIHandler) UpdateSearchSettings added in v2.2.0

func (h *APIHandler) UpdateSearchSettings(c *gin.Context)

UpdateSearchSettings PUT /api/v1/search/settings {"index_enabled": true, "page_index_enabled": true} 两项都可选、至少给一项;没给的一项不动。

  • index_enabled:打开或关闭全文索引,立即生效并持久化。关闭只是停止维护与使用(旧的 LIKE 检索照常工作),索引数据保留,再打开时补齐。 环境变量 RELAYMESH_SEARCH_INDEX=off 强制关闭时,打开会被拒绝(409)。
  • page_index_enabled(#266 / 1c):页面里的搜索(任务页、文档、会话与群聊面板)是否先问全文索引;关掉立即回退原来的搜索。 它只管页面,不影响全局搜索,也不影响全文索引本身是否在维护。

func (*APIHandler) UpdateSemantic added in v2.2.0

func (h *APIHandler) UpdateSemantic(c *gin.Context)

UpdateSemantic PUT /api/v1/search/semantic 部分更新非机密配置:请求体里没给的字段保持原值。密钥不能走这里(会被明确拒绝),见 PUT .../key。

func (*APIHandler) UpdateSessionMaxChecks

func (h *APIHandler) UpdateSessionMaxChecks(c *gin.Context)

func (*APIHandler) UpdateSessionPromptWait

func (h *APIHandler) UpdateSessionPromptWait(c *gin.Context)

func (*APIHandler) UpdateSessionWaitCountdown

func (h *APIHandler) UpdateSessionWaitCountdown(c *gin.Context)

func (*APIHandler) UpdateSettings

func (h *APIHandler) UpdateSettings(c *gin.Context)

func (*APIHandler) UpdateTaskStages

func (h *APIHandler) UpdateTaskStages(c *gin.Context)

func (*APIHandler) UpdateWorkItem

func (h *APIHandler) UpdateWorkItem(c *gin.Context)

UpdateWorkItem 更新任务;缺省的字段保持不变。

func (*APIHandler) UpdateWorkModule

func (h *APIHandler) UpdateWorkModule(c *gin.Context)

UpdateWorkModule 修改模块的名称或说明;缺省的字段保持不变。

func (*APIHandler) UpdateWorkflowPrompts added in v2.1.0

func (h *APIHandler) UpdateWorkflowPrompts(c *gin.Context)

UpdateWorkflowPrompts PUT /api/v1/workflows/:workflow_id/prompts { "resident"?: string, "wake_resume"?: string, "wake_new"?: string } 保存常驻提示词与 / 或会话自己的唤醒词模板(至少带一项);内容没变不涨版本,空串表示清除,超过字数上限 400。 先全部校验再写:一项不合规,整个请求什么也不保存。

func (*APIHandler) UpsertProjectModule

func (h *APIHandler) UpsertProjectModule(c *gin.Context)

UpsertProjectModule PUT /api/v1/projects/:id/modules

func (*APIHandler) WorkflowProject

func (h *APIHandler) WorkflowProject(c *gin.Context)

WorkflowProject GET /api/v1/workflows/:workflow_id/project —— 这个工作流属于哪个项目(没有就是 null)。

type AckReportsRequest

type AckReportsRequest struct {
	ThroughSequence int64 `json:"through_sequence"`
}

type AuthHandler

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

func NewAuthHandler

func NewAuthHandler(cfg *config.Config, st *store.Store, limiter *RateLimiter) *AuthHandler

func (*AuthHandler) ArtifactRenderMiddleware

func (a *AuthHandler) ArtifactRenderMiddleware() gin.HandlerFunc

ArtifactRenderMiddleware 只认 ?ticket=(单次、绑定文档编号)。没开登录口令时放行。

func (*AuthHandler) ChangeCredentials

func (a *AuthHandler) ChangeCredentials(c *gin.Context)

ChangeCredentials 修改管理账号和密码(需提供旧密码进行鉴权验证)

func (*AuthHandler) ClearAllBlockedIPs

func (a *AuthHandler) ClearAllBlockedIPs(c *gin.Context)

func (*AuthHandler) EffectiveCredentials

func (a *AuthHandler) EffectiveCredentials(ctx context.Context) (username string, password string, err error)

EffectiveCredentials 是账号密码判定的唯一真源,每次调用都实时读取数据库,不做缓存。 返回的 error 表示数据库读取或解析失败:此时 username/password 仍是「环境变量兜底值」, 但调用方若据此做安全放行(如终端总闸)必须把 error 当作失败处理。

func (*AuthHandler) GetBlockedIPs

func (a *AuthHandler) GetBlockedIPs(c *gin.Context)

func (*AuthHandler) IsMCPToken

func (a *AuthHandler) IsMCPToken(tokenString string) bool

isMCPToken 判断字符串是否是某个 MCP 令牌(环境变量配置的,或凭据库里的,无论是否启用)。 它只用来给出明确的拒绝原因,绝不能据此放行:MCP 令牌代表「某个智能体」,而 REST / SSE 是给人类管理员的。 IsMCPToken 判断给定字符串是否是一把有效的 MCP 令牌(环境变量令牌或凭据库令牌),供终端 REST 的闸门使用。

func (*AuthHandler) IssueArtifactTicket

func (a *AuthHandler) IssueArtifactTicket(c *gin.Context)

IssueArtifactTicket POST /api/v1/artifacts/:id/ticket:签发渲染页的一次性票据(iframe 不能带请求头)。

func (*AuthHandler) IssueSSETicket

func (a *AuthHandler) IssueSSETicket(c *gin.Context)

IssueSSETicket 签发 SSE 一次性票据(POST /api/v1/auth/sse_ticket,需已登录)。 浏览器的 EventSource 无法自定义请求头,过去把 7 天有效的 JWT 直接拼进 URL,会进入反代访问日志; 现在改为 30 秒、单次有效的票据,泄漏后也无法再被利用。

func (*AuthHandler) Login

func (a *AuthHandler) Login(c *gin.Context)

func (*AuthHandler) Middleware

func (a *AuthHandler) Middleware() gin.HandlerFunc

Middleware 是业务接口的鉴权中间件:只接受 Authorization: Bearer 头。 URL 查询串里的 token 会被访问日志、反代日志、浏览器历史与 Referer 泄漏,因此不再用于普通接口; 需要在 URL 上携带凭据的长连接(SSE)请使用 StreamMiddleware。

func (*AuthHandler) ResetCredentials

func (a *AuthHandler) ResetCredentials(c *gin.Context)

ResetCredentials 重置账号密码回退至环境变量初始值

func (*AuthHandler) RevealCredentialToken

func (a *AuthHandler) RevealCredentialToken(c *gin.Context)

RevealCredentialToken 在再次验证 Web 登录密码后返回某个 MCP 令牌的完整明文 (POST /api/v1/credentials/:id/reveal,请求体 {"password": "..."})。

令牌明文存放在库里(MCP 客户端靠它直连),列表接口只给掩码;这里是唯一能「读出旧令牌」的入口,所以:

  • 只有人类登录态能到这里:路由挂在受 JWT 保护的组内,任何 MCP 令牌都会被中间件挡掉;
  • 登录 JWT 之外必须再提交一次 Web 密码,JWT 泄露了也读不出令牌;
  • 密码错误与登录共用同一份按 IP 的反爆破额度,达到上限即锁定;
  • 每次尝试(成功、失败、被锁)都写审计,只记谁、从哪、哪个令牌,绝不记令牌与密码;
  • 响应禁止缓存;密码错误用 403 而不是 401——401 会被前端当成「登录过期」而踢回登录页。

未设置 Web 密码(开放模式)时没有可验证的对象,直接放行:此时任何人本来就能重新生成令牌。

func (*AuthHandler) SetCredentialRevealHook

func (a *AuthHandler) SetCredentialRevealHook(fn func(actor, ip, result, detail string))

SetCredentialRevealHook 注册「查看令牌」的审计回调;必须在对外提供服务之前调用。 result 取 ok / fail / deny,含义与终端审计一致。

func (*AuthHandler) SetCredentialsChangedHook

func (a *AuthHandler) SetCredentialsChangedHook(fn func(subject, ip string))

SetCredentialsChangedHook 注册凭据变更回调;必须在对外提供服务之前调用。

func (*AuthHandler) SetLoginLockedHook added in v2.1.0

func (a *AuthHandler) SetLoginLockedHook(fn func())

SetLoginLockedHook 注册「登录失败过多、来源被锁定」的回调;必须在对外提供服务之前调用。

func (*AuthHandler) Status

func (a *AuthHandler) Status(c *gin.Context)

func (*AuthHandler) StreamMiddleware

func (a *AuthHandler) StreamMiddleware() gin.HandlerFunc

StreamMiddleware 用于 SSE 等浏览器原生 API 无法自定义请求头的流式端点,凭据来源依次为:

  1. Authorization: Bearer 头;
  2. ?ticket=:由 POST /api/v1/auth/sse_ticket 签发的一次性票据(30 秒、单次,泄漏进日志也无价值);
  3. ?token=:旧版前端与第三方脚本的兼容通道,仅在 RELAYMESH_ALLOW_QUERY_TOKEN 未关闭时接受。

func (*AuthHandler) UnblockIP

func (a *AuthHandler) UnblockIP(c *gin.Context)

func (*AuthHandler) VerifyHumanJWT

func (a *AuthHandler) VerifyHumanJWT(tokenString string) (subject string, ok bool)

VerifyHumanJWT 只认「Web 登录签发的管理员 JWT」:不接受 MCP 令牌、凭据库令牌或任何其他来源。 自 v1.7 起整个 REST / SSE 管理面都只认人类 JWT(见 authMiddleware),本函数保留给需要同时核对 role 与 sub 的终端端点。

func (*AuthHandler) VerifyJWTToken

func (a *AuthHandler) VerifyJWTToken(tokenString string) (*jwt.MapClaims, bool)

VerifyJWTToken 校验 JWT 并返回 claims

type BlockedIPInfo

type BlockedIPInfo struct {
	IP            string    `json:"ip"`
	FailedCount   int       `json:"failed_count"`
	LastFailedAt  time.Time `json:"last_failed_at"`
	LockedUntil   time.Time `json:"locked_until"`
	RemainingSecs int64     `json:"remaining_seconds"`
}

type ChangeCredentialsRequest

type ChangeCredentialsRequest struct {
	OldPassword string `json:"old_password"`
	NewUsername string `json:"new_username"`
	NewPassword string `json:"new_password"`
}

type CreateTaskRequest

type CreateTaskRequest struct {
	TaskID     string            `json:"task_id,omitempty"`
	Title      string            `json:"title,omitempty"`
	Mode       string            `json:"mode,omitempty"`
	Stages     model.TaskStages  `json:"stages,omitempty"`
	Segments   []model.Segment   `json:"segments,omitempty"`
	WaitPolicy *model.WaitPolicy `json:"wait_policy,omitempty"`
}

type GroupCandidate

type GroupCandidate struct {
	WorkflowID string `json:"workflow_id"`
	Name       string `json:"name"`
	ProjectDir string `json:"project_directory,omitempty"`
	HostName   string `json:"host_name,omitempty"`
	State      string `json:"state,omitempty"`
	// Eligible 表示它处于聊天模式(G-1);不满足时 Reason 说明为什么不能加入。
	Eligible bool   `json:"eligible"`
	Reason   string `json:"reason,omitempty"`
}

GroupCandidate 是建群时可以选的工作流。

type IPAttempt

type IPAttempt struct {
	FailedCount  int
	LastFailedAt time.Time
	LockedUntil  time.Time
}

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type RateLimitedWriter

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

RateLimitedWriter 实现带上下文感知与平滑分块输出的流式限速器,为核心 SSE 与 API 预留生存带宽

func NewRateLimitedWriter

func NewRateLimitedWriter(w io.Writer, ctx context.Context, limitKBps int) *RateLimitedWriter

func (*RateLimitedWriter) Write

func (rw *RateLimitedWriter) Write(p []byte) (int, error)

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter() *RateLimiter

func (*RateLimiter) CheckLocked

func (rl *RateLimiter) CheckLocked(ip string) (isLocked bool, remaining time.Duration)

CheckLocked 检查该 IP 是否处于封禁锁定期

func (*RateLimiter) ClearAll

func (rl *RateLimiter) ClearAll()

ClearAll 手动清空所有封禁记录

func (*RateLimiter) Close

func (rl *RateLimiter) Close()

func (*RateLimiter) GetBlockedIPs

func (rl *RateLimiter) GetBlockedIPs() []BlockedIPInfo

GetBlockedIPs 获取当前所有处于封禁状态的 IP 列表

func (*RateLimiter) RecordFailure

func (rl *RateLimiter) RecordFailure(ip string, maxAttempts int, lockoutDuration time.Duration) (isLocked bool, remaining time.Duration)

RecordFailure 记录一次登录失败,若达到阈值则自动封禁

func (*RateLimiter) RecordSuccess

func (rl *RateLimiter) RecordSuccess(ip string)

RecordSuccess 登录成功,清除该 IP 的所有失败记录

func (*RateLimiter) UnblockIP

func (rl *RateLimiter) UnblockIP(ip string)

UnblockIP 手动解封特定 IP

type SSEBroker

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

func NewSSEBroker

func NewSSEBroker() *SSEBroker

func (*SSEBroker) Broadcast

func (b *SSEBroker) Broadcast(eventType string, data any)

func (*SSEBroker) Close

func (b *SSEBroker) Close()

Close 让所有 SSE 连接立即结束;关停后新接入的连接也会马上结束。可重复调用。

func (*SSEBroker) HandleSSE

func (b *SSEBroker) HandleSSE(c *gin.Context)

type SaveWorkflowSheetRequest

type SaveWorkflowSheetRequest struct {
	Content string `json:"content"`
}

type SendTaskFeedbackRequest

type SendTaskFeedbackRequest struct {
	Body             string                `json:"body"`
	ExpectedRevision int64                 `json:"expected_revision"`
	Source           string                `json:"source,omitempty"`
	References       []model.PathReference `json:"references"`
}

type Server

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

func NewServer

func NewServer(cfg *config.Config, st *store.Store, staticFS fs.FS) *Server

func (*Server) Broker

func (s *Server) Broker() *SSEBroker

func (*Server) Engine

func (s *Server) Engine() *gin.Engine

func (*Server) MCPServer

func (s *Server) MCPServer() *mcp.Server

func (*Server) Run

func (s *Server) Run(addr string) error

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context)

Shutdown 优雅关闭被 HTTP 服务器「劫持」的长连接(终端 WebSocket):http.Server.Shutdown 不会处理它们, 因此必须在 http.Server.Shutdown 之前调用,让终端连接带着关闭码结束。

func (*Server) Start

func (s *Server) Start()

Start 启动需要后台协程的组件(终端总闸监视与周期清理)。应在开始接受连接之前调用;重复调用无副作用。

func (*Server) Store

func (s *Server) Store() *store.Store

func (*Server) Terminal

func (s *Server) Terminal() *terminal.Hub

Terminal 返回终端 Hub(可能为 nil)。

type SubmitFeedbackRequest

type SubmitFeedbackRequest struct {
	ResponseText string          `json:"response_text"`
	UserMessages []string        `json:"user_messages"`
	Images       []feedbackImage `json:"images"`
	// DraftWorkflowID 是草稿图片所在的工作流(图片带 draft_key 时使用);缺省取会话所属的工作流。
	DraftWorkflowID string `json:"draft_workflow_id"`
}

type TranscribeAudioRequest

type TranscribeAudioRequest struct {
	AudioBase64 string `json:"audio_base64"`
	MimeType    string `json:"mime_type"`
	APIURL      string `json:"api_url"`
	APIKey      string `json:"api_key"`
	Model       string `json:"model"`
	Language    string `json:"language"`
	Stream      bool   `json:"stream"`
}

type UpdateTaskStagesRequest

type UpdateTaskStagesRequest struct {
	ExpectedRevision int64            `json:"expected_revision,omitempty"`
	CurrentStageID   string           `json:"current_stage_id,omitempty"`
	Stages           model.TaskStages `json:"stages"`
}

Jump to

Keyboard shortcuts

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