|
|
|
@@ -33,6 +33,7 @@ import (
|
|
|
|
|
"github.com/Autumn-27/artex/llmpool"
|
|
|
|
|
"github.com/Autumn-27/artex/llmrec"
|
|
|
|
|
"github.com/Autumn-27/artex/report"
|
|
|
|
|
"github.com/Autumn-27/artex/server/perm"
|
|
|
|
|
"github.com/Autumn-27/artex/traffic"
|
|
|
|
|
"github.com/Autumn-27/norma/llm"
|
|
|
|
|
actool "github.com/Autumn-27/norma/tool"
|
|
|
|
@@ -802,339 +803,352 @@ func (s *Server) chatAgentRef() *agent.ChatAgent {
|
|
|
|
|
return s.chatAgent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Server) Handler() http.Handler {
|
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
|
// apiRoutes builds the /api/ mux with every API route and its permission.
|
|
|
|
|
func (s *Server) apiRoutes() *apiMux {
|
|
|
|
|
mux := newAPIMux()
|
|
|
|
|
s.registerSideRoutes(mux)
|
|
|
|
|
s.registerSharedBrowserRoutes(mux)
|
|
|
|
|
|
|
|
|
|
// Auth routes — exempt from JWT check (handled in requireAuth)
|
|
|
|
|
mux.HandleFunc("GET /api/auth/status", s.authStatus)
|
|
|
|
|
mux.HandleFunc("POST /api/auth/init", s.authInit)
|
|
|
|
|
mux.HandleFunc("POST /api/auth/login", s.authLogin)
|
|
|
|
|
mux.HandleFunc("POST /api/auth/change-password", s.authChangePassword)
|
|
|
|
|
s.handle(mux, "GET /api/auth/status", perm.Public, s.authStatus)
|
|
|
|
|
s.handle(mux, "POST /api/auth/init", perm.Public, s.authInit)
|
|
|
|
|
s.handle(mux, "POST /api/auth/login", perm.Public, s.authLogin)
|
|
|
|
|
s.handle(mux, "POST /api/auth/change-password", perm.Public, s.authChangePassword)
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("GET /api/health", s.health)
|
|
|
|
|
mux.HandleFunc("GET /api/ready", s.ready)
|
|
|
|
|
mux.HandleFunc("GET /api/stats", s.stats)
|
|
|
|
|
mux.HandleFunc("GET /api/logs", s.getLogs)
|
|
|
|
|
mux.HandleFunc("GET /api/logs/history", s.getLogsHistory)
|
|
|
|
|
mux.HandleFunc("GET /api/logs/stream", s.streamLogs)
|
|
|
|
|
s.handle(mux, "GET /api/health", perm.Public, s.health)
|
|
|
|
|
s.handle(mux, "GET /api/ready", perm.Public, s.ready)
|
|
|
|
|
s.handle(mux, "GET /api/stats", perm.Authenticated, s.stats)
|
|
|
|
|
s.handle(mux, "GET /api/logs", perm.Authenticated, s.getLogs)
|
|
|
|
|
s.handle(mux, "GET /api/logs/history", perm.Authenticated, s.getLogsHistory)
|
|
|
|
|
s.handle(mux, "GET /api/logs/stream", perm.Authenticated, s.streamLogs)
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("GET /api/tasks", s.listTasks)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks", s.createTask)
|
|
|
|
|
mux.HandleFunc("GET /api/skill-gaps", s.skillGaps)
|
|
|
|
|
mux.HandleFunc("GET /api/task-categories", s.pgListTaskCategories)
|
|
|
|
|
mux.HandleFunc("POST /api/task-categories", s.pgCreateTaskCategory)
|
|
|
|
|
mux.HandleFunc("PATCH /api/task-categories/{id}", s.pgRenameTaskCategory)
|
|
|
|
|
mux.HandleFunc("DELETE /api/task-categories/{id}", s.pgDeleteTaskCategory)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/category/batch", s.updateTasksCategoryBatch)
|
|
|
|
|
mux.HandleFunc("GET /api/task-templates", s.pgListTaskTemplates)
|
|
|
|
|
mux.HandleFunc("POST /api/task-templates", s.pgCreateTaskTemplate)
|
|
|
|
|
mux.HandleFunc("PATCH /api/task-templates/{id}", s.pgUpdateTaskTemplate)
|
|
|
|
|
mux.HandleFunc("DELETE /api/task-templates/{id}", s.pgDeleteTaskTemplate)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}", s.getTask)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/outcome", s.taskOutcome)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/lessons", s.taskLessons)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/lessons/extract", s.extractTaskLessons)
|
|
|
|
|
mux.HandleFunc("PATCH /api/tasks/{id}", s.updateTaskMetadata)
|
|
|
|
|
mux.HandleFunc("PATCH /api/tasks/{id}/category", s.updateTaskCategory)
|
|
|
|
|
s.handle(mux, "GET /api/tasks", perm.Authenticated, s.listTasks)
|
|
|
|
|
s.handle(mux, "POST /api/tasks", perm.Authenticated, s.createTask)
|
|
|
|
|
s.handle(mux, "GET /api/skill-gaps", perm.Authenticated, s.skillGaps)
|
|
|
|
|
s.handle(mux, "GET /api/task-categories", perm.Authenticated, s.pgListTaskCategories)
|
|
|
|
|
s.handle(mux, "POST /api/task-categories", perm.Authenticated, s.pgCreateTaskCategory)
|
|
|
|
|
s.handle(mux, "PATCH /api/task-categories/{id}", perm.Authenticated, s.pgRenameTaskCategory)
|
|
|
|
|
s.handle(mux, "DELETE /api/task-categories/{id}", perm.Authenticated, s.pgDeleteTaskCategory)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/category/batch", perm.Authenticated, s.updateTasksCategoryBatch)
|
|
|
|
|
s.handle(mux, "GET /api/task-templates", perm.Authenticated, s.pgListTaskTemplates)
|
|
|
|
|
s.handle(mux, "POST /api/task-templates", perm.Authenticated, s.pgCreateTaskTemplate)
|
|
|
|
|
s.handle(mux, "PATCH /api/task-templates/{id}", perm.Authenticated, s.pgUpdateTaskTemplate)
|
|
|
|
|
s.handle(mux, "DELETE /api/task-templates/{id}", perm.Authenticated, s.pgDeleteTaskTemplate)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}", perm.Authenticated, s.getTask)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/outcome", perm.Authenticated, s.taskOutcome)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/lessons", perm.Authenticated, s.taskLessons)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/lessons/extract", perm.Authenticated, s.extractTaskLessons)
|
|
|
|
|
s.handle(mux, "PATCH /api/tasks/{id}", perm.Authenticated, s.updateTaskMetadata)
|
|
|
|
|
s.handle(mux, "PATCH /api/tasks/{id}/category", perm.Authenticated, s.updateTaskCategory)
|
|
|
|
|
// task-level asset interception/allow rules
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/intercept-rules", s.taskInterceptListRules)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/intercept-rules", s.taskInterceptCreateRule)
|
|
|
|
|
mux.HandleFunc("PUT /api/tasks/{id}/intercept-rules/{rid}", s.taskInterceptUpdateRule)
|
|
|
|
|
mux.HandleFunc("DELETE /api/tasks/{id}/intercept-rules/{rid}", s.taskInterceptDeleteRule)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/intercept-rules/{rid}/toggle", s.taskInterceptToggleRule)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/target-pins", s.taskListTargetPins)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/target-pins/{pid}/revoke", s.taskRevokeTargetPin)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/control/batch", s.controlTasksBatch)
|
|
|
|
|
mux.HandleFunc("GET /api/task-archives", s.listTaskArchives)
|
|
|
|
|
mux.HandleFunc("GET /api/task-archives/{id}", s.getTaskArchive)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/credentials", s.listTaskCredentials)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/credentials", s.addTaskCredential)
|
|
|
|
|
mux.HandleFunc("DELETE /api/tasks/{id}/credentials/{cid}", s.deleteTaskCredential)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/archive", s.queueTaskArchive)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/archive/batch", s.queueTaskArchivesBatch)
|
|
|
|
|
mux.HandleFunc("POST /api/task-archives/{id}/restore", s.queueTaskArchiveRestore)
|
|
|
|
|
mux.HandleFunc("POST /api/task-archives/restore/batch", s.restoreTaskArchivesBatch)
|
|
|
|
|
mux.HandleFunc("DELETE /api/task-archives/{id}", s.queueTaskArchiveDelete)
|
|
|
|
|
mux.HandleFunc("POST /api/task-archives/delete/batch", s.deleteTaskArchivesBatch)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/coverage", s.taskCoverage)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/coverage-graph", s.taskCoverageGraph)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/asset-refs", s.taskAssetRefs)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/assets", s.attachTaskAssets)
|
|
|
|
|
mux.HandleFunc("DELETE /api/tasks/{id}/assets/{assetID}", s.detachTaskAsset)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/intent-assets", s.taskIntentAssets)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/intercept-rules", perm.Authenticated, s.taskInterceptListRules)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/intercept-rules", perm.Authenticated, s.taskInterceptCreateRule)
|
|
|
|
|
s.handle(mux, "PUT /api/tasks/{id}/intercept-rules/{rid}", perm.Authenticated, s.taskInterceptUpdateRule)
|
|
|
|
|
s.handle(mux, "DELETE /api/tasks/{id}/intercept-rules/{rid}", perm.Authenticated, s.taskInterceptDeleteRule)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/intercept-rules/{rid}/toggle", perm.Authenticated, s.taskInterceptToggleRule)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/target-pins", perm.Authenticated, s.taskListTargetPins)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/target-pins/{pid}/revoke", perm.Authenticated, s.taskRevokeTargetPin)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/control/batch", perm.Authenticated, s.controlTasksBatch)
|
|
|
|
|
s.handle(mux, "GET /api/task-archives", perm.Authenticated, s.listTaskArchives)
|
|
|
|
|
s.handle(mux, "GET /api/task-archives/{id}", perm.Authenticated, s.getTaskArchive)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/credentials", perm.Authenticated, s.listTaskCredentials)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/credentials", perm.Authenticated, s.addTaskCredential)
|
|
|
|
|
s.handle(mux, "DELETE /api/tasks/{id}/credentials/{cid}", perm.Authenticated, s.deleteTaskCredential)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/archive", perm.Authenticated, s.queueTaskArchive)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/archive/batch", perm.Authenticated, s.queueTaskArchivesBatch)
|
|
|
|
|
s.handle(mux, "POST /api/task-archives/{id}/restore", perm.Authenticated, s.queueTaskArchiveRestore)
|
|
|
|
|
s.handle(mux, "POST /api/task-archives/restore/batch", perm.Authenticated, s.restoreTaskArchivesBatch)
|
|
|
|
|
s.handle(mux, "DELETE /api/task-archives/{id}", perm.Authenticated, s.queueTaskArchiveDelete)
|
|
|
|
|
s.handle(mux, "POST /api/task-archives/delete/batch", perm.Authenticated, s.deleteTaskArchivesBatch)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/coverage", perm.Authenticated, s.taskCoverage)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/coverage-graph", perm.Authenticated, s.taskCoverageGraph)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/asset-refs", perm.Authenticated, s.taskAssetRefs)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/assets", perm.Authenticated, s.attachTaskAssets)
|
|
|
|
|
s.handle(mux, "DELETE /api/tasks/{id}/assets/{assetID}", perm.Authenticated, s.detachTaskAsset)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/intent-assets", perm.Authenticated, s.taskIntentAssets)
|
|
|
|
|
|
|
|
|
|
// workspace file manager (over workDir)
|
|
|
|
|
mux.HandleFunc("GET /api/workspace/list", s.wsList)
|
|
|
|
|
mux.HandleFunc("GET /api/workspace/read", s.wsRead)
|
|
|
|
|
mux.HandleFunc("POST /api/workspace/write", s.wsWrite)
|
|
|
|
|
mux.HandleFunc("POST /api/workspace/mkdir", s.wsMkdir)
|
|
|
|
|
mux.HandleFunc("DELETE /api/workspace/delete", s.wsDelete)
|
|
|
|
|
mux.HandleFunc("GET /api/workspace/download", s.wsDownload)
|
|
|
|
|
mux.HandleFunc("POST /api/workspace/upload", s.wsUpload)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/scope", s.taskScopeList)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/scope", s.taskScopeAdd)
|
|
|
|
|
mux.HandleFunc("DELETE /api/tasks/{id}/scope/{sid}", s.taskScopeDelete)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/goals", s.listGoals) // goal management: list all goals of this task
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/goals", s.addGoal) // goal management: human-added goal (revives the task)
|
|
|
|
|
mux.HandleFunc("PATCH /api/tasks/{id}/goals/{gid}", s.editGoal) // goal management: edit a goal (revives the task)
|
|
|
|
|
mux.HandleFunc("DELETE /api/tasks/{id}/goals/{gid}", s.deleteGoal) // goal management: hard-delete a goal (no revival)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/constraints", s.listConstraints) // constraint management: list this task's operation constraints
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/constraints", s.addConstraint) // constraint management: add a constraint (planner not notified)
|
|
|
|
|
mux.HandleFunc("PATCH /api/tasks/{id}/constraints/{cid}", s.editConstraint) // constraint management: edit a constraint
|
|
|
|
|
mux.HandleFunc("DELETE /api/tasks/{id}/constraints/{cid}", s.deleteConstraint) // constraint management: delete a constraint
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/control", s.control)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/retarget", s.retargetTaskHandler)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/extend", s.extendTaskHandler)
|
|
|
|
|
mux.HandleFunc("PUT /api/tasks/{id}/llm", s.updateTaskLLMProfiles)
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/llm/resolution", s.taskLLMResolutionHandler)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/intents/{iid}/control", s.controlIntent)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/intents/{iid}/messages", s.sendWorkerMessage)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/intents/{iid}/rerun", s.rerunIntent) // rerun one blocked/exhausted/stopped intent
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/intents/rerun-blocked", s.rerunBlocked) // batch-rerun all blocked intents of this task
|
|
|
|
|
mux.HandleFunc("POST /api/active", s.setActive)
|
|
|
|
|
s.handle(mux, "GET /api/workspace/list", perm.Authenticated, s.wsList)
|
|
|
|
|
s.handle(mux, "GET /api/workspace/read", perm.Authenticated, s.wsRead)
|
|
|
|
|
s.handle(mux, "POST /api/workspace/write", perm.Authenticated, s.wsWrite)
|
|
|
|
|
s.handle(mux, "POST /api/workspace/mkdir", perm.Authenticated, s.wsMkdir)
|
|
|
|
|
s.handle(mux, "DELETE /api/workspace/delete", perm.Authenticated, s.wsDelete)
|
|
|
|
|
s.handle(mux, "GET /api/workspace/download", perm.Authenticated, s.wsDownload)
|
|
|
|
|
s.handle(mux, "POST /api/workspace/upload", perm.Authenticated, s.wsUpload)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/scope", perm.Authenticated, s.taskScopeList)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/scope", perm.Authenticated, s.taskScopeAdd)
|
|
|
|
|
s.handle(mux, "DELETE /api/tasks/{id}/scope/{sid}", perm.Authenticated, s.taskScopeDelete)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/goals", perm.Authenticated, s.listGoals) // goal management: list all goals of this task
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/goals", perm.Authenticated, s.addGoal) // goal management: human-added goal (revives the task)
|
|
|
|
|
s.handle(mux, "PATCH /api/tasks/{id}/goals/{gid}", perm.Authenticated, s.editGoal) // goal management: edit a goal (revives the task)
|
|
|
|
|
s.handle(mux, "DELETE /api/tasks/{id}/goals/{gid}", perm.Authenticated, s.deleteGoal) // goal management: hard-delete a goal (no revival)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/constraints", perm.Authenticated, s.listConstraints) // constraint management: list this task's operation constraints
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/constraints", perm.Authenticated, s.addConstraint) // constraint management: add a constraint (planner not notified)
|
|
|
|
|
s.handle(mux, "PATCH /api/tasks/{id}/constraints/{cid}", perm.Authenticated, s.editConstraint) // constraint management: edit a constraint
|
|
|
|
|
s.handle(mux, "DELETE /api/tasks/{id}/constraints/{cid}", perm.Authenticated, s.deleteConstraint) // constraint management: delete a constraint
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/control", perm.Authenticated, s.control)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/retarget", perm.Authenticated, s.retargetTaskHandler)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/extend", perm.Authenticated, s.extendTaskHandler)
|
|
|
|
|
s.handle(mux, "PUT /api/tasks/{id}/llm", perm.Authenticated, s.updateTaskLLMProfiles)
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/llm/resolution", perm.Authenticated, s.taskLLMResolutionHandler)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/intents/{iid}/control", perm.Authenticated, s.controlIntent)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/intents/{iid}/messages", perm.Authenticated, s.sendWorkerMessage)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/intents/{iid}/rerun", perm.Authenticated, s.rerunIntent) // rerun one blocked/exhausted/stopped intent
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/intents/rerun-blocked", perm.Authenticated, s.rerunBlocked) // batch-rerun all blocked intents of this task
|
|
|
|
|
s.handle(mux, "POST /api/active", perm.Authenticated, s.setActive)
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("GET /api/llm", s.getLLM)
|
|
|
|
|
mux.HandleFunc("POST /api/llm", s.setLLM)
|
|
|
|
|
mux.HandleFunc("POST /api/llm/test", s.testLLM)
|
|
|
|
|
s.handle(mux, "GET /api/llm", perm.Authenticated, s.getLLM)
|
|
|
|
|
s.handle(mux, "POST /api/llm", perm.Authenticated, s.setLLM)
|
|
|
|
|
s.handle(mux, "POST /api/llm/test", perm.Authenticated, s.testLLM)
|
|
|
|
|
|
|
|
|
|
// asset system
|
|
|
|
|
mux.HandleFunc("GET /api/assets", s.listAssets)
|
|
|
|
|
mux.HandleFunc("GET /api/assets/counts", s.assetCounts)
|
|
|
|
|
mux.HandleFunc("POST /api/assets", s.insertAssets)
|
|
|
|
|
mux.HandleFunc("DELETE /api/assets", s.deleteAssets)
|
|
|
|
|
s.handle(mux, "GET /api/assets", perm.Authenticated, s.listAssets)
|
|
|
|
|
s.handle(mux, "GET /api/assets/counts", perm.Authenticated, s.assetCounts)
|
|
|
|
|
s.handle(mux, "POST /api/assets", perm.Authenticated, s.insertAssets)
|
|
|
|
|
s.handle(mux, "DELETE /api/assets", perm.Authenticated, s.deleteAssets)
|
|
|
|
|
|
|
|
|
|
// company system
|
|
|
|
|
mux.HandleFunc("GET /api/companies", s.listCompanies)
|
|
|
|
|
mux.HandleFunc("POST /api/companies", s.createCompany)
|
|
|
|
|
mux.HandleFunc("GET /api/companies/{id}", s.getCompany)
|
|
|
|
|
mux.HandleFunc("DELETE /api/companies/{id}", s.deleteCompany)
|
|
|
|
|
mux.HandleFunc("POST /api/companies/{id}/scope", s.addCompanyScope)
|
|
|
|
|
mux.HandleFunc("POST /api/companies/reattribute", s.reattribute)
|
|
|
|
|
s.handle(mux, "GET /api/companies", perm.Authenticated, s.listCompanies)
|
|
|
|
|
s.handle(mux, "POST /api/companies", perm.Authenticated, s.createCompany)
|
|
|
|
|
s.handle(mux, "GET /api/companies/{id}", perm.Authenticated, s.getCompany)
|
|
|
|
|
s.handle(mux, "DELETE /api/companies/{id}", perm.Authenticated, s.deleteCompany)
|
|
|
|
|
s.handle(mux, "POST /api/companies/{id}/scope", perm.Authenticated, s.addCompanyScope)
|
|
|
|
|
s.handle(mux, "POST /api/companies/reattribute", perm.Authenticated, s.reattribute)
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/frontier", s.frontier)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings", s.findings)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings/groups", s.findingGroups)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings/asset-tree", s.findingAssetTree)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings/stats", s.findingStats)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings/export", s.findingsExport)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/frontier", perm.Authenticated, s.frontier)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings", perm.Authenticated, s.findings)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings/groups", perm.Authenticated, s.findingGroups)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings/asset-tree", perm.Authenticated, s.findingAssetTree)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings/stats", perm.Authenticated, s.findingStats)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings/export", perm.Authenticated, s.findingsExport)
|
|
|
|
|
s.registerFindingTraffic(mux)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings/{id}", s.getFinding)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings/{id}/lineage", s.findingLineage)
|
|
|
|
|
mux.HandleFunc("POST /api/exploration/findings/{id}/deepen", s.deepenFinding)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings/{id}/retests", s.listFindingRetests)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/findings/retests/active", s.listActiveFindingRetests)
|
|
|
|
|
mux.HandleFunc("POST /api/exploration/findings/{id}/retests", s.startFindingRetest)
|
|
|
|
|
mux.HandleFunc("PATCH /api/exploration/findings/{id}", s.patchFinding)
|
|
|
|
|
mux.HandleFunc("POST /api/exploration/findings/bulk-status", s.bulkPatchFindingStatus)
|
|
|
|
|
mux.HandleFunc("POST /api/exploration/findings/bulk-report-state", s.bulkPatchFindingReportState)
|
|
|
|
|
mux.HandleFunc("DELETE /api/exploration/findings/{id}", s.deleteFinding)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/intents", s.intents)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/graph", s.explorationGraph)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/nodes", s.explorationNodes)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/activity", s.activity)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/activity/history", s.activityHistory)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/main-sessions", s.mainSessions)
|
|
|
|
|
mux.HandleFunc("POST /api/exploration/main-session/new", s.newMainSession)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/activity/stream", s.streamActivity)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/activity/{seq}", s.activityDetail)
|
|
|
|
|
mux.HandleFunc("GET /api/exploration/tokens", s.tokenStats)
|
|
|
|
|
mux.HandleFunc("GET /api/tokens/daily", s.tokenDailyStats)
|
|
|
|
|
mux.HandleFunc("GET /api/tokens/conversations", s.conversationTokens)
|
|
|
|
|
mux.HandleFunc("GET /api/tokens/usage", s.pgUsageStats) // global llm_usage aggregation (new dashboard view)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings/{id}", perm.Authenticated, s.getFinding)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings/{id}/lineage", perm.Authenticated, s.findingLineage)
|
|
|
|
|
s.handle(mux, "POST /api/exploration/findings/{id}/deepen", perm.Authenticated, s.deepenFinding)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings/{id}/retests", perm.Authenticated, s.listFindingRetests)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/findings/retests/active", perm.Authenticated, s.listActiveFindingRetests)
|
|
|
|
|
s.handle(mux, "POST /api/exploration/findings/{id}/retests", perm.Authenticated, s.startFindingRetest)
|
|
|
|
|
s.handle(mux, "PATCH /api/exploration/findings/{id}", perm.Authenticated, s.patchFinding)
|
|
|
|
|
s.handle(mux, "POST /api/exploration/findings/bulk-status", perm.Authenticated, s.bulkPatchFindingStatus)
|
|
|
|
|
s.handle(mux, "POST /api/exploration/findings/bulk-report-state", perm.Authenticated, s.bulkPatchFindingReportState)
|
|
|
|
|
s.handle(mux, "DELETE /api/exploration/findings/{id}", perm.Authenticated, s.deleteFinding)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/intents", perm.Authenticated, s.intents)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/graph", perm.Authenticated, s.explorationGraph)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/nodes", perm.Authenticated, s.explorationNodes)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/activity", perm.Authenticated, s.activity)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/activity/history", perm.Authenticated, s.activityHistory)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/main-sessions", perm.Authenticated, s.mainSessions)
|
|
|
|
|
s.handle(mux, "POST /api/exploration/main-session/new", perm.Authenticated, s.newMainSession)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/activity/stream", perm.Authenticated, s.streamActivity)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/activity/{seq}", perm.Authenticated, s.activityDetail)
|
|
|
|
|
s.handle(mux, "GET /api/exploration/tokens", perm.Authenticated, s.tokenStats)
|
|
|
|
|
s.handle(mux, "GET /api/tokens/daily", perm.Authenticated, s.tokenDailyStats)
|
|
|
|
|
s.handle(mux, "GET /api/tokens/conversations", perm.Authenticated, s.conversationTokens)
|
|
|
|
|
s.handle(mux, "GET /api/tokens/usage", perm.Authenticated, s.pgUsageStats) // global llm_usage aggregation (new dashboard view)
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("GET /api/audit", s.getAudit)
|
|
|
|
|
mux.HandleFunc("POST /api/gc", s.gc)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic", s.getTraffic)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic/hosts", s.getTrafficHosts)
|
|
|
|
|
mux.HandleFunc("DELETE /api/traffic", s.deleteTraffic)
|
|
|
|
|
mux.HandleFunc("DELETE /api/traffic/hosts", s.deleteTrafficHosts)
|
|
|
|
|
mux.HandleFunc("DELETE /api/traffic/all", s.deleteAllTraffic)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic/exchange", s.getTrafficExchange)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic/stream", s.getTrafficStream)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic/blob", s.getTrafficBlob)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/ingest", s.ingestTraffic)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/replay", s.replayTraffic)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/import/har", s.importTrafficHAR)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic/export/har", s.exportTrafficHAR)
|
|
|
|
|
mux.HandleFunc("GET /api/commands", s.pgListCommands)
|
|
|
|
|
mux.HandleFunc("GET /api/commands/stats", s.pgToolStats) // aggregate call counts per tool
|
|
|
|
|
mux.HandleFunc("GET /api/llm/records", s.pgListLLMRecords)
|
|
|
|
|
mux.HandleFunc("GET /api/llm/context/summary", s.pgLLMContextSummary)
|
|
|
|
|
mux.HandleFunc("DELETE /api/llm/records", s.pgDeleteLLMRecords)
|
|
|
|
|
mux.HandleFunc("GET /api/llm/records/tasks", s.pgLLMTasks)
|
|
|
|
|
mux.HandleFunc("GET /api/llm/records/by-model", s.pgTokenByModel) // aggregate this task's token usage by model
|
|
|
|
|
mux.HandleFunc("GET /api/llm/records/{id}", s.pgGetLLMRecord)
|
|
|
|
|
mux.HandleFunc("GET /api/settings", s.getSettings)
|
|
|
|
|
mux.HandleFunc("PUT /api/settings", s.putSettings)
|
|
|
|
|
mux.HandleFunc("GET /api/settings/noise", s.noiseStatus) // current noise profile + per-host counters (no reset)
|
|
|
|
|
s.handle(mux, "GET /api/audit", perm.Authenticated, s.getAudit)
|
|
|
|
|
s.handle(mux, "POST /api/gc", perm.Authenticated, s.gc)
|
|
|
|
|
s.handle(mux, "GET /api/traffic", perm.Authenticated, s.getTraffic)
|
|
|
|
|
s.handle(mux, "GET /api/traffic/hosts", perm.Authenticated, s.getTrafficHosts)
|
|
|
|
|
s.handle(mux, "DELETE /api/traffic", perm.Authenticated, s.deleteTraffic)
|
|
|
|
|
s.handle(mux, "DELETE /api/traffic/hosts", perm.Authenticated, s.deleteTrafficHosts)
|
|
|
|
|
s.handle(mux, "DELETE /api/traffic/all", perm.Authenticated, s.deleteAllTraffic)
|
|
|
|
|
s.handle(mux, "GET /api/traffic/exchange", perm.Authenticated, s.getTrafficExchange)
|
|
|
|
|
s.handle(mux, "GET /api/traffic/stream", perm.Authenticated, s.getTrafficStream)
|
|
|
|
|
s.handle(mux, "GET /api/traffic/blob", perm.Authenticated, s.getTrafficBlob)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/ingest", perm.Authenticated, s.ingestTraffic)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/replay", perm.Authenticated, s.replayTraffic)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/import/har", perm.Authenticated, s.importTrafficHAR)
|
|
|
|
|
s.handle(mux, "GET /api/traffic/export/har", perm.Authenticated, s.exportTrafficHAR)
|
|
|
|
|
s.handle(mux, "GET /api/commands", perm.Authenticated, s.pgListCommands)
|
|
|
|
|
s.handle(mux, "GET /api/commands/stats", perm.Authenticated, s.pgToolStats) // aggregate call counts per tool
|
|
|
|
|
s.handle(mux, "GET /api/llm/records", perm.Authenticated, s.pgListLLMRecords)
|
|
|
|
|
s.handle(mux, "GET /api/llm/context/summary", perm.Authenticated, s.pgLLMContextSummary)
|
|
|
|
|
s.handle(mux, "DELETE /api/llm/records", perm.Authenticated, s.pgDeleteLLMRecords)
|
|
|
|
|
s.handle(mux, "GET /api/llm/records/tasks", perm.Authenticated, s.pgLLMTasks)
|
|
|
|
|
s.handle(mux, "GET /api/llm/records/by-model", perm.Authenticated, s.pgTokenByModel) // aggregate this task's token usage by model
|
|
|
|
|
s.handle(mux, "GET /api/llm/records/{id}", perm.Authenticated, s.pgGetLLMRecord)
|
|
|
|
|
s.handle(mux, "GET /api/settings", perm.Authenticated, s.getSettings)
|
|
|
|
|
s.handle(mux, "PUT /api/settings", perm.Authenticated, s.putSettings)
|
|
|
|
|
s.handle(mux, "GET /api/settings/noise", perm.Authenticated, s.noiseStatus) // current noise profile + per-host counters (no reset)
|
|
|
|
|
// Vulnerability IM push. Channels are "multi-instance + per-instance filter rules" resources, so they get their own group of
|
|
|
|
|
// REST endpoints instead of being stuffed into the flat /api/settings key-value store.
|
|
|
|
|
mux.HandleFunc("GET /api/notify/meta", s.notifyMeta)
|
|
|
|
|
mux.HandleFunc("GET /api/notify/channels", s.notifyListChannels)
|
|
|
|
|
mux.HandleFunc("POST /api/notify/channels", s.notifyCreateChannel)
|
|
|
|
|
mux.HandleFunc("PATCH /api/notify/channels/{id}", s.notifyUpdateChannel)
|
|
|
|
|
mux.HandleFunc("DELETE /api/notify/channels/{id}", s.notifyDeleteChannel)
|
|
|
|
|
mux.HandleFunc("POST /api/notify/channels/{id}/test", s.notifyTestChannel)
|
|
|
|
|
mux.HandleFunc("GET /api/notify/deliveries", s.notifyListDeliveries)
|
|
|
|
|
mux.HandleFunc("POST /api/notify/deliveries/{id}/retry", s.notifyRetryDelivery)
|
|
|
|
|
s.handle(mux, "GET /api/notify/meta", perm.Authenticated, s.notifyMeta)
|
|
|
|
|
s.handle(mux, "GET /api/notify/channels", perm.Authenticated, s.notifyListChannels)
|
|
|
|
|
s.handle(mux, "POST /api/notify/channels", perm.Authenticated, s.notifyCreateChannel)
|
|
|
|
|
s.handle(mux, "PATCH /api/notify/channels/{id}", perm.Authenticated, s.notifyUpdateChannel)
|
|
|
|
|
s.handle(mux, "DELETE /api/notify/channels/{id}", perm.Authenticated, s.notifyDeleteChannel)
|
|
|
|
|
s.handle(mux, "POST /api/notify/channels/{id}/test", perm.Authenticated, s.notifyTestChannel)
|
|
|
|
|
s.handle(mux, "GET /api/notify/deliveries", perm.Authenticated, s.notifyListDeliveries)
|
|
|
|
|
s.handle(mux, "POST /api/notify/deliveries/{id}/retry", perm.Authenticated, s.notifyRetryDelivery)
|
|
|
|
|
// Inbound chat bridges, one per transport kind (telegram).
|
|
|
|
|
mux.HandleFunc("GET /api/chat-bridges", s.chatBridgeList)
|
|
|
|
|
mux.HandleFunc("PUT /api/chat-bridges/{kind}", s.chatBridgeSave)
|
|
|
|
|
mux.HandleFunc("POST /api/chat-bridges/{kind}/test", s.chatBridgeTest)
|
|
|
|
|
mux.HandleFunc("POST /api/settings/web-search/test", s.testWebSearch)
|
|
|
|
|
mux.HandleFunc("GET /api/report", s.getReport)
|
|
|
|
|
mux.HandleFunc("GET /api/chat/mentions", s.searchChatMentions)
|
|
|
|
|
mux.HandleFunc("POST /api/chat", s.chat)
|
|
|
|
|
mux.HandleFunc("POST /api/chat/upload", s.chatUpload) // upload method 1: files land in uploads/ under the conversation/task work dir
|
|
|
|
|
mux.HandleFunc("GET /api/tasks/{id}/chat/status", s.taskChatStatus)
|
|
|
|
|
mux.HandleFunc("POST /api/tasks/{id}/chat/stop", s.stopChat)
|
|
|
|
|
s.handle(mux, "GET /api/chat-bridges", perm.Authenticated, s.chatBridgeList)
|
|
|
|
|
s.handle(mux, "PUT /api/chat-bridges/{kind}", perm.Authenticated, s.chatBridgeSave)
|
|
|
|
|
s.handle(mux, "POST /api/chat-bridges/{kind}/test", perm.Authenticated, s.chatBridgeTest)
|
|
|
|
|
s.handle(mux, "POST /api/settings/web-search/test", perm.Authenticated, s.testWebSearch)
|
|
|
|
|
s.handle(mux, "GET /api/report", perm.Authenticated, s.getReport)
|
|
|
|
|
s.handle(mux, "GET /api/chat/mentions", perm.Authenticated, s.searchChatMentions)
|
|
|
|
|
s.handle(mux, "POST /api/chat", perm.Authenticated, s.chat)
|
|
|
|
|
s.handle(mux, "POST /api/chat/upload", perm.Authenticated, s.chatUpload) // upload method 1: files land in uploads/ under the conversation/task work dir
|
|
|
|
|
s.handle(mux, "GET /api/tasks/{id}/chat/status", perm.Authenticated, s.taskChatStatus)
|
|
|
|
|
s.handle(mux, "POST /api/tasks/{id}/chat/stop", perm.Authenticated, s.stopChat)
|
|
|
|
|
|
|
|
|
|
// --- Admin API (PostgreSQL data source; new database & admin console plan) ---
|
|
|
|
|
mux.HandleFunc("DELETE /api/tasks/{id}", s.pgDeleteTask)
|
|
|
|
|
s.handle(mux, "DELETE /api/tasks/{id}", perm.Authenticated, s.pgDeleteTask)
|
|
|
|
|
// Agents
|
|
|
|
|
// conversations (chat page)
|
|
|
|
|
mux.HandleFunc("GET /api/conversations", s.pgListConversations)
|
|
|
|
|
mux.HandleFunc("POST /api/conversations", s.pgCreateConversation)
|
|
|
|
|
mux.HandleFunc("POST /api/conversations/delete/batch", s.pgDeleteConversationsBatch)
|
|
|
|
|
mux.HandleFunc("PATCH /api/conversations/{id}", s.pgRenameConversation)
|
|
|
|
|
mux.HandleFunc("PATCH /api/conversations/{id}/profile", s.pgUpdateConversation)
|
|
|
|
|
mux.HandleFunc("DELETE /api/conversations/{id}", s.pgDeleteConversation)
|
|
|
|
|
mux.HandleFunc("GET /api/conversations/{id}/messages", s.pgConversationMessages)
|
|
|
|
|
mux.HandleFunc("POST /api/conversations/{id}/messages", s.pgSendConversationMessage)
|
|
|
|
|
mux.HandleFunc("POST /api/conversations/{id}/stop", s.pgStopConversation)
|
|
|
|
|
mux.HandleFunc("GET /api/conversations/{id}/messages/{seq}", s.pgConversationMsgDetail)
|
|
|
|
|
mux.HandleFunc("GET /api/conversations/{id}/target-pins", s.convListTargetPins)
|
|
|
|
|
mux.HandleFunc("POST /api/conversations/{id}/target-pins/{pid}/revoke", s.convRevokeTargetPin)
|
|
|
|
|
s.handle(mux, "GET /api/conversations", perm.Authenticated, s.pgListConversations)
|
|
|
|
|
s.handle(mux, "POST /api/conversations", perm.Authenticated, s.pgCreateConversation)
|
|
|
|
|
s.handle(mux, "POST /api/conversations/delete/batch", perm.Authenticated, s.pgDeleteConversationsBatch)
|
|
|
|
|
s.handle(mux, "PATCH /api/conversations/{id}", perm.Authenticated, s.pgRenameConversation)
|
|
|
|
|
s.handle(mux, "PATCH /api/conversations/{id}/profile", perm.Authenticated, s.pgUpdateConversation)
|
|
|
|
|
s.handle(mux, "DELETE /api/conversations/{id}", perm.Authenticated, s.pgDeleteConversation)
|
|
|
|
|
s.handle(mux, "GET /api/conversations/{id}/messages", perm.Authenticated, s.pgConversationMessages)
|
|
|
|
|
s.handle(mux, "POST /api/conversations/{id}/messages", perm.Authenticated, s.pgSendConversationMessage)
|
|
|
|
|
s.handle(mux, "POST /api/conversations/{id}/stop", perm.Authenticated, s.pgStopConversation)
|
|
|
|
|
s.handle(mux, "GET /api/conversations/{id}/messages/{seq}", perm.Authenticated, s.pgConversationMsgDetail)
|
|
|
|
|
s.handle(mux, "GET /api/conversations/{id}/target-pins", perm.Authenticated, s.convListTargetPins)
|
|
|
|
|
s.handle(mux, "POST /api/conversations/{id}/target-pins/{pid}/revoke", perm.Authenticated, s.convRevokeTargetPin)
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("GET /api/agents", s.pgListAgents)
|
|
|
|
|
mux.HandleFunc("POST /api/agents", s.pgCreateAgent)
|
|
|
|
|
mux.HandleFunc("GET /api/agents/{key}", s.pgGetAgent)
|
|
|
|
|
mux.HandleFunc("PATCH /api/agents/{key}", s.pgUpdateAgent)
|
|
|
|
|
mux.HandleFunc("DELETE /api/agents/{key}", s.pgDeleteAgent)
|
|
|
|
|
mux.HandleFunc("PUT /api/agents/{key}/config", s.pgSaveAgentConfig)
|
|
|
|
|
mux.HandleFunc("PUT /api/agents/{key}/prompt", s.pgSavePrompt)
|
|
|
|
|
mux.HandleFunc("POST /api/agents/{key}/prompt/reset", s.pgResetPrompt)
|
|
|
|
|
mux.HandleFunc("PUT /api/agents/{key}/wrapup", s.pgSaveWrapup)
|
|
|
|
|
mux.HandleFunc("POST /api/agents/{key}/wrapup/reset", s.pgResetWrapup)
|
|
|
|
|
mux.HandleFunc("PUT /api/agents/{key}/wrapup/task-timeout", s.pgSaveTaskTimeoutWrapup)
|
|
|
|
|
mux.HandleFunc("POST /api/agents/{key}/wrapup/task-timeout/reset", s.pgResetTaskTimeoutWrapup)
|
|
|
|
|
mux.HandleFunc("GET /api/agents/{key}/triggers", s.pgListTriggers)
|
|
|
|
|
mux.HandleFunc("POST /api/agents/{key}/triggers", s.pgCreateTrigger)
|
|
|
|
|
mux.HandleFunc("PATCH /api/triggers/{id}", s.pgUpdateTrigger)
|
|
|
|
|
mux.HandleFunc("DELETE /api/triggers/{id}", s.pgDeleteTrigger)
|
|
|
|
|
mux.HandleFunc("GET /api/agents/{key}/prompts", s.pgListPromptVersions)
|
|
|
|
|
mux.HandleFunc("GET /api/agents/{key}/variables", s.pgPromptVars)
|
|
|
|
|
mux.HandleFunc("POST /api/agents/{key}/prompt/preview", s.pgPreviewPrompt)
|
|
|
|
|
mux.HandleFunc("GET /api/agents/{key}/visibility", s.pgGetAgentVisibility)
|
|
|
|
|
mux.HandleFunc("PUT /api/agents/{key}/visibility", s.pgSetAgentVisibility)
|
|
|
|
|
s.handle(mux, "GET /api/agents", perm.Authenticated, s.pgListAgents)
|
|
|
|
|
s.handle(mux, "POST /api/agents", perm.Authenticated, s.pgCreateAgent)
|
|
|
|
|
s.handle(mux, "GET /api/agents/{key}", perm.Authenticated, s.pgGetAgent)
|
|
|
|
|
s.handle(mux, "PATCH /api/agents/{key}", perm.Authenticated, s.pgUpdateAgent)
|
|
|
|
|
s.handle(mux, "DELETE /api/agents/{key}", perm.Authenticated, s.pgDeleteAgent)
|
|
|
|
|
s.handle(mux, "PUT /api/agents/{key}/config", perm.Authenticated, s.pgSaveAgentConfig)
|
|
|
|
|
s.handle(mux, "PUT /api/agents/{key}/prompt", perm.Authenticated, s.pgSavePrompt)
|
|
|
|
|
s.handle(mux, "POST /api/agents/{key}/prompt/reset", perm.Authenticated, s.pgResetPrompt)
|
|
|
|
|
s.handle(mux, "PUT /api/agents/{key}/wrapup", perm.Authenticated, s.pgSaveWrapup)
|
|
|
|
|
s.handle(mux, "POST /api/agents/{key}/wrapup/reset", perm.Authenticated, s.pgResetWrapup)
|
|
|
|
|
s.handle(mux, "PUT /api/agents/{key}/wrapup/task-timeout", perm.Authenticated, s.pgSaveTaskTimeoutWrapup)
|
|
|
|
|
s.handle(mux, "POST /api/agents/{key}/wrapup/task-timeout/reset", perm.Authenticated, s.pgResetTaskTimeoutWrapup)
|
|
|
|
|
s.handle(mux, "GET /api/agents/{key}/triggers", perm.Authenticated, s.pgListTriggers)
|
|
|
|
|
s.handle(mux, "POST /api/agents/{key}/triggers", perm.Authenticated, s.pgCreateTrigger)
|
|
|
|
|
s.handle(mux, "PATCH /api/triggers/{id}", perm.Authenticated, s.pgUpdateTrigger)
|
|
|
|
|
s.handle(mux, "DELETE /api/triggers/{id}", perm.Authenticated, s.pgDeleteTrigger)
|
|
|
|
|
s.handle(mux, "GET /api/agents/{key}/prompts", perm.Authenticated, s.pgListPromptVersions)
|
|
|
|
|
s.handle(mux, "GET /api/agents/{key}/variables", perm.Authenticated, s.pgPromptVars)
|
|
|
|
|
s.handle(mux, "POST /api/agents/{key}/prompt/preview", perm.Authenticated, s.pgPreviewPrompt)
|
|
|
|
|
s.handle(mux, "GET /api/agents/{key}/visibility", perm.Authenticated, s.pgGetAgentVisibility)
|
|
|
|
|
s.handle(mux, "PUT /api/agents/{key}/visibility", perm.Authenticated, s.pgSetAgentVisibility)
|
|
|
|
|
// built-in tool catalog (description/param defaults editable, bound per agent; key and handler live in code)
|
|
|
|
|
mux.HandleFunc("GET /api/tools", s.pgListTools)
|
|
|
|
|
mux.HandleFunc("PUT /api/tools/{key}", s.pgUpdateTool)
|
|
|
|
|
mux.HandleFunc("POST /api/tools/custom", s.pgCreateCustomTool)
|
|
|
|
|
mux.HandleFunc("POST /api/tools/custom/test", s.pgTestCustomTool)
|
|
|
|
|
mux.HandleFunc("PUT /api/tools/custom/{key}", s.pgUpdateCustomTool)
|
|
|
|
|
mux.HandleFunc("DELETE /api/tools/custom/{key}", s.pgDeleteCustomTool)
|
|
|
|
|
mux.HandleFunc("POST /api/settings/python/detect", s.pgDetectPython)
|
|
|
|
|
mux.HandleFunc("POST /api/tools/{key}/reset", s.pgResetTool)
|
|
|
|
|
s.handle(mux, "GET /api/tools", perm.Authenticated, s.pgListTools)
|
|
|
|
|
s.handle(mux, "PUT /api/tools/{key}", perm.Authenticated, s.pgUpdateTool)
|
|
|
|
|
s.handle(mux, "POST /api/tools/custom", perm.Authenticated, s.pgCreateCustomTool)
|
|
|
|
|
s.handle(mux, "POST /api/tools/custom/test", perm.Authenticated, s.pgTestCustomTool)
|
|
|
|
|
s.handle(mux, "PUT /api/tools/custom/{key}", perm.Authenticated, s.pgUpdateCustomTool)
|
|
|
|
|
s.handle(mux, "DELETE /api/tools/custom/{key}", perm.Authenticated, s.pgDeleteCustomTool)
|
|
|
|
|
s.handle(mux, "POST /api/settings/python/detect", perm.Authenticated, s.pgDetectPython)
|
|
|
|
|
s.handle(mux, "POST /api/tools/{key}/reset", perm.Authenticated, s.pgResetTool)
|
|
|
|
|
// MCP CRUD
|
|
|
|
|
mux.HandleFunc("GET /api/mcp", s.pgListMCP)
|
|
|
|
|
mux.HandleFunc("POST /api/mcp", s.pgSaveMCP)
|
|
|
|
|
mux.HandleFunc("DELETE /api/mcp/{id}", s.pgDeleteMCP)
|
|
|
|
|
mux.HandleFunc("GET /api/mcp/{id}/tools", s.pgMCPTools)
|
|
|
|
|
mux.HandleFunc("POST /api/mcp/{id}/refresh", s.pgRefreshMCP)
|
|
|
|
|
s.handle(mux, "GET /api/mcp", perm.Authenticated, s.pgListMCP)
|
|
|
|
|
s.handle(mux, "POST /api/mcp", perm.Authenticated, s.pgSaveMCP)
|
|
|
|
|
s.handle(mux, "DELETE /api/mcp/{id}", perm.Authenticated, s.pgDeleteMCP)
|
|
|
|
|
s.handle(mux, "GET /api/mcp/{id}/tools", perm.Authenticated, s.pgMCPTools)
|
|
|
|
|
s.handle(mux, "POST /api/mcp/{id}/refresh", perm.Authenticated, s.pgRefreshMCP)
|
|
|
|
|
// asset sync — ScopeSentry data source
|
|
|
|
|
mux.HandleFunc("GET /api/sync/scopesentry/status", s.syncSSStatus)
|
|
|
|
|
mux.HandleFunc("POST /api/sync/scopesentry/datasource", s.syncSSDatasource)
|
|
|
|
|
mux.HandleFunc("GET /api/sync/scopesentry/projects", s.syncSSProjects)
|
|
|
|
|
mux.HandleFunc("GET /api/sync/scopesentry/tasks", s.syncSSTasks)
|
|
|
|
|
mux.HandleFunc("POST /api/sync/scopesentry/sync", s.syncSSRun)
|
|
|
|
|
s.handle(mux, "GET /api/sync/scopesentry/status", perm.Authenticated, s.syncSSStatus)
|
|
|
|
|
s.handle(mux, "POST /api/sync/scopesentry/datasource", perm.Authenticated, s.syncSSDatasource)
|
|
|
|
|
s.handle(mux, "GET /api/sync/scopesentry/projects", perm.Authenticated, s.syncSSProjects)
|
|
|
|
|
s.handle(mux, "GET /api/sync/scopesentry/tasks", perm.Authenticated, s.syncSSTasks)
|
|
|
|
|
s.handle(mux, "POST /api/sync/scopesentry/sync", perm.Authenticated, s.syncSSRun)
|
|
|
|
|
// Skill CRUD (filesystem)
|
|
|
|
|
mux.HandleFunc("GET /api/skills", s.fsListSkills)
|
|
|
|
|
mux.HandleFunc("POST /api/skills", s.fsCreateSkill)
|
|
|
|
|
mux.HandleFunc("POST /api/skills/upload", s.fsUploadSkill)
|
|
|
|
|
mux.HandleFunc("DELETE /api/skills/{name}", s.fsDeleteSkill)
|
|
|
|
|
mux.HandleFunc("GET /api/skills/missing", s.fsMissingSkills) // names of skills that were invoked but do not exist
|
|
|
|
|
mux.HandleFunc("GET /api/skills/{name}/usage", s.fsSkillUsage) // recent invocations of one skill
|
|
|
|
|
mux.HandleFunc("PUT /api/skills/{name}/meta", s.fsUpdateSkillMeta)
|
|
|
|
|
mux.HandleFunc("POST /api/skills/{name}/dirs", s.fsCreateDir)
|
|
|
|
|
mux.HandleFunc("GET /api/skills/{name}/files", s.fsListFiles)
|
|
|
|
|
s.handle(mux, "GET /api/skills", perm.Authenticated, s.fsListSkills)
|
|
|
|
|
s.handle(mux, "POST /api/skills", perm.Authenticated, s.fsCreateSkill)
|
|
|
|
|
s.handle(mux, "POST /api/skills/upload", perm.Authenticated, s.fsUploadSkill)
|
|
|
|
|
s.handle(mux, "DELETE /api/skills/{name}", perm.Authenticated, s.fsDeleteSkill)
|
|
|
|
|
s.handle(mux, "GET /api/skills/missing", perm.Authenticated, s.fsMissingSkills) // names of skills that were invoked but do not exist
|
|
|
|
|
s.handle(mux, "GET /api/skills/{name}/usage", perm.Authenticated, s.fsSkillUsage) // recent invocations of one skill
|
|
|
|
|
s.handle(mux, "PUT /api/skills/{name}/meta", perm.Authenticated, s.fsUpdateSkillMeta)
|
|
|
|
|
s.handle(mux, "POST /api/skills/{name}/dirs", perm.Authenticated, s.fsCreateDir)
|
|
|
|
|
s.handle(mux, "GET /api/skills/{name}/files", perm.Authenticated, s.fsListFiles)
|
|
|
|
|
// {file...} captures path segments including slashes (e.g. scripts/extract.py)
|
|
|
|
|
mux.HandleFunc("GET /api/skills/{name}/files/{file...}", s.fsReadFile)
|
|
|
|
|
mux.HandleFunc("PUT /api/skills/{name}/files/{file...}", s.fsWriteFile)
|
|
|
|
|
mux.HandleFunc("DELETE /api/skills/{name}/files/{file...}", s.fsDeletePath)
|
|
|
|
|
s.handle(mux, "GET /api/skills/{name}/files/{file...}", perm.Authenticated, s.fsReadFile)
|
|
|
|
|
s.handle(mux, "PUT /api/skills/{name}/files/{file...}", perm.Authenticated, s.fsWriteFile)
|
|
|
|
|
s.handle(mux, "DELETE /api/skills/{name}/files/{file...}", perm.Authenticated, s.fsDeletePath)
|
|
|
|
|
// MCP resource-side visibility (more specific skill routes match first)
|
|
|
|
|
mux.HandleFunc("GET /api/visibility/{kind}/{id}", s.pgResourceVisibility)
|
|
|
|
|
mux.HandleFunc("POST /api/visibility/toggle", s.pgToggleVisibility)
|
|
|
|
|
s.handle(mux, "GET /api/visibility/{kind}/{id}", perm.Authenticated, s.pgResourceVisibility)
|
|
|
|
|
s.handle(mux, "POST /api/visibility/toggle", perm.Authenticated, s.pgToggleVisibility)
|
|
|
|
|
// Skill visibility (by name, more specific, takes priority over the wildcard routes above)
|
|
|
|
|
mux.HandleFunc("GET /api/visibility/skill/{name}", s.pgSkillVisibility)
|
|
|
|
|
mux.HandleFunc("POST /api/visibility/skill/toggle", s.pgToggleSkillVisibility)
|
|
|
|
|
s.handle(mux, "GET /api/visibility/skill/{name}", perm.Authenticated, s.pgSkillVisibility)
|
|
|
|
|
s.handle(mux, "POST /api/visibility/skill/toggle", perm.Authenticated, s.pgToggleSkillVisibility)
|
|
|
|
|
// LLM multi-profile
|
|
|
|
|
mux.HandleFunc("GET /api/llm/profiles", s.pgListProfiles)
|
|
|
|
|
mux.HandleFunc("POST /api/llm/profiles", s.pgSaveProfile)
|
|
|
|
|
mux.HandleFunc("DELETE /api/llm/profiles/{id}", s.pgDeleteProfile)
|
|
|
|
|
mux.HandleFunc("POST /api/llm/profiles/active", s.pgActivateProfile)
|
|
|
|
|
mux.HandleFunc("GET /api/llm/retry-policy", s.pgGetLLMRetryPolicy)
|
|
|
|
|
mux.HandleFunc("POST /api/llm/retry-policy", s.pgSaveLLMRetryPolicy)
|
|
|
|
|
mux.HandleFunc("GET /api/llm/pool", s.pgLLMPoolStatus)
|
|
|
|
|
mux.HandleFunc("POST /api/llm/pool/reset", s.pgLLMPoolReset)
|
|
|
|
|
mux.HandleFunc("POST /api/llm/models", s.pgListModels)
|
|
|
|
|
s.handle(mux, "GET /api/llm/profiles", perm.Authenticated, s.pgListProfiles)
|
|
|
|
|
s.handle(mux, "POST /api/llm/profiles", perm.Authenticated, s.pgSaveProfile)
|
|
|
|
|
s.handle(mux, "DELETE /api/llm/profiles/{id}", perm.Authenticated, s.pgDeleteProfile)
|
|
|
|
|
s.handle(mux, "POST /api/llm/profiles/active", perm.Authenticated, s.pgActivateProfile)
|
|
|
|
|
s.handle(mux, "GET /api/llm/retry-policy", perm.Authenticated, s.pgGetLLMRetryPolicy)
|
|
|
|
|
s.handle(mux, "POST /api/llm/retry-policy", perm.Authenticated, s.pgSaveLLMRetryPolicy)
|
|
|
|
|
s.handle(mux, "GET /api/llm/pool", perm.Authenticated, s.pgLLMPoolStatus)
|
|
|
|
|
s.handle(mux, "POST /api/llm/pool/reset", perm.Authenticated, s.pgLLMPoolReset)
|
|
|
|
|
s.handle(mux, "POST /api/llm/models", perm.Authenticated, s.pgListModels)
|
|
|
|
|
|
|
|
|
|
// interception rule management
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/rules", s.interceptListRules)
|
|
|
|
|
mux.HandleFunc("POST /api/intercept/rules", s.interceptCreateRule)
|
|
|
|
|
mux.HandleFunc("PUT /api/intercept/rules/{id}", s.interceptUpdateRule)
|
|
|
|
|
mux.HandleFunc("DELETE /api/intercept/rules/{id}", s.interceptDeleteRule)
|
|
|
|
|
mux.HandleFunc("POST /api/intercept/rules/{id}/toggle", s.interceptToggleRule)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/rules", perm.Authenticated, s.interceptListRules)
|
|
|
|
|
s.handle(mux, "POST /api/intercept/rules", perm.Authenticated, s.interceptCreateRule)
|
|
|
|
|
s.handle(mux, "PUT /api/intercept/rules/{id}", perm.Authenticated, s.interceptUpdateRule)
|
|
|
|
|
s.handle(mux, "DELETE /api/intercept/rules/{id}", perm.Authenticated, s.interceptDeleteRule)
|
|
|
|
|
s.handle(mux, "POST /api/intercept/rules/{id}/toggle", perm.Authenticated, s.interceptToggleRule)
|
|
|
|
|
|
|
|
|
|
// capture-proxy rewrite rule management (stored and compiled; not applied by the proxy yet)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic/rewrite-rules", s.rewriteListRules)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/rewrite-rules", s.rewriteCreateRule)
|
|
|
|
|
mux.HandleFunc("PUT /api/traffic/rewrite-rules/{id}", s.rewriteUpdateRule)
|
|
|
|
|
mux.HandleFunc("DELETE /api/traffic/rewrite-rules/{id}", s.rewriteDeleteRule)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/rewrite-rules/{id}/toggle", s.rewriteToggleRule)
|
|
|
|
|
s.handle(mux, "GET /api/traffic/rewrite-rules", perm.Authenticated, s.rewriteListRules)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/rewrite-rules", perm.Authenticated, s.rewriteCreateRule)
|
|
|
|
|
s.handle(mux, "PUT /api/traffic/rewrite-rules/{id}", perm.Authenticated, s.rewriteUpdateRule)
|
|
|
|
|
s.handle(mux, "DELETE /api/traffic/rewrite-rules/{id}", perm.Authenticated, s.rewriteDeleteRule)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/rewrite-rules/{id}/toggle", perm.Authenticated, s.rewriteToggleRule)
|
|
|
|
|
|
|
|
|
|
// capture-proxy constrained Go tampering hooks (P4.2, operator-only, opt-in via ARTEX_TAMPER_HOOKS_ENABLED)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic/hooks", s.tamperListHooks)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/hooks", s.tamperCreateHook)
|
|
|
|
|
mux.HandleFunc("PUT /api/traffic/hooks/{id}", s.tamperUpdateHook)
|
|
|
|
|
mux.HandleFunc("DELETE /api/traffic/hooks/{id}", s.tamperDeleteHook)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/hooks/{id}/toggle", s.tamperToggleHook)
|
|
|
|
|
mux.HandleFunc("GET /api/traffic/hooks/{id}/versions", s.tamperListHookVersions)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/hooks/{id}/rollback", s.tamperRollbackHook)
|
|
|
|
|
mux.HandleFunc("POST /api/traffic/hooks/dry-run", s.tamperDryRunHook)
|
|
|
|
|
s.handle(mux, "GET /api/traffic/hooks", perm.Authenticated, s.tamperListHooks)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/hooks", perm.Authenticated, s.tamperCreateHook)
|
|
|
|
|
s.handle(mux, "PUT /api/traffic/hooks/{id}", perm.Authenticated, s.tamperUpdateHook)
|
|
|
|
|
s.handle(mux, "DELETE /api/traffic/hooks/{id}", perm.Authenticated, s.tamperDeleteHook)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/hooks/{id}/toggle", perm.Authenticated, s.tamperToggleHook)
|
|
|
|
|
s.handle(mux, "GET /api/traffic/hooks/{id}/versions", perm.Authenticated, s.tamperListHookVersions)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/hooks/{id}/rollback", perm.Authenticated, s.tamperRollbackHook)
|
|
|
|
|
s.handle(mux, "POST /api/traffic/hooks/dry-run", perm.Authenticated, s.tamperDryRunHook)
|
|
|
|
|
|
|
|
|
|
// asset interception rule management (global blocklist: domains/IPs/URLs/CIDRs)
|
|
|
|
|
mux.HandleFunc("GET /api/asset-intercept/rules", s.assetInterceptListRules)
|
|
|
|
|
mux.HandleFunc("POST /api/asset-intercept/rules", s.assetInterceptCreateRule)
|
|
|
|
|
mux.HandleFunc("PUT /api/asset-intercept/rules/{id}", s.assetInterceptUpdateRule)
|
|
|
|
|
mux.HandleFunc("DELETE /api/asset-intercept/rules/{id}", s.assetInterceptDeleteRule)
|
|
|
|
|
mux.HandleFunc("POST /api/asset-intercept/rules/{id}/toggle", s.assetInterceptToggleRule)
|
|
|
|
|
s.handle(mux, "GET /api/asset-intercept/rules", perm.Authenticated, s.assetInterceptListRules)
|
|
|
|
|
s.handle(mux, "POST /api/asset-intercept/rules", perm.Authenticated, s.assetInterceptCreateRule)
|
|
|
|
|
s.handle(mux, "PUT /api/asset-intercept/rules/{id}", perm.Authenticated, s.assetInterceptUpdateRule)
|
|
|
|
|
s.handle(mux, "DELETE /api/asset-intercept/rules/{id}", perm.Authenticated, s.assetInterceptDeleteRule)
|
|
|
|
|
s.handle(mux, "POST /api/asset-intercept/rules/{id}/toggle", perm.Authenticated, s.assetInterceptToggleRule)
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/pending", s.interceptListPending)
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/pending/{id}", s.interceptGetOne)
|
|
|
|
|
mux.HandleFunc("POST /api/intercept/pending/{id}/decide", s.interceptDecide)
|
|
|
|
|
mux.HandleFunc("POST /api/intercept/pending/batch-decide", s.interceptBatchDecide)
|
|
|
|
|
mux.HandleFunc("POST /api/intercept/pending/{id}/always-allow", s.interceptAlwaysAllow) // creates an argv allow rule; the request stays pending
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/history", s.interceptHistory)
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/history/{id}", s.interceptDetail)
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/history/{id}/execution", s.interceptExecution)
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/task/{taskID}", s.interceptListTaskItems)
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/task/{taskID}/pending-summary", s.interceptTaskPendingSummary)
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/tool-config", s.interceptGetToolConfig)
|
|
|
|
|
mux.HandleFunc("PUT /api/intercept/tool-config", s.interceptSetToolConfig)
|
|
|
|
|
mux.HandleFunc("GET /api/target-gate/exemptions", s.targetGateGetExemptions)
|
|
|
|
|
mux.HandleFunc("PUT /api/target-gate/exemptions", s.targetGateSetExemptions)
|
|
|
|
|
mux.HandleFunc("GET /api/target-gate/exemptions/history", s.targetGateExemptionHistory)
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/judge", s.interceptGetJudgeConfig)
|
|
|
|
|
mux.HandleFunc("PUT /api/intercept/judge", s.interceptSetJudgeConfig)
|
|
|
|
|
mux.HandleFunc("GET /api/intercept/judge/usage", s.interceptJudgeUsage) // cumulative token usage of fallback approval
|
|
|
|
|
s.handle(mux, "GET /api/intercept/pending", perm.Authenticated, s.interceptListPending)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/pending/{id}", perm.Authenticated, s.interceptGetOne)
|
|
|
|
|
s.handle(mux, "POST /api/intercept/pending/{id}/decide", perm.Authenticated, s.interceptDecide)
|
|
|
|
|
s.handle(mux, "POST /api/intercept/pending/batch-decide", perm.Authenticated, s.interceptBatchDecide)
|
|
|
|
|
s.handle(mux, "POST /api/intercept/pending/{id}/always-allow", perm.Authenticated, s.interceptAlwaysAllow) // creates an argv allow rule; the request stays pending
|
|
|
|
|
s.handle(mux, "GET /api/intercept/history", perm.Authenticated, s.interceptHistory)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/history/{id}", perm.Authenticated, s.interceptDetail)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/history/{id}/execution", perm.Authenticated, s.interceptExecution)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/task/{taskID}", perm.Authenticated, s.interceptListTaskItems)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/task/{taskID}/pending-summary", perm.Authenticated, s.interceptTaskPendingSummary)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/tool-config", perm.Authenticated, s.interceptGetToolConfig)
|
|
|
|
|
s.handle(mux, "PUT /api/intercept/tool-config", perm.Authenticated, s.interceptSetToolConfig)
|
|
|
|
|
s.handle(mux, "GET /api/target-gate/exemptions", perm.Authenticated, s.targetGateGetExemptions)
|
|
|
|
|
s.handle(mux, "PUT /api/target-gate/exemptions", perm.Authenticated, s.targetGateSetExemptions)
|
|
|
|
|
s.handle(mux, "GET /api/target-gate/exemptions/history", perm.Authenticated, s.targetGateExemptionHistory)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/judge", perm.Authenticated, s.interceptGetJudgeConfig)
|
|
|
|
|
s.handle(mux, "PUT /api/intercept/judge", perm.Authenticated, s.interceptSetJudgeConfig)
|
|
|
|
|
s.handle(mux, "GET /api/intercept/judge/usage", perm.Authenticated, s.interceptJudgeUsage) // cumulative token usage of fallback approval
|
|
|
|
|
|
|
|
|
|
// /api/* goes through CORS + JWT; everything else is served by the embedded
|
|
|
|
|
// frontend (public — auth is enforced client-side and on the API). With the
|
|
|
|
|
return mux
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Server) Handler() http.Handler {
|
|
|
|
|
return s.handlerFor(s.apiRoutes())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// handlerFor builds the production handler around an API mux. Handler uses
|
|
|
|
|
// it with the real route table; tests use it with their own routes, so they
|
|
|
|
|
// exercise the same chain.
|
|
|
|
|
func (s *Server) handlerFor(mux *apiMux) http.Handler {
|
|
|
|
|
// /api/* goes through CORS, JWT and the route permission check (routes.go);
|
|
|
|
|
// everything else is served by the embedded frontend (public — auth is
|
|
|
|
|
// enforced client-side and on the API). With the
|
|
|
|
|
// no-embed build the webui handler just 404s (run `next dev` separately).
|
|
|
|
|
api := cors(s.requireAuth(mux))
|
|
|
|
|
api := cors(s.requireAuth(s.requirePerm(mux)))
|
|
|
|
|
root := http.NewServeMux()
|
|
|
|
|
root.Handle("/api/", api)
|
|
|
|
|
webui := s.webuiHandler()
|
|
|
|
|