secrets • AI Agent SDK

First-class secret references for credential fields (Issue #3102).

secrets

AI Agent

First-class secret references for credential fields (Issue #3102).

Provides a lightweight, protocol-first contract so that any credential field (bot token, Slack app token, WhatsApp verify token, API keys) can be sourced from an environment variable, a mounted secret file, or a command / secret manager — instead of being committed as plaintext or exposed as a process-wide environment variable.

Design goals (kept deliberately lightweight — stdlib only, no heavy imports):

  • `SecretRef` — a typed, immutable reference describing where a secret lives.
  • `SecretInput — str | SecretRef | dict so plaintext and ${ENV}` stay
  • fully backward compatible; the reference form is purely additive.
  • `SecretResolver` — a pluggable protocol; the built-in resolver handles the
  • `env / file / exec` sources with the stdlib alone.
  • `register_secret_for_redaction / redact_secrets` — a process-wide
  • registry so resolved secret values can be scrubbed from logs and errors.

The wrapper (`praisonai`) and channel adapters may register additional resolvers (e.g. a Vault / AWS / GCP secret-manager resolver) without importing anything heavy into core.

Import

python
from praisonaiagents import secrets

Classes

Functions

Constants

NameValue
_VALID_SOURCES('env', 'file', 'exec')
AVAILABLE'available'
UNAVAILABLE'configured-but-unavailable'
MISSING'missing'
_REDACTED'[REDACTED]'
_MIN_REDACT_LEN4
_CREDENTIAL_SHAPE_PATTERNS`(‘\\bsk-(?:ant-\proj-)?[A-Za-z0-9_-]{16,}\\b’, ‘\\bAKIA[0-9A-Z]{16}\\b’, ‘\\bgh[pousr]_[A-Za-z0-9]{16,}\\b’, ‘\\bgithub_pat_[A-Za-z0-9_]{22,}\\b’, ‘\\bAIza[0-9A-Za-z_-]{35}\\b’, ‘\\bxox[baprs]-[0-9A-Z…`
_SENTINEL_PREFIX'oc-sent-'