piphi-runtime-kit-python 0.8.1__py3-none-any.whl → 0.10.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- piphi_runtime_kit_python/__init__.py +47 -0
- piphi_runtime_kit_python/camera.py +237 -0
- piphi_runtime_kit_python/onboarding.py +34 -0
- piphi_runtime_kit_python/runtime/network.py +33 -0
- {piphi_runtime_kit_python-0.8.1.dist-info → piphi_runtime_kit_python-0.10.1.dist-info}/METADATA +22 -2
- {piphi_runtime_kit_python-0.8.1.dist-info → piphi_runtime_kit_python-0.10.1.dist-info}/RECORD +9 -6
- {piphi_runtime_kit_python-0.8.1.dist-info → piphi_runtime_kit_python-0.10.1.dist-info}/WHEEL +0 -0
- {piphi_runtime_kit_python-0.8.1.dist-info → piphi_runtime_kit_python-0.10.1.dist-info}/entry_points.txt +0 -0
- {piphi_runtime_kit_python-0.8.1.dist-info → piphi_runtime_kit_python-0.10.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -14,6 +14,30 @@ from .automations import (
|
|
|
14
14
|
audit_behaviors_contract,
|
|
15
15
|
build_mock_automation_event,
|
|
16
16
|
)
|
|
17
|
+
from .camera import (
|
|
18
|
+
CAMERA_MAX_SDP_BYTES,
|
|
19
|
+
CAMERA_MAX_SNAPSHOT_BYTES,
|
|
20
|
+
CAMERA_MAX_SOURCE_URL_BYTES,
|
|
21
|
+
CAMERA_MEDIA_CONTRACT_VERSION,
|
|
22
|
+
CameraCapabilityDeclaration,
|
|
23
|
+
CameraCapabilityEndpoints,
|
|
24
|
+
CameraMediaError,
|
|
25
|
+
CameraMediaProvider,
|
|
26
|
+
CameraSessionClose,
|
|
27
|
+
CameraSessionOffer,
|
|
28
|
+
CameraSessionOpened,
|
|
29
|
+
CameraSidecarSessionOpen,
|
|
30
|
+
CameraSidecarStatus,
|
|
31
|
+
CameraSnapshotRequest,
|
|
32
|
+
CameraSourceDescriptor,
|
|
33
|
+
CameraSourceResolver,
|
|
34
|
+
CameraWebRtcOffer,
|
|
35
|
+
)
|
|
36
|
+
from .onboarding import (
|
|
37
|
+
OnboardingDeclaration,
|
|
38
|
+
OnboardingMode,
|
|
39
|
+
validate_onboarding_declaration,
|
|
40
|
+
)
|
|
17
41
|
from .runtime.auth import (
|
|
18
42
|
RUNTIME_CONTAINER_ID_HEADER_NAME,
|
|
19
43
|
RUNTIME_INTERNAL_TOKEN_HEADER_NAME,
|
|
@@ -109,6 +133,7 @@ from .runtime.mqtt import (
|
|
|
109
133
|
build_source_status_topic,
|
|
110
134
|
build_source_topic_root,
|
|
111
135
|
)
|
|
136
|
+
from .runtime.network import RUNTIME_PORT_ENV_NAME, runtime_port
|
|
112
137
|
from .runtime.registry import RuntimeRegistry
|
|
113
138
|
from .runtime.starter import (
|
|
114
139
|
RuntimeStarter,
|
|
@@ -156,6 +181,10 @@ from .schemas import (
|
|
|
156
181
|
)
|
|
157
182
|
|
|
158
183
|
__all__ = [
|
|
184
|
+
"CAMERA_MAX_SDP_BYTES",
|
|
185
|
+
"CAMERA_MAX_SNAPSHOT_BYTES",
|
|
186
|
+
"CAMERA_MAX_SOURCE_URL_BYTES",
|
|
187
|
+
"CAMERA_MEDIA_CONTRACT_VERSION",
|
|
159
188
|
"CORE_BASE_URL_ENV_NAME",
|
|
160
189
|
"DEFAULT_CORE_CLIENT_TIMEOUT_SECONDS",
|
|
161
190
|
"DEFAULT_RUNTIME_CONFIG_SNAPSHOT_FILENAME",
|
|
@@ -166,6 +195,7 @@ __all__ = [
|
|
|
166
195
|
"RUNTIME_CONFIG_SNAPSHOT_PATH_ENV_NAME",
|
|
167
196
|
"RUNTIME_CONTAINER_ID_HEADER_NAME",
|
|
168
197
|
"RUNTIME_INTERNAL_TOKEN_HEADER_NAME",
|
|
198
|
+
"RUNTIME_PORT_ENV_NAME",
|
|
169
199
|
"AutomationActionDefinition",
|
|
170
200
|
"AutomationActionRequest",
|
|
171
201
|
"AutomationActionResult",
|
|
@@ -176,6 +206,19 @@ __all__ = [
|
|
|
176
206
|
"AutomationIdempotencyStore",
|
|
177
207
|
"AutomationRegistry",
|
|
178
208
|
"BackgroundTaskLimitError",
|
|
209
|
+
"CameraCapabilityDeclaration",
|
|
210
|
+
"CameraCapabilityEndpoints",
|
|
211
|
+
"CameraMediaError",
|
|
212
|
+
"CameraMediaProvider",
|
|
213
|
+
"CameraSessionClose",
|
|
214
|
+
"CameraSessionOffer",
|
|
215
|
+
"CameraSessionOpened",
|
|
216
|
+
"CameraSidecarSessionOpen",
|
|
217
|
+
"CameraSidecarStatus",
|
|
218
|
+
"CameraSnapshotRequest",
|
|
219
|
+
"CameraSourceDescriptor",
|
|
220
|
+
"CameraSourceResolver",
|
|
221
|
+
"CameraWebRtcOffer",
|
|
179
222
|
"ConfigSyncCoordinator",
|
|
180
223
|
"CoreAuthError",
|
|
181
224
|
"CoreDeliveryError",
|
|
@@ -197,6 +240,8 @@ __all__ = [
|
|
|
197
240
|
"IntegrationEventRequest",
|
|
198
241
|
"MqttBrokerConfig",
|
|
199
242
|
"MqttJsonClient",
|
|
243
|
+
"OnboardingDeclaration",
|
|
244
|
+
"OnboardingMode",
|
|
200
245
|
"RuntimeAuthContext",
|
|
201
246
|
"RuntimeAuthHeaders",
|
|
202
247
|
"RuntimeConfig",
|
|
@@ -275,10 +320,12 @@ __all__ = [
|
|
|
275
320
|
"resolve_device_id",
|
|
276
321
|
"resolve_runtime_config_snapshot_path",
|
|
277
322
|
"runtime_lifespan",
|
|
323
|
+
"runtime_port",
|
|
278
324
|
"schedule_event_delivery",
|
|
279
325
|
"schedule_telemetry_delivery",
|
|
280
326
|
"shutdown_background_tasks",
|
|
281
327
|
"track_background_task",
|
|
282
328
|
"validate_typed_config",
|
|
283
329
|
"validate_typed_configs",
|
|
330
|
+
"validate_onboarding_declaration",
|
|
284
331
|
]
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"""Versioned camera-media contract helpers for PiPhi runtimes."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Awaitable, Callable
|
|
6
|
+
from typing import Literal, Protocol
|
|
7
|
+
from urllib.parse import urlsplit
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
10
|
+
|
|
11
|
+
CAMERA_MEDIA_CONTRACT_VERSION: Literal["camera.media.v1"] = "camera.media.v1"
|
|
12
|
+
CAMERA_MAX_SDP_BYTES = 256 * 1024
|
|
13
|
+
CAMERA_MAX_SOURCE_URL_BYTES = 4096
|
|
14
|
+
CAMERA_MAX_SNAPSHOT_BYTES = 8 * 1024 * 1024
|
|
15
|
+
|
|
16
|
+
CameraMediaTransport = Literal["snapshot", "webrtc", "hls"]
|
|
17
|
+
CameraSourceProtocol = Literal["rtsp", "rtsps", "http", "https"]
|
|
18
|
+
CameraSourceTransport = Literal["tcp", "udp", "auto"]
|
|
19
|
+
CameraMediaAudience = Literal["browser-core", "core-sidecar"]
|
|
20
|
+
CameraErrorCode = Literal[
|
|
21
|
+
"CAMERA_OFFLINE",
|
|
22
|
+
"CAMERA_ACCESS_DENIED",
|
|
23
|
+
"CAMERA_SOURCE_INVALID",
|
|
24
|
+
"CAMERA_CODEC_UNSUPPORTED",
|
|
25
|
+
"CAMERA_SIDECAR_UNAVAILABLE",
|
|
26
|
+
"CAMERA_CAPACITY_REACHED",
|
|
27
|
+
"CAMERA_SESSION_EXPIRED",
|
|
28
|
+
"CAMERA_NEGOTIATION_FAILED",
|
|
29
|
+
"CAMERA_SNAPSHOT_UNAVAILABLE",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class CameraContractModel(BaseModel):
|
|
34
|
+
"""Closed base model used by every camera-media message."""
|
|
35
|
+
|
|
36
|
+
model_config = ConfigDict(extra="forbid")
|
|
37
|
+
|
|
38
|
+
contract_version: Literal["camera.media.v1"] = CAMERA_MEDIA_CONTRACT_VERSION
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class CameraCapabilityEndpoints(BaseModel):
|
|
42
|
+
"""Path-only runtime endpoints declared for one camera capability."""
|
|
43
|
+
|
|
44
|
+
model_config = ConfigDict(extra="forbid")
|
|
45
|
+
|
|
46
|
+
source: str | None = None
|
|
47
|
+
snapshot: str | None = None
|
|
48
|
+
events: str | None = None
|
|
49
|
+
hls: str | None = None
|
|
50
|
+
webrtc: str | None = None
|
|
51
|
+
webrtc_close: str | None = None
|
|
52
|
+
|
|
53
|
+
@model_validator(mode="after")
|
|
54
|
+
def validate_paths(self) -> CameraCapabilityEndpoints:
|
|
55
|
+
values = [
|
|
56
|
+
self.source,
|
|
57
|
+
self.snapshot,
|
|
58
|
+
self.events,
|
|
59
|
+
self.hls,
|
|
60
|
+
self.webrtc,
|
|
61
|
+
self.webrtc_close,
|
|
62
|
+
]
|
|
63
|
+
if not any(values):
|
|
64
|
+
raise ValueError("at least one camera endpoint is required")
|
|
65
|
+
for value in (entry for entry in values if entry is not None):
|
|
66
|
+
if (
|
|
67
|
+
not value.startswith("/")
|
|
68
|
+
or value.startswith("//")
|
|
69
|
+
or "\\" in value
|
|
70
|
+
or any(segment in {".", ".."} for segment in value.split("/"))
|
|
71
|
+
):
|
|
72
|
+
raise ValueError("camera endpoints must be safe path-only values")
|
|
73
|
+
return self
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class CameraCapabilityDeclaration(CameraContractModel):
|
|
77
|
+
"""Portable camera capability metadata shared with Core."""
|
|
78
|
+
|
|
79
|
+
message_type: Literal["camera.capability"] = "camera.capability"
|
|
80
|
+
capability_id: str = Field(min_length=1, max_length=300, pattern=r"^[A-Za-z0-9][A-Za-z0-9._:-]*$")
|
|
81
|
+
transports: list[CameraMediaTransport] = Field(min_length=1)
|
|
82
|
+
audio_available: bool = False
|
|
83
|
+
recording_available: bool = False
|
|
84
|
+
refresh_seconds: int = Field(default=15, ge=2, le=300)
|
|
85
|
+
endpoints: CameraCapabilityEndpoints
|
|
86
|
+
|
|
87
|
+
@model_validator(mode="after")
|
|
88
|
+
def validate_transports(self) -> CameraCapabilityDeclaration:
|
|
89
|
+
if len(self.transports) != len(set(self.transports)):
|
|
90
|
+
raise ValueError("camera transports must be unique")
|
|
91
|
+
required_endpoints = {
|
|
92
|
+
"snapshot": self.endpoints.snapshot,
|
|
93
|
+
"hls": self.endpoints.hls,
|
|
94
|
+
"webrtc": self.endpoints.webrtc,
|
|
95
|
+
}
|
|
96
|
+
for transport, endpoint in required_endpoints.items():
|
|
97
|
+
if transport in self.transports and endpoint is None and self.endpoints.source is None:
|
|
98
|
+
raise ValueError(f"{transport} requires its endpoint or a protected source endpoint")
|
|
99
|
+
return self
|
|
100
|
+
|
|
101
|
+
def manifest_capability(self) -> dict[str, object]:
|
|
102
|
+
"""Return the current PiPhi manifest representation."""
|
|
103
|
+
|
|
104
|
+
camera: dict[str, object] = {
|
|
105
|
+
"contract_version": CAMERA_MEDIA_CONTRACT_VERSION,
|
|
106
|
+
"refresh_seconds": self.refresh_seconds,
|
|
107
|
+
}
|
|
108
|
+
endpoint_keys = {
|
|
109
|
+
"source": "gateway_source_endpoint",
|
|
110
|
+
"snapshot": "snapshot_endpoint",
|
|
111
|
+
"events": "events_endpoint",
|
|
112
|
+
"hls": "stream_endpoint",
|
|
113
|
+
"webrtc": "webrtc_endpoint",
|
|
114
|
+
"webrtc_close": "webrtc_close_endpoint",
|
|
115
|
+
}
|
|
116
|
+
for field_name, manifest_name in endpoint_keys.items():
|
|
117
|
+
value = getattr(self.endpoints, field_name)
|
|
118
|
+
if value is not None:
|
|
119
|
+
camera[manifest_name] = value
|
|
120
|
+
if "hls" in self.transports:
|
|
121
|
+
camera["stream_type"] = "hls"
|
|
122
|
+
return {"kind": "camera", "value_kind": "camera", "camera": camera}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class CameraSourceDescriptor(CameraContractModel):
|
|
126
|
+
"""Private camera source passed only between an integration, Core, and a sidecar."""
|
|
127
|
+
|
|
128
|
+
message_type: Literal["camera.source"] = "camera.source"
|
|
129
|
+
audience: Literal["core-sidecar"] = "core-sidecar"
|
|
130
|
+
camera_id: str = Field(min_length=1, max_length=300, pattern=r"^[A-Za-z0-9][A-Za-z0-9._:-]*$")
|
|
131
|
+
source_url: str = Field(min_length=1, max_length=CAMERA_MAX_SOURCE_URL_BYTES)
|
|
132
|
+
source_protocol: CameraSourceProtocol
|
|
133
|
+
preferred_transport: CameraSourceTransport = "auto"
|
|
134
|
+
connect_timeout_seconds: int = Field(default=10, ge=1, le=60)
|
|
135
|
+
|
|
136
|
+
@model_validator(mode="after")
|
|
137
|
+
def validate_source(self) -> CameraSourceDescriptor:
|
|
138
|
+
if any(character in self.source_url for character in "\r\n\0"):
|
|
139
|
+
raise ValueError("camera source URL contains a forbidden control character")
|
|
140
|
+
parsed = urlsplit(self.source_url)
|
|
141
|
+
if parsed.scheme.lower() != self.source_protocol or not parsed.hostname:
|
|
142
|
+
raise ValueError("camera source URL and source_protocol must match and include a host")
|
|
143
|
+
return self
|
|
144
|
+
|
|
145
|
+
def safe_summary(self) -> dict[str, object]:
|
|
146
|
+
"""Return diagnostics that cannot disclose the URL or credentials."""
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
"camera_id": self.camera_id,
|
|
150
|
+
"source_protocol": self.source_protocol,
|
|
151
|
+
"preferred_transport": self.preferred_transport,
|
|
152
|
+
"connect_timeout_seconds": self.connect_timeout_seconds,
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class CameraWebRtcOffer(BaseModel):
|
|
157
|
+
"""Bounded SDP offer reusable inside browser and sidecar messages."""
|
|
158
|
+
|
|
159
|
+
model_config = ConfigDict(extra="forbid")
|
|
160
|
+
|
|
161
|
+
type: Literal["offer"] = "offer"
|
|
162
|
+
sdp: str = Field(min_length=1, max_length=CAMERA_MAX_SDP_BYTES)
|
|
163
|
+
include_audio: bool = False
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class CameraSessionOffer(CameraWebRtcOffer, CameraContractModel):
|
|
167
|
+
message_type: Literal["camera.session.offer"] = "camera.session.offer"
|
|
168
|
+
audience: Literal["browser-core"] = "browser-core"
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class CameraSidecarSessionOpen(CameraContractModel):
|
|
172
|
+
message_type: Literal["camera.sidecar.session.open"] = "camera.sidecar.session.open"
|
|
173
|
+
audience: Literal["core-sidecar"] = "core-sidecar"
|
|
174
|
+
source: CameraSourceDescriptor
|
|
175
|
+
offer: CameraWebRtcOffer
|
|
176
|
+
idle_timeout_seconds: int = Field(default=60, ge=10, le=900)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class CameraSessionOpened(CameraContractModel):
|
|
180
|
+
message_type: Literal["camera.session.opened"] = "camera.session.opened"
|
|
181
|
+
audience: CameraMediaAudience
|
|
182
|
+
session_id: str = Field(min_length=1, max_length=4096)
|
|
183
|
+
type: Literal["answer"] = "answer"
|
|
184
|
+
sdp: str = Field(min_length=1, max_length=CAMERA_MAX_SDP_BYTES)
|
|
185
|
+
expires_at: str | None = Field(default=None, max_length=128)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class CameraSessionClose(CameraContractModel):
|
|
189
|
+
message_type: Literal["camera.session.close"] = "camera.session.close"
|
|
190
|
+
audience: CameraMediaAudience
|
|
191
|
+
session_id: str = Field(min_length=1, max_length=4096)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class CameraSnapshotRequest(CameraContractModel):
|
|
195
|
+
message_type: Literal["camera.snapshot.request"] = "camera.snapshot.request"
|
|
196
|
+
audience: CameraMediaAudience
|
|
197
|
+
maximum_bytes: int = Field(default=CAMERA_MAX_SNAPSHOT_BYTES, ge=1024, le=CAMERA_MAX_SNAPSHOT_BYTES)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class CameraSidecarStatus(CameraContractModel):
|
|
201
|
+
message_type: Literal["camera.sidecar.status"] = "camera.sidecar.status"
|
|
202
|
+
audience: Literal["core-sidecar"] = "core-sidecar"
|
|
203
|
+
ready: bool
|
|
204
|
+
active_sessions: int = Field(ge=0)
|
|
205
|
+
session_capacity: int = Field(ge=1)
|
|
206
|
+
degraded_reason: str | None = Field(default=None, max_length=300)
|
|
207
|
+
supported_source_protocols: list[CameraSourceProtocol] = Field(default_factory=list)
|
|
208
|
+
supported_transports: list[CameraMediaTransport] = Field(default_factory=list)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class CameraMediaError(CameraContractModel):
|
|
212
|
+
message_type: Literal["camera.error"] = "camera.error"
|
|
213
|
+
audience: CameraMediaAudience
|
|
214
|
+
code: CameraErrorCode
|
|
215
|
+
message: str = Field(min_length=1, max_length=300)
|
|
216
|
+
retryable: bool
|
|
217
|
+
retry_after_seconds: int | None = Field(default=None, ge=1, le=3600)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class CameraMediaProvider(Protocol):
|
|
221
|
+
"""Narrow integration-owned interface consumed by Core camera brokering."""
|
|
222
|
+
|
|
223
|
+
def resolve_source(
|
|
224
|
+
self,
|
|
225
|
+
config_id: str,
|
|
226
|
+
capability_id: str,
|
|
227
|
+
) -> Awaitable[CameraSourceDescriptor]: ...
|
|
228
|
+
|
|
229
|
+
def capture_snapshot(
|
|
230
|
+
self,
|
|
231
|
+
config_id: str,
|
|
232
|
+
capability_id: str,
|
|
233
|
+
request: CameraSnapshotRequest,
|
|
234
|
+
) -> Awaitable[tuple[str, bytes]]: ...
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
CameraSourceResolver = Callable[[str, str], Awaitable[CameraSourceDescriptor]]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Typed homeowner onboarding declarations for PiPhi manifests."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any, Mapping
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, ConfigDict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class OnboardingMode(str, Enum):
|
|
10
|
+
"""The first homeowner-facing action after a package is installed."""
|
|
11
|
+
|
|
12
|
+
MANUAL = "manual"
|
|
13
|
+
DISCOVERY = "discovery"
|
|
14
|
+
ACCOUNT = "account"
|
|
15
|
+
SERVICE = "service"
|
|
16
|
+
NONE = "none"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class OnboardingDeclaration(BaseModel):
|
|
20
|
+
"""Manifest declaration consumed by PiPhi Core's setup planner."""
|
|
21
|
+
|
|
22
|
+
model_config = ConfigDict(extra="forbid")
|
|
23
|
+
|
|
24
|
+
mode: OnboardingMode
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def validate_onboarding_declaration(
|
|
28
|
+
value: OnboardingDeclaration | Mapping[str, Any],
|
|
29
|
+
) -> OnboardingDeclaration:
|
|
30
|
+
"""Validate and normalize a manifest ``onboarding`` object."""
|
|
31
|
+
|
|
32
|
+
if isinstance(value, OnboardingDeclaration):
|
|
33
|
+
return value
|
|
34
|
+
return OnboardingDeclaration.model_validate(dict(value))
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Managed runtime network configuration helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from collections.abc import Mapping
|
|
7
|
+
|
|
8
|
+
RUNTIME_PORT_ENV_NAME = "PORT"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def runtime_port(default: int, *, environ: Mapping[str, str] | None = None) -> int:
|
|
12
|
+
"""Return the Core-assigned listener port, or ``default`` outside Core.
|
|
13
|
+
|
|
14
|
+
A present but invalid ``PORT`` is a contract error. Silently falling back in
|
|
15
|
+
that case can bind a managed runtime to a port owned by another service.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
_validate_port(default, source="default")
|
|
19
|
+
environment = os.environ if environ is None else environ
|
|
20
|
+
raw = environment.get(RUNTIME_PORT_ENV_NAME)
|
|
21
|
+
if raw is None:
|
|
22
|
+
return default
|
|
23
|
+
try:
|
|
24
|
+
port = int(raw)
|
|
25
|
+
except ValueError as exc:
|
|
26
|
+
raise ValueError("PORT must be an integer between 1 and 65535") from exc
|
|
27
|
+
return _validate_port(port, source=RUNTIME_PORT_ENV_NAME)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _validate_port(port: int, *, source: str) -> int:
|
|
31
|
+
if isinstance(port, bool) or not isinstance(port, int) or not 1 <= port <= 65535:
|
|
32
|
+
raise ValueError(f"{source} must be an integer between 1 and 65535")
|
|
33
|
+
return port
|
{piphi_runtime_kit_python-0.8.1.dist-info → piphi_runtime_kit_python-0.10.1.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: piphi-runtime-kit-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.1
|
|
4
4
|
Summary: PiPhi Network runtime integration helpers
|
|
5
5
|
Keywords: piphi,runtime,integration,iot
|
|
6
6
|
Author-Email: KelvinSan <support@piphi.network>
|
|
@@ -18,6 +18,7 @@ Project-URL: Repository, https://github.com/PiPhi-io/piphi-runtime-kit-python
|
|
|
18
18
|
Project-URL: Issues, https://github.com/PiPhi-io/piphi-runtime-kit-python/issues
|
|
19
19
|
Requires-Python: >=3.11
|
|
20
20
|
Requires-Dist: anyio<5.0,>=4.14.2
|
|
21
|
+
Requires-Dist: certifi>=2026.10.19
|
|
21
22
|
Requires-Dist: httpx<1.0,>=0.27
|
|
22
23
|
Requires-Dist: pydantic<2.14,>=2.8
|
|
23
24
|
Provides-Extra: fastapi
|
|
@@ -30,12 +31,31 @@ Description-Content-Type: text/markdown
|
|
|
30
31
|
|
|
31
32
|
Small Python helpers for building PiPhi runtime integrations.
|
|
32
33
|
|
|
34
|
+
## Managed listener port
|
|
35
|
+
|
|
36
|
+
Core assigns the primary listener through `PORT`. Use `runtime_port(default)` when starting the server. The default is only for unmanaged local development; an invalid managed assignment raises an error rather than risking a collision.
|
|
37
|
+
|
|
33
38
|
This package is intentionally thin. It removes repetitive PiPhi runtime
|
|
34
39
|
plumbing without hiding the HTTP contract behind a large framework. The goal
|
|
35
40
|
is to help developers move faster while still understanding what their runtime
|
|
36
41
|
is doing.
|
|
37
42
|
|
|
38
|
-
Version `0.
|
|
43
|
+
Version `0.10.0` is the current documented baseline.
|
|
44
|
+
|
|
45
|
+
## Onboarding declarations
|
|
46
|
+
|
|
47
|
+
Runtime discovery and homeowner onboarding are separate contracts. Validate a
|
|
48
|
+
manifest's explicit first-use declaration without inferring it from `/discover`:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from piphi_runtime_kit_python import OnboardingMode, validate_onboarding_declaration
|
|
52
|
+
|
|
53
|
+
onboarding = validate_onboarding_declaration({"mode": OnboardingMode.MANUAL})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The supported modes are `manual`, `discovery`, `account`, `service`, and
|
|
57
|
+
`none`. Runtime strategies such as `passive` or `mdns` belong in runtime
|
|
58
|
+
discovery metadata, not in `onboarding.mode`.
|
|
39
59
|
|
|
40
60
|
> New to PiPhi? Start with [First 15 Minutes](#first-15-minutes), then read [The Golden Path](#the-golden-path), then compare your code to the example app.
|
|
41
61
|
|
{piphi_runtime_kit_python-0.8.1.dist-info → piphi_runtime_kit_python-0.10.1.dist-info}/RECORD
RENAMED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
piphi_runtime_kit_python-0.
|
|
2
|
-
piphi_runtime_kit_python-0.
|
|
3
|
-
piphi_runtime_kit_python-0.
|
|
4
|
-
piphi_runtime_kit_python-0.
|
|
5
|
-
piphi_runtime_kit_python/__init__.py,sha256=
|
|
1
|
+
piphi_runtime_kit_python-0.10.1.dist-info/METADATA,sha256=iMTDMhsDbFdtEw7GhGh50Rh2xkpqp8OMSSE2caCHS4o,38421
|
|
2
|
+
piphi_runtime_kit_python-0.10.1.dist-info/WHEEL,sha256=IuIk3wbaEnFH1cx75iM2R1CmliRI3dFLXTbRakgvgFQ,90
|
|
3
|
+
piphi_runtime_kit_python-0.10.1.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
|
4
|
+
piphi_runtime_kit_python-0.10.1.dist-info/licenses/LICENSE,sha256=pS6szQI4X7qAin1ODdoDp-XwZvsFy6ZZ28-JAwGHgzo,1070
|
|
5
|
+
piphi_runtime_kit_python/__init__.py,sha256=fNMpSEmmNfLk1eSjVHfIb0p3HPhbyHTvN0qXrczRbYI,9602
|
|
6
6
|
piphi_runtime_kit_python/adapters/__init__.py,sha256=3jBhPZSBN3Qo7MKHlxAol2jPU3cK23BXHR2oTlircsw,361
|
|
7
7
|
piphi_runtime_kit_python/adapters/fastapi.py,sha256=4BP_Ewm2K4NmyUvhgOzCUH7-fN3JwQFRwSUVxrHptQI,3099
|
|
8
8
|
piphi_runtime_kit_python/automations.py,sha256=mDK62mo0hbsXGU48zEp-W7Q9MSzO9CsjnUEf75X6Yvw,20545
|
|
9
|
+
piphi_runtime_kit_python/camera.py,sha256=37LCMzRvP1NxCWXa4Z7WmWWRLsw92MM3CZLNscTdMe8,9093
|
|
9
10
|
piphi_runtime_kit_python/fastapi.py,sha256=xvHU19-CVDPKjmXW6nW72mpdbJEOLZzT8Twal7lCCkc,453
|
|
11
|
+
piphi_runtime_kit_python/onboarding.py,sha256=ZnCmQxb6hWp6L1RxbrqpziScnW9BONhXKapOiFu9kYo,898
|
|
10
12
|
piphi_runtime_kit_python/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
11
13
|
piphi_runtime_kit_python/runtime/__init__.py,sha256=giSFLVRYGZU8icAWAgThevj59oTAXRoKTe5zo3fEeiA,4081
|
|
12
14
|
piphi_runtime_kit_python/runtime/auth.py,sha256=SDfQ1zSWR5zg3fGYMpr0Az9zkvDwgrrtcQVtyeFU0NI,4728
|
|
@@ -21,6 +23,7 @@ piphi_runtime_kit_python/runtime/health.py,sha256=D5aGvsuIHAFCEq6tw6o0qOuRhiC-Nx
|
|
|
21
23
|
piphi_runtime_kit_python/runtime/identity.py,sha256=RyTIF8ZA7Kt-xmloYG9J6GuDZ_UcdPPoSA1TEqC6YKU,5098
|
|
22
24
|
piphi_runtime_kit_python/runtime/lifespan.py,sha256=fHBwM9-2OskRwRIklK1PG0f_Y77guZoL1qJ7Y4jks7g,3037
|
|
23
25
|
piphi_runtime_kit_python/runtime/mqtt.py,sha256=QC6C017stmmjD89tMFvrRyazpANuIBCN3KrYodjiTrE,6178
|
|
26
|
+
piphi_runtime_kit_python/runtime/network.py,sha256=pWQg_9VjprrDhQ5iSo7PhAW1kETFWpe7zxyj6zMg5jE,1138
|
|
24
27
|
piphi_runtime_kit_python/runtime/registry.py,sha256=nO7qoc0JVBjUhqsvAubMN0DH5hNcZmWtnVY0l-G5KN8,3418
|
|
25
28
|
piphi_runtime_kit_python/runtime/starter.py,sha256=0D54HeKHK1veb1F-DfgC46UkUp6B0DtJS97ga_EslJ8,7043
|
|
26
29
|
piphi_runtime_kit_python/runtime/state.py,sha256=OIwVxAzX2ErsZ2XdrWlIP5r3GHHub5y9PDtoqNDlwkQ,952
|
|
@@ -28,4 +31,4 @@ piphi_runtime_kit_python/runtime/state_service.py,sha256=bWxQD9JJRJsOA2k1S_TttFx
|
|
|
28
31
|
piphi_runtime_kit_python/runtime/tasks.py,sha256=E9WoE75NQiJp3buJYexysl3NuP8HJHJ3KfaGVKLdiw0,3238
|
|
29
32
|
piphi_runtime_kit_python/runtime/telemetry.py,sha256=b08Faq0CBrTqc5MCDjRUnX0KVT-MN8n4Le_FE-b2BVo,6719
|
|
30
33
|
piphi_runtime_kit_python/schemas.py,sha256=eXb_WEEGREGTRWkhShaof9N64vlrsHhVKAJECSia_to,10435
|
|
31
|
-
piphi_runtime_kit_python-0.
|
|
34
|
+
piphi_runtime_kit_python-0.10.1.dist-info/RECORD,,
|
{piphi_runtime_kit_python-0.8.1.dist-info → piphi_runtime_kit_python-0.10.1.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|