Skip to main content
Repair and provision a gateway config from Python β€” no shell-out, no interactive wizard, and a typed result you can assert on.

Quick Start

1

Repair a broken config

2

Provision a config from scratch

3

Detect without repairing


How It Works

Both entry points share the detect β†’ repair β†’ re-validate lifecycle behind praisonai gateway doctor --fix.

When to use which


API Reference

Three symbols make up the whole public surface.

repair_gateway_config

repair_gateway_config(config_path, *, fix=False, dry_run=False) -> GatewayRepairResult Runs the same detect β†’ repair β†’ re-validate lifecycle as praisonai gateway doctor --fix: forward-migrate an out-of-date config_version and mint/persist a strong gateway.auth_token when the configured one is weak or missing.

provision_gateway_config

provision_gateway_config(*, platform, token, agents=None, config_path=None) -> Path
provision_gateway_config is fail-closed: an unsupported platform or an empty token raises ValueError and writes nothing, rather than producing a config the gateway would boot degraded.

GatewayRepairResult

@dataclass(frozen=True) β€” the closed result shape returned by repair_gateway_config. .to_dict() returns a shallow JSON-safe copy of all four fields.

Precedence & Fallbacks

The auth-token repair interacts with ${ENV} references and explicit YAML tokens as follows.

CLI parity

The Python API, CLI, and YAML surfaces run the same helpers.

Common Patterns

CI-driven per-tenant provisioning

Post-deploy self-healing check

Testing the fixed gateway in pytest

Explicit path vs default location


Best Practices

Run without fix=True, review remaining_degraded_owners, then re-run with fix=True. A detect-only pass never writes to disk.
Config-version drift and weak tokens are silent until you check. Wire repair_gateway_config(path, fix=False) into your post-deploy smoke test.
provision_gateway_config(token=...) persists the credential to ~/.praisonai/.env (0600). Pass a ${VAR} reference in your YAML so the secret stays out of source control.
Both surfaces run the same helpers in admin.py β€” a repair from either is identical. Use the CLI interactively, the Python API in CI and tests.
An unsupported platform or empty token refuses to write, preventing a β€œstarts degraded” outcome. Do not catch and ignore it.

Gateway CLI

The wrapping gateway doctor commands.

Bot Onboarding

The interactive wizard β€” sibling of provision_gateway_config.

Bind-Aware Auth

Weak-secret guard context.

Config Migration

Config-version migration context.