distinct / distinct_agent /__init__.py
aaxaxax's picture
initial commit
2aa8b3a
Raw History Blame Contribute Delete
5.13 kB
"""Cross-platform local worker primitives for Distinct.
One request-signing scheme is in production: the newline-delimited canonical
request implemented by ``distinct_agent.transport.sign_server_request`` and
verified by ``distinct_server.security.sign_request``. The two are deliberate
duplicates -- the agent must not import the server package -- and
``tests/test_signing_conformance.py`` pins them together.
``distinct_agent.auth`` implemented a different, incompatible scheme and has
been deleted. The decision it was waiting on is made: a signed
``AgentSnapshot`` carries a detached signature, implemented as
``distinct_protocol.handshake.SignedSnapshot`` and argued in PLAN.md section
4.9. ``tests/test_signing_conformance.py`` keeps the deleted scheme deleted.
Response authentication in the other direction lives in
``distinct_agent.transport.ServerAuthenticator``: under an agent-pull transport
the agent dials an address a human typed, so the server-to-agent direction
needs proving too.
"""
# Before anything else: `distinct_agent.transport` imports gradio_client,
# which contacts huggingface.co on every Client construction, once for a
# registry lookup and once for telemetry carrying the server URL the
# operator typed. `transport.py` already passes analytics_enabled=False and
# that keyword cannot disable anything. Importing this package runs this
# file first, which is the only point ahead of that import.
from distinct_protocol.telemetry import silence_third_party_telemetry
silence_third_party_telemetry()
from .containment import (
MINIMUM_TIER,
TARGET_TIER,
TIER_ISOLATED,
TIER_NONE,
TIER_PRIVILEGE,
TIER_PROCESS,
ContainmentPolicy,
ContainmentReport,
detect_containment,
)
from .energy import (
CumulativeEnergyMeter,
EnergyMeter,
EnergyToken,
EnergyUsage,
PyRaplEnergyMeter,
UnavailableEnergyMeter,
WindowsPerformanceCounterRaplMeter,
detect_energy_meter,
)
from .models import (
KNOWN_MODEL_MANIFESTS,
DiscoveredModel,
discover_models,
index_discovered,
model_manifest,
)
from .queue import (
DEFAULT_POLL_INTERVAL_SECONDS,
DEFAULT_SNAPSHOT_INTERVAL_SECONDS,
CancellationDecision,
InMemoryJobQueue,
JobView,
OfferDecision,
)
from .runners import (
LLAMA_ENVIRONMENT_ALLOWLIST,
DeterministicDemoRunner,
InferenceResult,
InferenceRunner,
LlamaCppRunner,
RunnerCancelled,
RunnerError,
RunnerTimedOut,
RunnerUnavailable,
build_llama_environment,
)
from .sandbox import (
DenoSandboxStatus,
GeneratedExecutionDisabled,
GeneratedExecutionPolicy,
check_deno_sandbox,
)
from .servers import (
AllowanceError,
AllowanceGate,
PinMismatch,
Refusal,
ServerRegistry,
UnknownServer,
storage_warning,
)
from .tools import ToolBrokerAdapter, ToolBrokerUnavailable, ToolNotAllowed, load_tool_broker
from .transport import (
AgentApiRejected,
AgentCredential,
AgentPairingRejected,
AgentProtocolError,
AgentTransportError,
AgentTransportUnavailable,
GradioAgentTransport,
canonical_body,
canonical_server_request,
decode_agent_secret,
sign_server_request,
validate_server_url,
)
from .worker import (
AgentTransport,
JobExecutor,
LocalInferenceExecutor,
WorkerLoop,
WorkerLoopSettings,
)
__all__ = [
"AgentTransport",
"AgentApiRejected",
"AgentCredential",
"AgentPairingRejected",
"AgentProtocolError",
"AgentTransportError",
"AgentTransportUnavailable",
"AllowanceError",
"AllowanceGate",
"CancellationDecision",
"ContainmentPolicy",
"ContainmentReport",
"CumulativeEnergyMeter",
"DEFAULT_POLL_INTERVAL_SECONDS",
"DEFAULT_SNAPSHOT_INTERVAL_SECONDS",
"DenoSandboxStatus",
"MINIMUM_TIER",
"DeterministicDemoRunner",
"DiscoveredModel",
"EnergyMeter",
"EnergyToken",
"EnergyUsage",
"GeneratedExecutionDisabled",
"GeneratedExecutionPolicy",
"GradioAgentTransport",
"InMemoryJobQueue",
"InferenceResult",
"InferenceRunner",
"JobExecutor",
"JobView",
"KNOWN_MODEL_MANIFESTS",
"LLAMA_ENVIRONMENT_ALLOWLIST",
"LlamaCppRunner",
"LocalInferenceExecutor",
"OfferDecision",
"PinMismatch",
"PyRaplEnergyMeter",
"Refusal",
"RunnerCancelled",
"RunnerError",
"RunnerTimedOut",
"RunnerUnavailable",
"ServerRegistry",
"TARGET_TIER",
"TIER_ISOLATED",
"TIER_NONE",
"TIER_PRIVILEGE",
"TIER_PROCESS",
"ToolBrokerAdapter",
"ToolBrokerUnavailable",
"ToolNotAllowed",
"UnavailableEnergyMeter",
"UnknownServer",
"WindowsPerformanceCounterRaplMeter",
"WorkerLoop",
"WorkerLoopSettings",
"build_llama_environment",
"canonical_body",
"canonical_server_request",
"check_deno_sandbox",
"detect_containment",
"detect_energy_meter",
"decode_agent_secret",
"discover_models",
"index_discovered",
"load_tool_broker",
"model_manifest",
"sign_server_request",
"storage_warning",
"validate_server_url",
]