Utility for normalizing and converting UUIDs, supporting legacy prefixes.
# Source: https://github.com/omnigent-ai/omnigent | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Canonical UUID normalization shared by clients and database columns."""
from __future__ import annotations
import uuid
# Hex length of a bare uuid4 id, the canonical Python-side form.
_UUID_HEX_LEN = 32
# Accept historical prefixes so old URLs and clients keep resolving; reject
# unknown prefixes so a different ID type cannot silently become a UUID.
_LEGACY_ID_PREFIXES = frozenset(
{
"ag",
"conv",
"host",
"pol",
"file",
"cmt",
# conversation-item per-type prefixes
"msg",
"fc",
"fco",
"err
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key