feat(agent): 技能用量 - 按用户运行日志统计检索与读取 (#590)

This commit is contained in:
itsWyatt-K
2026-09-23 16:22:44 +08:00
committed by ddCat
parent 841e5e5109
commit 1eed747cb3
8 changed files with 514 additions and 1 deletions

View File

@@ -24,6 +24,21 @@ func RegisterAgentRoutes(r *gin.RouterGroup, svc *service.Service) {
capabilities := service.CloudAgentCapabilitySetInfo()
ok(c, gin.H{"version": 2, "permissionModes": []string{"read_only", "request_approval", "auto"}, "contextScopes": []string{"canvas"}, "skills": true, "writeTools": true, "billing": "fixed_request", "maxHistoryPairs": 10, "maxHistoryBytes": 64000, "maxSteps": 0, "tools": service.CloudAgentSupportedToolNames(), "capabilitySetVersion": capabilities.Version, "capabilitySetHash": capabilities.Hash, "nodeTypes": capabilities.Nodes})
})
// Skill usage is derived from the caller's own journal receipts, so it stays
// read-only and never exposes another user's runs.
r.GET("/agent/skills/usage", func(c *gin.Context) {
user, err := currentUser(c, svc)
if err != nil {
failService(c, err)
return
}
view, err := svc.CloudAgentSkillUsage(user.ID)
if err != nil {
failService(c, err)
return
}
ok(c, view)
})
// Profiles are durable preference data, not an authorization surface. The
// service validates scope ownership and the compiler injects the effective
// layers only after the code-level policy has been fixed.