yera.tools.creds.snapshot
Read-only flat credential snapshot exposed to tool bodies.
Symbols
ToolCreds
Read-only snapshot of credentials available to a tool.
Wraps a flat dict[str, str] mapping dotted keys
(<group>.<subkey>) to their string values. Tools obtain an
instance via
tool_creds rather than
constructing one directly.
Example:
@yr.tool(creds=["db"])
def query(sql: str) -> list[dict]:
creds = yr.tool_creds()
host = creds.require("db.host")
port = creds.require("db.port")
...
Methods
ToolCreds.get
get(
key: str,
) → str | NoneLook up a credential by dotted key, returning None if absent.
Parameters
Dotted credential key, e.g. "openai.api_key".
Returns
The credential value, or None if no such key is configured.
ToolCreds.require
require(
key: str,
) → strLook up a credential by dotted key, raising if absent.
Parameters
Dotted credential key, e.g. "openai.api_key".
Returns
The credential value.
Raises
If no such key is configured.
ToolCreds.keys
keys() → list[str]Return the configured credential keys, sorted alphabetically.
ToolCreds.__contains__
__contains__(
key: str,
) → boolCheck whether a dotted key is configured.
ToolCreds.__len__
__len__() → intNumber of configured credentials.
ToolCreds.__repr__
__repr__() → strRepr string for ToolCreds.