api

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GzipMiddleware added in v1.3.0

func GzipMiddleware() gin.HandlerFunc

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

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) AckReports

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

func (*APIHandler) AppendWorkflowFeedback

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

func (*APIHandler) ArchiveSession

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

func (*APIHandler) CancelSession

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

func (*APIHandler) CreateCredential added in v1.1.0

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

func (*APIHandler) CreateNorm added in v1.1.0

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

func (*APIHandler) CreateTask added in v1.1.0

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

func (*APIHandler) DeleteCredential added in v1.1.0

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

func (*APIHandler) DeleteNorm added in v1.1.0

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

func (*APIHandler) DeleteWorkflowDraft

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

func (*APIHandler) GetCredential added in v1.1.0

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

func (*APIHandler) GetCurrentSession

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

func (*APIHandler) GetNorm added in v1.1.0

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

func (*APIHandler) GetSession

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

func (*APIHandler) GetSessionImage added in v1.3.0

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

func (*APIHandler) GetSettings

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

Settings APIs

func (*APIHandler) GetTask

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

func (*APIHandler) GetWorkflowDraft

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

Workflow Drafts Handlers

func (*APIHandler) GetWorkflowPhase added in v1.1.0

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

func (*APIHandler) GetWorkflowSessions added in v1.3.0

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

func (*APIHandler) GetWorkflowSheet added in v1.5.0

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

func (*APIHandler) KeepaliveSession

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

func (*APIHandler) ListCredentials added in v1.1.0

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

func (*APIHandler) ListNorms added in v1.1.0

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

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) ReadReports

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

func (*APIHandler) ReadTaskFeedbacks added in v1.1.0

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

func (*APIHandler) RegenerateCredentialToken added in v1.1.0

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

func (*APIHandler) RenameSession

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

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 added in v1.5.0

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

func (*APIHandler) SendTaskFeedback

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

func (*APIHandler) SetWorkflowPhase added in v1.1.0

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

func (*APIHandler) SubmitFeedback

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

func (*APIHandler) TranscribeAudio

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

func (*APIHandler) UnarchiveSession

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

func (*APIHandler) UpdateCredential added in v1.1.0

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

func (*APIHandler) UpdateNorm added in v1.1.0

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

func (*APIHandler) UpdateSessionMaxChecks

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

func (*APIHandler) UpdateSessionPromptWait

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

func (*APIHandler) UpdateSessionUserPresence

func (h *APIHandler) UpdateSessionUserPresence(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 added in v1.1.0

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

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) ChangeCredentials

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

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

func (*AuthHandler) ClearAllBlockedIPs

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

func (*AuthHandler) GetBlockedIPs

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

func (*AuthHandler) GetEffectiveCredentials

func (a *AuthHandler) GetEffectiveCredentials(c *gin.Context) (username string, password string)

GetEffectiveCredentials 获取当前生效的账号和密码(优先数据库,兜底环境变量)

func (*AuthHandler) Login

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

func (*AuthHandler) Middleware

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

func (*AuthHandler) ResetCredentials

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

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

func (*AuthHandler) Status

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

func (*AuthHandler) UnblockIP

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

func (*AuthHandler) VerifyToken

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

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 added in v1.1.0

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 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 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) HandleSSE

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

type SaveWorkflowSheetRequest added in v1.5.0

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 added in v1.2.0

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) Store added in v1.2.0

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

type SubmitFeedbackRequest

type SubmitFeedbackRequest struct {
	ResponseText string               `json:"response_text"`
	UserMessages []string             `json:"user_messages"`
	Images       []model.SessionImage `json:"images"`
}

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 added in v1.1.0

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