Add a shared SDK scaffold for entitlement checks and a reusable Gitea release workflow template to standardize skill packaging and publishing across projects.
23 lines
634 B
Python
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
|