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.
This commit is contained in:
22
sdk/jiangchang_skill_core/guard.py
Normal file
22
sdk/jiangchang_skill_core/guard.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
Reference in New Issue
Block a user