-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpremium_contract.py
More file actions
80 lines (65 loc) · 2.25 KB
/
premium_contract.py
File metadata and controls
80 lines (65 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""Public contract for separate premium extension repositories.
This module is safe to publish. It defines the stable registration surface
that a private premium repo can target without living inside the OSS core.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any, Protocol, TypedDict
PREMIUM_RUNTIME_CONTRACT_VERSION = "1.1"
@dataclass(slots=True)
class PremiumMountContext:
"""Context passed from OSS core into a private premium extension."""
contract_version: str
server_name: str
feature_id: str
machine_id: str
host_runtime_version: str = ""
installation_fingerprint: str = ""
manifest_id: str = ""
protection_phase: int = 1
config: dict[str, Any] = field(default_factory=dict)
class PremiumRegistrationResult(TypedDict, total=False):
"""Structured result returned by premium registration hooks."""
mounted: bool
contract_version: str
extension_name: str
host_runtime_version: str
installation_fingerprint: str
manifest_id: str
protection_phase: int
packs: list[str]
features: list[str]
selection_mode: str
notes: str
class PremiumExtensionRegistrar(Protocol):
"""Callable signature for a private premium registration hook."""
def __call__(
self,
mcp: Any,
*,
server_name: str | None = None,
mount_context: PremiumMountContext | None = None,
) -> PremiumRegistrationResult | dict[str, Any] | None: ...
def build_mount_context(
*,
server_name: str,
feature_id: str,
machine_id: str,
host_runtime_version: str = "",
installation_fingerprint: str = "",
manifest_id: str = "",
protection_phase: int = 1,
config: dict[str, Any] | None = None,
) -> PremiumMountContext:
"""Build a standard context object for private premium extensions."""
return PremiumMountContext(
contract_version=PREMIUM_RUNTIME_CONTRACT_VERSION,
server_name=server_name,
feature_id=feature_id,
machine_id=machine_id,
host_runtime_version=host_runtime_version,
installation_fingerprint=installation_fingerprint,
manifest_id=manifest_id,
protection_phase=protection_phase,
config=dict(config or {}),
)