Skip to main content

ophix-client-core

The shared foundation every Ophix client is built on.

Every fleet client — whichever domain it's fetching credentials, configs, certificates, or tasks for — needs the same underlying plumbing: registration, token rotation with post-rotation validation, HTTP handling, a consistent CLI. ophix-client-core is that shared foundation, so each Tier 1 client (ophix-cred-client, ophix-task-client, etc.) only has to implement the handful of API calls specific to its own domain.

This package is automatically included with every Ophix client, no need to separately install it.


For domain client authors

Add ophix-client-core as a dependency in your pyproject.toml, then follow the pattern below.

_config.py — declare your ClientConfig

from client_core.config import ClientConfig
from my_client._version import __version__

CLIENT_CONFIG = ClientConfig(
    prog="my-client",
    description="Ophix My Domain client.",
    env_file=".my.env",
    server_url_key="MYSERVER_URL",
    api_token_key="MYSERVER_API_TOKEN",
    ca_cert_key="MYSERVER_CA_CERT",
    client_name="my",   # drives X-My-* request headers and .my/ cert directory
    version=__version__,
)

cli.py — extend the base command registry

from client_core.commands import build_commands
from client_core.parser import make_main
from my_client._config import CLIENT_CONFIG
from my_client.core import get_things

def cmd_fetch(args):
    ...

COMMANDS = build_commands(CLIENT_CONFIG)
COMMANDS["fetch"] = {
    "help": "Fetch things from the server.",
    "arguments": [],
    "handler": cmd_fetch,
}

main = make_main(CLIENT_CONFIG, COMMANDS)

build_commands(config) returns the full set of base commands pre-bound to your config. Extend the dict with domain-specific entries and pass it to make_main.


What's included

Base CLI commands

All commands are registered automatically by build_commands(config).

Command Description
quickstart <server_url> <client_name> Set server URL, download CA cert, and register in one step
set server|ca-cert|token <value> Write a configuration value to the env file
download ca-cert Download and save the server CA certificate
register <name> Register this client with the server
rotate-token Generate a new token, send to server, update env file
info Show client identity from the server
update Update venv info on the server
doctor Diagnose local configuration and server connectivity

client_core.config — ClientConfig

Dataclass holding all domain-specific identifiers. Passed to every shared function so no global state is required.

client_core.core

Shared utilities:

  • resolve_server_config(config, ...) — load env file, resolve URL/token/CA cert, validate
  • build_client_headers(config, api_token=None) — standard X-{Name}-* request headers
  • ensure_env_file(config) — find or create the domain env file with 600 permissions
  • find_project_root() — walk up from cwd to find project root
  • in_venv() — return Path(sys.prefix) if inside a venv, else None
  • detect_os_flavour() — human-readable OS description
  • detect_invocation() — best-effort invocation string from sys.argv

client_core.parser

  • build_parser(config, commands) — build an ArgumentParser from a ClientConfig and COMMANDS dict
  • make_main(config, commands) — return a main() callable suitable for use as a pyproject.toml entry point

Environment file

Each domain client uses its own env file (e.g. .task.env, .cred.env). ClientConfig.env_file sets the filename. Three keys are always present:

Key Description
{NAME}SERVER_URL Server base URL
{NAME}SERVER_API_TOKEN 64-character hex client token
{NAME}SERVER_CA_CERT Path to CA certificate PEM (optional)

The CA certificate is saved to .<client_name>/ca-cert.pem relative to the project root.

If the server has no custom CA configured (e.g. it uses a publicly trusted certificate such as Let's Encrypt), /api/server/ca-cert/ returns 404. Both download ca-cert and quickstart treat this as expected — they print an informational message and continue rather than failing, since the system trust store already covers a publicly signed certificate and no local CA file is needed.


License

MIT

Metadata

Release files for ophix-client-core 2026.10.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ophix-client-core 2026.10.4.1
File Size Uploaded Provenance Actions
ophix_client_core-2026.10.4.1.tar.gz 15.0 kB Without provenance Details for ophix_client_core-2026.10.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ophix-client-core 2026.10.4.1
File Interpreter ABI Platform Actions
ophix_client_core-2026.10.4.1-py3-none-any.whl Python 3 none any Details for ophix_client_core-2026.10.4.1-py3-none-any.whl

Total release size: 29.6 kB

Release files / ophix_client_core-2026.10.4.1.tar.gz

Download URL ophix_client_core-2026.10.4.1.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cd5cd0ebd6dc0076911b31dbc1b2bf85e11047383faf5619c5fa9fd7f0729cef
BLAKE2b-256 checksum
How to use checksums
fd22656fba840f2c785c1819e9efff25c0160d5e1d96b763018a3f0693878283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / ophix_client_core-2026.10.4.1-py3-none-any.whl

Download URL ophix_client_core-2026.10.4.1-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84efdea185d02c58c64a399042a8d0048eb0d387548f0efcb7ae93ebdf5ae330
BLAKE2b-256 checksum
How to use checksums
3a6b0e2ae02467e101c7a707ca98f45456050a2c8814b9e516a91b381e0db159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for ophix-client-core 2026.10.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page