Documentation
¶
Index ¶
- Constants
- func BuildCSP(host string) string
- func ConfigureTrustedProxies(engine *gin.Engine, raw string)
- func GzipMiddleware() gin.HandlerFunc
- func RedactRequestURI(uri string) string
- func RedactingLogFormatter(param gin.LogFormatterParams) string
- func RedactingRecovery() gin.HandlerFunc
- func ResolveCSPMode(raw string) (mode string, warning string)
- func ResolveTrustedProxies(raw string) (proxies []string, mode string, err error)
- func SecurityHeadersMiddleware(mode string) gin.HandlerFunc
- type APIHandler
- func (h *APIHandler) AckReports(c *gin.Context)
- func (h *APIHandler) AddGroupMembers(c *gin.Context)
- func (h *APIHandler) AddProjectDir(c *gin.Context)
- func (h *APIHandler) AnswerConfirm(c *gin.Context)
- func (h *APIHandler) AnswerConfirmBatch(c *gin.Context)
- func (h *APIHandler) AppendWorkflowFeedback(c *gin.Context)
- func (h *APIHandler) ApplyProjectMigration(c *gin.Context)
- func (h *APIHandler) ArchiveProject(c *gin.Context)
- func (h *APIHandler) ArchiveProjectDoc(c *gin.Context)
- func (h *APIHandler) ArchiveSession(c *gin.Context)
- func (h *APIHandler) CancelSession(c *gin.Context)
- func (h *APIHandler) ConversationSummaries(c *gin.Context)
- func (h *APIHandler) CreateAuthProfile(c *gin.Context)
- func (h *APIHandler) CreateCredential(c *gin.Context)
- func (h *APIHandler) CreateGroup(c *gin.Context)
- func (h *APIHandler) CreateNorm(c *gin.Context)
- func (h *APIHandler) CreateProject(c *gin.Context)
- func (h *APIHandler) CreateProjectDoc(c *gin.Context)
- func (h *APIHandler) CreateProjectGrant(c *gin.Context)
- func (h *APIHandler) CreateTask(c *gin.Context)
- func (h *APIHandler) CreateWorkItem(c *gin.Context)
- func (h *APIHandler) CreateWorkModule(c *gin.Context)
- func (h *APIHandler) CreateWorkflow(c *gin.Context)
- func (h *APIHandler) DeleteArtifactData(c *gin.Context)
- func (h *APIHandler) DeleteAuthProfile(c *gin.Context)
- func (h *APIHandler) DeleteCredential(c *gin.Context)
- func (h *APIHandler) DeleteDraftImage(c *gin.Context)
- func (h *APIHandler) DeleteNorm(c *gin.Context)
- func (h *APIHandler) DeleteProjectDoc(c *gin.Context)
- func (h *APIHandler) DeleteProjectModule(c *gin.Context)
- func (h *APIHandler) DeleteSession(c *gin.Context)
- func (h *APIHandler) DeleteWorkItem(c *gin.Context)
- func (h *APIHandler) DeleteWorkModule(c *gin.Context)
- func (h *APIHandler) DeleteWorkflowDraft(c *gin.Context)
- func (h *APIHandler) DismissConfirm(c *gin.Context)
- func (h *APIHandler) ExportAuditCSV(c *gin.Context)
- func (h *APIHandler) ExportProjectDocsZip(c *gin.Context)
- func (h *APIHandler) ExportProjectKnowledgeZip(c *gin.Context)
- func (h *APIHandler) GetArtifact(c *gin.Context)
- func (h *APIHandler) GetArtifactData(c *gin.Context)
- func (h *APIHandler) GetAsyncMode(c *gin.Context)
- func (h *APIHandler) GetConfirm(c *gin.Context)
- func (h *APIHandler) GetConfirmsBoard(c *gin.Context)
- func (h *APIHandler) GetCredential(c *gin.Context)
- func (h *APIHandler) GetCurrentSession(c *gin.Context)
- func (h *APIHandler) GetDraftImage(c *gin.Context)
- func (h *APIHandler) GetGroup(c *gin.Context)
- func (h *APIHandler) GetInboxConfig(c *gin.Context)
- func (h *APIHandler) GetNorm(c *gin.Context)
- func (h *APIHandler) GetNotifyPrefs(c *gin.Context)
- func (h *APIHandler) GetNtfy(c *gin.Context)
- func (h *APIHandler) GetProject(c *gin.Context)
- func (h *APIHandler) GetProjectDoc(c *gin.Context)
- func (h *APIHandler) GetProjectDocLinks(c *gin.Context)
- func (h *APIHandler) GetProjectDocsBlueprint(c *gin.Context)
- func (h *APIHandler) GetSession(c *gin.Context)
- func (h *APIHandler) GetSessionImage(c *gin.Context)
- func (h *APIHandler) GetSettings(c *gin.Context)
- func (h *APIHandler) GetTask(c *gin.Context)
- func (h *APIHandler) GetWorkItem(c *gin.Context)
- func (h *APIHandler) GetWorkflowDraft(c *gin.Context)
- func (h *APIHandler) GetWorkflowInbox(c *gin.Context)
- func (h *APIHandler) GetWorkflowPhase(c *gin.Context)
- func (h *APIHandler) GetWorkflowSessionBodies(c *gin.Context)
- func (h *APIHandler) GetWorkflowSessions(c *gin.Context)
- func (h *APIHandler) GetWorkflowSheet(c *gin.Context)
- func (h *APIHandler) GetWorkflowUpdates(c *gin.Context)
- func (h *APIHandler) GroupCandidates(c *gin.Context)
- func (h *APIHandler) ImproveWorkItem(c *gin.Context)
- func (h *APIHandler) KeepaliveSession(c *gin.Context)
- func (h *APIHandler) LinkWorkItemSession(c *gin.Context)
- func (h *APIHandler) ListAgentIdentities(c *gin.Context)
- func (h *APIHandler) ListAgentSessions(c *gin.Context)
- func (h *APIHandler) ListArtifactComments(c *gin.Context)
- func (h *APIHandler) ListArtifactData(c *gin.Context)
- func (h *APIHandler) ListAudit(c *gin.Context)
- func (h *APIHandler) ListAuthProfiles(c *gin.Context)
- func (h *APIHandler) ListConfirms(c *gin.Context)
- func (h *APIHandler) ListConversationMessages(c *gin.Context)
- func (h *APIHandler) ListCredentials(c *gin.Context)
- func (h *APIHandler) ListDraftImages(c *gin.Context)
- func (h *APIHandler) ListGroups(c *gin.Context)
- func (h *APIHandler) ListNorms(c *gin.Context)
- func (h *APIHandler) ListProjectDocRevisions(c *gin.Context)
- func (h *APIHandler) ListProjectDocs(c *gin.Context)
- func (h *APIHandler) ListProjectGrants(c *gin.Context)
- func (h *APIHandler) ListProjectKnowledge(c *gin.Context)
- func (h *APIHandler) ListProjects(c *gin.Context)
- func (h *APIHandler) ListQueuedFeedbacks(c *gin.Context)
- func (h *APIHandler) ListSessions(c *gin.Context)
- func (h *APIHandler) ListTasks(c *gin.Context)
- func (h *APIHandler) ListWorkItemAssignees(c *gin.Context)
- func (h *APIHandler) ListWorkItems(c *gin.Context)
- func (h *APIHandler) ListWorkModules(c *gin.Context)
- func (h *APIHandler) ListWorkflowCheckpoints(c *gin.Context)
- func (h *APIHandler) MarkConversationRead(c *gin.Context)
- func (h *APIHandler) MoveWorkModule(c *gin.Context)
- func (h *APIHandler) PostArtifactComment(c *gin.Context)
- func (h *APIHandler) PostProjectDocComment(c *gin.Context)
- func (h *APIHandler) PreviewCredentialTools(c *gin.Context)
- func (h *APIHandler) ProjectBlueprint(c *gin.Context)
- func (h *APIHandler) ProjectMigration(c *gin.Context)
- func (h *APIHandler) ProjectModulePage(c *gin.Context)
- func (h *APIHandler) ProjectSuggestions(c *gin.Context)
- func (h *APIHandler) PutArtifactData(c *gin.Context)
- func (h *APIHandler) PutDraftImage(c *gin.Context)
- func (h *APIHandler) ReadReports(c *gin.Context)
- func (h *APIHandler) ReadTaskFeedbacks(c *gin.Context)
- func (h *APIHandler) RegenerateCredentialToken(c *gin.Context)
- func (h *APIHandler) RemoveGroupMember(c *gin.Context)
- func (h *APIHandler) RemoveProjectDir(c *gin.Context)
- func (h *APIHandler) RenameSession(c *gin.Context)
- func (h *APIHandler) RenderArtifact(c *gin.Context)
- func (h *APIHandler) ReplyWindow(c *gin.Context)
- func (h *APIHandler) ResetNotifyConversation(c *gin.Context)
- func (h *APIHandler) ResolveArtifactComment(c *gin.Context)
- func (h *APIHandler) RestoreProjectDocRevision(c *gin.Context)
- func (h *APIHandler) RestoreSession(c *gin.Context)
- func (h *APIHandler) RevokeProjectGrant(c *gin.Context)
- func (h *APIHandler) RevokeQueuedFeedback(c *gin.Context)
- func (h *APIHandler) RevokeSession(c *gin.Context)
- func (h *APIHandler) SaveWorkflowDraft(c *gin.Context)
- func (h *APIHandler) SaveWorkflowSheet(c *gin.Context)
- func (h *APIHandler) SearchProjectDocs(c *gin.Context)
- func (h *APIHandler) SearchProjectKnowledge(c *gin.Context)
- func (h *APIHandler) SendConversationMessage(c *gin.Context)
- func (h *APIHandler) SendTaskFeedback(c *gin.Context)
- func (h *APIHandler) ServeHookBinary(c *gin.Context)
- func (h *APIHandler) ServeHookInstallPs1(c *gin.Context)
- func (h *APIHandler) ServeHookInstallSh(c *gin.Context)
- func (h *APIHandler) SessionPresence(c *gin.Context)
- func (h *APIHandler) SetDefaultAuthProfile(c *gin.Context)
- func (h *APIHandler) SetGroupMemberPolicy(c *gin.Context)
- func (h *APIHandler) SetNotifyConversation(c *gin.Context)
- func (h *APIHandler) SetNtfy(n *ntfy.Notifier)
- func (h *APIHandler) SetTerminal(hub *terminal.Hub)
- func (h *APIHandler) SetWorkflowPhase(c *gin.Context)
- func (h *APIHandler) SubmitFeedback(c *gin.Context)
- func (h *APIHandler) TestNtfy(c *gin.Context)
- func (h *APIHandler) TranscribeAudio(c *gin.Context)
- func (h *APIHandler) UnarchiveSession(c *gin.Context)
- func (h *APIHandler) UnlinkWorkItemSession(c *gin.Context)
- func (h *APIHandler) UpdateAgentIdentity(c *gin.Context)
- func (h *APIHandler) UpdateAsyncMode(c *gin.Context)
- func (h *APIHandler) UpdateAuthProfile(c *gin.Context)
- func (h *APIHandler) UpdateCredential(c *gin.Context)
- func (h *APIHandler) UpdateGroup(c *gin.Context)
- func (h *APIHandler) UpdateInboxConfig(c *gin.Context)
- func (h *APIHandler) UpdateNorm(c *gin.Context)
- func (h *APIHandler) UpdateNotifyPrefs(c *gin.Context)
- func (h *APIHandler) UpdateNtfy(c *gin.Context)
- func (h *APIHandler) UpdateProject(c *gin.Context)
- func (h *APIHandler) UpdateProjectDoc(c *gin.Context)
- func (h *APIHandler) UpdateSessionMaxChecks(c *gin.Context)
- func (h *APIHandler) UpdateSessionPromptWait(c *gin.Context)
- func (h *APIHandler) UpdateSessionWaitCountdown(c *gin.Context)
- func (h *APIHandler) UpdateSettings(c *gin.Context)
- func (h *APIHandler) UpdateTaskStages(c *gin.Context)
- func (h *APIHandler) UpdateWorkItem(c *gin.Context)
- func (h *APIHandler) UpdateWorkModule(c *gin.Context)
- func (h *APIHandler) UpsertProjectModule(c *gin.Context)
- func (h *APIHandler) WorkflowProject(c *gin.Context)
- type AckReportsRequest
- type AuthHandler
- func (a *AuthHandler) ArtifactRenderMiddleware() gin.HandlerFunc
- func (a *AuthHandler) ChangeCredentials(c *gin.Context)
- func (a *AuthHandler) ClearAllBlockedIPs(c *gin.Context)
- func (a *AuthHandler) EffectiveCredentials(ctx context.Context) (username string, password string, err error)
- func (a *AuthHandler) GetBlockedIPs(c *gin.Context)
- func (a *AuthHandler) IsMCPToken(tokenString string) bool
- func (a *AuthHandler) IssueArtifactTicket(c *gin.Context)
- func (a *AuthHandler) IssueSSETicket(c *gin.Context)
- func (a *AuthHandler) Login(c *gin.Context)
- func (a *AuthHandler) Middleware() gin.HandlerFunc
- func (a *AuthHandler) ResetCredentials(c *gin.Context)
- func (a *AuthHandler) RevealCredentialToken(c *gin.Context)
- func (a *AuthHandler) SetCredentialRevealHook(fn func(actor, ip, result, detail string))
- func (a *AuthHandler) SetCredentialsChangedHook(fn func(subject, ip string))
- func (a *AuthHandler) Status(c *gin.Context)
- func (a *AuthHandler) StreamMiddleware() gin.HandlerFunc
- func (a *AuthHandler) UnblockIP(c *gin.Context)
- func (a *AuthHandler) VerifyHumanJWT(tokenString string) (subject string, ok bool)
- func (a *AuthHandler) VerifyJWTToken(tokenString string) (*jwt.MapClaims, bool)
- type BlockedIPInfo
- type ChangeCredentialsRequest
- type CreateTaskRequest
- type GroupCandidate
- type IPAttempt
- type LoginRequest
- type RateLimitedWriter
- type RateLimiter
- func (rl *RateLimiter) CheckLocked(ip string) (isLocked bool, remaining time.Duration)
- func (rl *RateLimiter) ClearAll()
- func (rl *RateLimiter) Close()
- func (rl *RateLimiter) GetBlockedIPs() []BlockedIPInfo
- func (rl *RateLimiter) RecordFailure(ip string, maxAttempts int, lockoutDuration time.Duration) (isLocked bool, remaining time.Duration)
- func (rl *RateLimiter) RecordSuccess(ip string)
- func (rl *RateLimiter) UnblockIP(ip string)
- type SSEBroker
- type SaveWorkflowSheetRequest
- type SendTaskFeedbackRequest
- type Server
- func (s *Server) Broker() *SSEBroker
- func (s *Server) Engine() *gin.Engine
- func (s *Server) MCPServer() *mcp.Server
- func (s *Server) Run(addr string) error
- func (s *Server) Shutdown(ctx context.Context)
- func (s *Server) Start()
- func (s *Server) Store() *store.Store
- func (s *Server) Terminal() *terminal.Hub
- type SubmitFeedbackRequest
- type TranscribeAudioRequest
- type UpdateTaskStagesRequest
Constants ¶
const ( // CSPModeOff 关闭 CSP 头(仅用于排查兼容问题);其余安全头仍然下发。 CSPModeOff = "off" // CSPModeReport 只上报不拦截(Content-Security-Policy-Report-Only),用于灰度观察。 CSPModeReport = "report" // CSPModeEnforce 强制执行(默认)。 CSPModeEnforce = "enforce" )
Variables ¶
This section is empty.
Functions ¶
func BuildCSP ¶
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 ¶
ConfigureTrustedProxies 按 RELAYMESH_TRUSTED_PROXIES 设置 Gin 的可信代理网段。
背景:Gin 默认信任全部代理,此时 c.ClientIP() 会采信客户端自带的 X-Forwarded-For 最左项, 而登录反爆破(RateLimiter)与终端预认证限流都以它为键,攻击者每次换一个头值即可绕过锁定。 配置错误时回退为默认网段(回环 + 私网)而不是 Gin 的「信任全部」,宁可少信任也不多信任。
func GzipMiddleware ¶
func GzipMiddleware() gin.HandlerFunc
GzipMiddleware 为 HTTP 响应提供动态 Gzip 压缩,显著缩减大 JSON 和富文本在小带宽服务器上的网络传输体积
func RedactRequestURI ¶
RedactRequestURI 把访问日志里的凭据脱敏:
- 查询参数 token / ticket / access_token / key / api_key / password 的值
- 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 ¶
ResolveCSPMode 规范化 RELAYMESH_CSP。空值与非法值都回落到 enforce,并返回提示文案(非法时)。
func ResolveTrustedProxies ¶
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 (*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) 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) 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": "(可选)"}
201 {"status":"ok","workflow_id":"...","session":{占位会话},"start_prompt":"...",
"applied":{…实际生效的高级选项,没填就没有这个字段…},"warnings":[…落库之后没做成的事,没有就没有这个字段…]}
400 名字 / 编号 / 阶段 / 首条指令 / 目录 / 主机不合规(都发生在落库之前,不会留下半个会话) 409 给定的编号已存在
高级选项(#184)全部可选,都不填时与改动前的请求 / 响应逐字节相同:
- project_directory:占位会话(以及这个工作流)绑定到这个目录,D-161 从此要求智能体第一次汇报带同一个目录;
- host_name:占位会话的归属主机标签(智能体接入后,凭据绑定的主机仍以凭据为准);
- phase:起始阶段,按「人点的阶段」写入(同时是人工偏好阶段),广播 phase_changed;
- first_message:首条指令,经现有的投递规则一律排进收件箱(占位会话已完成且已被消费),智能体接入后读到。
校验类错误一律发生在落库之前;会话建好之后,阶段 / 首条指令这两步若失败,会话仍然保留,原因写进 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) ExportAuditCSV ¶
func (h *APIHandler) ExportAuditCSV(c *gin.Context)
ExportAuditCSV GET /api/v1/audit/export.csv(同样的筛选条件,最多 500 条一页,用 before 翻页)。
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) 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) 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,状态绑定智能体的开发流程),所以这里不再带「待验收的任务」; review_tasks / counts.review_tasks 两个字段保留为恒空([] / 0),只为兼容还没刷新的旧页面,新页面不读。
func (*APIHandler) GetCredential ¶
func (h *APIHandler) GetCredential(c *gin.Context)
func (*APIHandler) GetCurrentSession ¶
func (h *APIHandler) GetCurrentSession(c *gin.Context)
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 (*APIHandler) GetProjectDocLinks ¶
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) GetSession ¶
func (h *APIHandler) GetSession(c *gin.Context)
func (*APIHandler) GetSessionImage ¶
func (h *APIHandler) GetSessionImage(c *gin.Context)
func (*APIHandler) GetTask ¶
func (h *APIHandler) GetTask(c *gin.Context)
func (*APIHandler) GetWorkItem ¶
func (h *APIHandler) GetWorkItem(c *gin.Context)
GetWorkItem 返回任务详情(含最近的时间线与关联会话)。
func (*APIHandler) GetWorkflowDraft ¶
func (h *APIHandler) GetWorkflowDraft(c *gin.Context)
Workflow Drafts Handlers
func (*APIHandler) GetWorkflowInbox ¶
func (h *APIHandler) GetWorkflowInbox(c *gin.Context)
GetWorkflowInbox 返回一个工作流收件箱的现状。
func (*APIHandler) GetWorkflowPhase ¶
func (h *APIHandler) GetWorkflowPhase(c *gin.Context)
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) 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) ListGroups ¶
func (h *APIHandler) ListGroups(c *gin.Context)
ListGroups GET /api/v1/groups?archived=1
func (*APIHandler) ListNorms ¶
func (h *APIHandler) ListNorms(c *gin.Context)
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) 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) 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) 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) ProjectBlueprint ¶
func (h *APIHandler) ProjectBlueprint(c *gin.Context)
ProjectBlueprint GET /api/v1/projects/:id/blueprint?templates=1
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) PutDraftImage ¶
func (h *APIHandler) PutDraftImage(c *gin.Context)
PutDraftImage 上传(或重新确认)一张草稿图片。幂等:同一个内容键重复上传只刷新写入时间。
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) 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) RestoreProjectDocRevision ¶
func (h *APIHandler) RestoreProjectDocRevision(c *gin.Context)
RestoreProjectDocRevision POST /api/v1/workflows/:workflow_id/docs/:doc/revisions/:rev/restore
func (*APIHandler) RestoreSession ¶
func (h *APIHandler) RestoreSession(c *gin.Context)
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) 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) 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) 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) SetTerminal ¶
func (h *APIHandler) SetTerminal(hub *terminal.Hub)
SetTerminal 注入终端 Hub:令牌管理里涉及终端的操作需要它做二次解锁校验,令牌变更后也要通知它取消进行中的运行。
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 就用已保存的配置。不论推送成败,接口本身都返回 200,结果在 ok / error 里。
func (*APIHandler) TranscribeAudio ¶
func (h *APIHandler) TranscribeAudio(c *gin.Context)
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) UpdateAsyncMode ¶
func (h *APIHandler) UpdateAsyncMode(c *gin.Context)
UpdateAsyncMode PUT /api/v1/workflows/:workflow_id/async-mode { "enabled"?: bool, "profile_id"?: number } 开启需要这个工作流收到过 hook 事件,否则 409 并说明怎么办;关闭永远允许。
func (*APIHandler) UpdateAuthProfile ¶
func (h *APIHandler) UpdateAuthProfile(c *gin.Context)
UpdateAuthProfile PUT /api/v1/auth-profiles/:id
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) 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) 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) Status ¶
func (a *AuthHandler) Status(c *gin.Context)
func (*AuthHandler) StreamMiddleware ¶
func (a *AuthHandler) StreamMiddleware() gin.HandlerFunc
StreamMiddleware 用于 SSE 等浏览器原生 API 无法自定义请求头的流式端点,凭据来源依次为:
- Authorization: Bearer 头;
- ?ticket=:由 POST /api/v1/auth/sse_ticket 签发的一次性票据(30 秒、单次,泄漏进日志也无价值);
- ?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 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 LoginRequest ¶
type RateLimitedWriter ¶
type RateLimitedWriter struct {
// contains filtered or unexported fields
}
RateLimitedWriter 实现带上下文感知与平滑分块输出的流式限速器,为核心 SSE 与 API 预留生存带宽
func NewRateLimitedWriter ¶
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) 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 的所有失败记录
type SSEBroker ¶
type SSEBroker struct {
// contains filtered or unexported fields
}
func NewSSEBroker ¶
func NewSSEBroker() *SSEBroker
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 (*Server) Shutdown ¶
Shutdown 优雅关闭被 HTTP 服务器「劫持」的长连接(终端 WebSocket):http.Server.Shutdown 不会处理它们, 因此必须在 http.Server.Shutdown 之前调用,让终端连接带着关闭码结束。
type SubmitFeedbackRequest ¶
type TranscribeAudioRequest ¶
type UpdateTaskStagesRequest ¶
type UpdateTaskStagesRequest struct {
ExpectedRevision int64 `json:"expected_revision,omitempty"`
CurrentStageID string `json:"current_stage_id,omitempty"`
Stages model.TaskStages `json:"stages"`
}
Source Files
¶
- agent_state.go
- artifacts.go
- async_mode.go
- auth.go
- checkpoints.go
- clientip.go
- conditional.go
- confirms.go
- conversations.go
- credentials_preview.go
- credentials_reveal.go
- credentials_terminal.go
- draft_images.go
- groups.go
- gzip.go
- hook_install.go
- inbox.go
- notify_gate.go
- notify_prefs.go
- ntfy.go
- ntfy_guard.go
- ntfy_run.go
- oauth_handlers.go
- preset_runner.go
- project_docs.go
- projects.go
- ratelimit.go
- routes.go
- security.go
- server.go
- session_aggregates.go
- session_payload.go
- sessions_light.go
- sse.go
- sse_conversation.go
- static_cache.go
- terminal.go
- web_workflow.go
- work_items.go
- work_items_maintenance.go
- work_modules.go