Files
jiangchang-platform-kit/sdk/jiangchang_skill_core/guard.py
chendelian 117d31298e feat: add jiangchang platform kit skeleton
Add a shared SDK scaffold for entitlement checks and a reusable Gitea release workflow template to standardize skill packaging and publishing across projects.
2026-03-30 18:49:29 +08:00

23 lines
634 B
Python

from .client import EntitlementClient
from .errors import EntitlementDeniedError
from .models import EntitlementResult
def enforce_entitlement(
user_id: str,
skill_slug: str,
trace_id: str = "",
context: dict | None = None,
client: EntitlementClient | None = None,
) -> EntitlementResult:
c = client or EntitlementClient()
result = c.check_entitlement(
user_id=user_id,
skill_slug=skill_slug,
trace_id=trace_id,
context=context or {},
)
if not result.allow:
raise EntitlementDeniedError(result.reason or "skill not purchased or expired")
return result