fix(quota): exclude agents from quota rules and usage records (#325)

* fix(quota): exclude agents from quota rules and usage records

* refactor(quota): remove agent_skill_call_count resource type and related logic

* chore(db): replace manual migration with prisma-generated migration
This commit is contained in:
Yiling-J
2026-08-18 11:56:03 +08:00
committed by GitHub
parent f806272c06
commit 8a75d015a1
22 changed files with 127 additions and 318 deletions
-25
View File
@@ -3,7 +3,6 @@ import { Type } from 'typebox'
import { type AgentTool } from '@earendil-works/pi-agent-core'
import { agentService } from '@shumai/core/src/agent/agent'
import { resolveEffectiveRole } from '@shumai/core/src/authz/authz'
import { quotaService } from '@shumai/core/src/quota/quota-service'
const readSkillSchema = Type.Object({
skillId: Type.String({ description: 'The ID of the skill to read' }),
@@ -61,18 +60,6 @@ export const createReadSkillTool = (
)
}
// Quota pre-check
await quotaService.checkQuota(
{
teamId: skill.teamId,
userId,
role: effectiveRole,
resource: 'agent_skill_call_count',
resourceData: { id: params.skillId, skillId: params.skillId },
},
1,
)
// Capture environment variables using agentService
const envs = await agentService.getSkillEnvs(params.skillId)
onEnvsAdded(envs)
@@ -83,18 +70,6 @@ export const createReadSkillTool = (
// Notify that a skill was successfully loaded (e.g. to enable restricted tools)
await onSkillLoaded?.()
// Consume quota
await quotaService.consumeQuota(
{
teamId: skill.teamId,
userId,
role: effectiveRole,
resource: 'agent_skill_call_count',
resourceData: { id: params.skillId, skillId: params.skillId },
},
1,
)
return {
content: [{ type: 'text', text: skillMdContent }],
details: { skillId: params.skillId },