g8e Protocol Constants and Models
Project description
g8e
Python protocol library for the g8e zero-trust execution platform. Provides protocol constants, dynamic enums, and Pydantic models for building g8e-compatible clients and services.
Installation
Requires Python 3.10 or later. Dependencies are pydantic>=2.0.0 and protobuf>=4.0.0.
pip install g8e
Usage
Constants
The g8e.constants module loads JSON protocol constants from protocol/constants/ at import time. It exports dicts for events, status, collections, headers, channels, pubsub, intents, prompts, timestamps, document IDs, platform configuration, agents, network, API paths, key-value keys, and sender identifiers. The module also exports the ComponentName StrEnum and individual HTTP header string constants for session, context, and g8e-specific headers.
Set the G8E_PROTOCOL_DIR environment variable to override the default protocol directory resolution. The loader checks this variable first, then falls back to the relative path from the package, then to /app/protocol/constants for containerized environments.
Accessor Functions
The module provides typed accessor functions that resolve constant keys to their wire values:
collection(name)— collection wire value (e.g.collection("cases"))channel(name)— channel wire valueintent(name)— intent wire valueprompt(name)— prompt section wire valuekv_key(name, **kwargs)— formatted KV key with placeholder substitution (e.g.kv_key("SessionWeb", **{"session.type": "web", "session.id": "abc"}))kv_session_type(name)— session type wire value
The kv_key() function uses regex substitution to handle dotted placeholder names like {session.type} in KV key templates.
Enums
The g8e.enums module dynamically generates StrEnum and IntEnum classes from the STATUS and EVENTS protocol constants. Enum member names use SCREAMING_SNAKE_CASE; values preserve the raw protocol wire format. Integer-valued categories produce IntEnum; all others produce StrEnum. Access enums by PascalCase name via attribute lookup, for example g8e.enums.OperatorToolName or g8e.enums.EventType.
In addition to STATUS-derived enums, the module generates enums from other constant categories:
g8e.enums.Channel— fromchannels.jsong8e.enums.Intent— fromintents.jsong8e.enums.Prompt— fromprompts.jsong8e.enums.Collection— fromcollections.jsong8e.enums.KVKey— fromkv_keys.jsong8e.enums.SessionType— fromsession_typesinkv_keys.json
Models
The g8e.models package provides Pydantic v2 models for protocol data structures. All models extend G8eBaseModel, which configures populate_by_name and extra="ignore", and defaults exclude_none on serialization. The UTCDatetime annotated type serializes datetimes to ISO 8601 with a Z suffix.
g8e/models/base.py:G8eBaseModel,UTCDatetime, and re-exports of PydanticField,ConfigDict,field_validator,model_validator.g8e/models/context.py:RequestContextandBoundOperator.RequestContextvalidates session identity forCLIENTsource components, requiring eitherweb_session_idorcli_session_idand auser_id.g8e/models/events.py: SSE wire models (SessionEventWire,BackgroundEventWire) with factory methodsfrom_session_event()andfrom_background_event()for construction from event type + data. AI event payload models for chat processing, tool lifecycle, citations, errors, thinking, turn completion, retry, and triage clarification.g8e/models/internal_api.py:ChatMessageRequest,ChatStartedResponse, andResourceCreationRequestfor internal API interactions.ChatMessageRequestinherits fromLLMOverrides, which provides 12 optional LLM provider/model/endpoint override fields.g8e/models/settings.py:G8eeUserSettings,PlatformSettings, and nested settings models for LLM providers, search, eval judge, command validation, and batch execution.g8e/models/governance.py:GovernanceEnvelope,GovernanceMetadata,GovernanceL1,GovernanceL2,GovernanceL3, andcompute_transaction_hash(). TheGovernanceEnvelopemodel mirrors the canonical wire format for all mutations.compute_transaction_hash()produces a deterministic SHA-256 over pipe-delimited canonical fields.
Examples
Working examples are in protocol/python/examples/. Run constants_example.py for constants and headers usage, or models_example.py for model instantiation, serialization, and validation.
Components
g8e/constants.py: Runtime loader for JSON protocol constants fromprotocol/constants/. Exports dict constants,ComponentNameenum, HTTP header string constants, and accessor functions (collection(),channel(),intent(),prompt(),kv_key(),kv_session_type()).g8e/enums.py: DynamicStrEnumandIntEnumgeneration fromSTATUS,EVENTS, and other constant categories (channels, intents, prompts, collections, kv_keys, session_types).g8e/models/: Pydantic v2 models for protocol data structures, SSE events, internal API requests, user settings, and governance envelopes.
Protocol Versioning
This package follows semantic versioning. Major version changes indicate breaking protocol changes. Minor version changes add new protocol features. Patch version changes include bug fixes and non-breaking enhancements.
License
Apache License 2.0. See protocol/LICENSE for details.
Contributing
Protocol changes require coordination across all g8e components. Submit protocol change proposals via GitHub issues with clear justification and impact analysis.
Support
For protocol questions and support, open a GitHub issue or visit https://github.com/g8e-ai/g8e
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file g8e-1.5.9.tar.gz.
File metadata
- Download URL: g8e-1.5.9.tar.gz
- Upload date:
- Size: 116.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be64178d9fe06f3028aab48981929e5c8c1b0586b9659170a9199935275fcc2a
|
|
| MD5 |
e0dd134d2fe7076c8da11bdf5f2b572b
|
|
| BLAKE2b-256 |
798496596dda869d6a2b1157d744f73453d65edf0b54e25c7d42df22b99522ca
|
Provenance
The following attestation bundles were made for g8e-1.5.9.tar.gz:
Publisher:
release-python-protocol.yml on g8e-ai/g8e
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
g8e-1.5.9.tar.gz -
Subject digest:
be64178d9fe06f3028aab48981929e5c8c1b0586b9659170a9199935275fcc2a - Sigstore transparency entry: 2204541903
- Sigstore integration time:
-
Permalink:
g8e-ai/g8e@167d094a9f9600951c587a17d3f2b22af83739bf -
Branch / Tag:
refs/tags/protocol/v1.5.9 - Owner: https://github.com/g8e-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-protocol.yml@167d094a9f9600951c587a17d3f2b22af83739bf -
Trigger Event:
push
-
Statement type:
File details
Details for the file g8e-1.5.9-py3-none-any.whl.
File metadata
- Download URL: g8e-1.5.9-py3-none-any.whl
- Upload date:
- Size: 116.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d92c9793b5c5e337b87653b2c379172155bba6872f512a12455ba8be2a0e129d
|
|
| MD5 |
bf08fc368cd4bdc40c19e92b5311eb4b
|
|
| BLAKE2b-256 |
cae9a01af793c66d1fef9139e94bca0964cf340b07925d1f07ec0d6c4e302dbf
|
Provenance
The following attestation bundles were made for g8e-1.5.9-py3-none-any.whl:
Publisher:
release-python-protocol.yml on g8e-ai/g8e
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
g8e-1.5.9-py3-none-any.whl -
Subject digest:
d92c9793b5c5e337b87653b2c379172155bba6872f512a12455ba8be2a0e129d - Sigstore transparency entry: 2204541927
- Sigstore integration time:
-
Permalink:
g8e-ai/g8e@167d094a9f9600951c587a17d3f2b22af83739bf -
Branch / Tag:
refs/tags/protocol/v1.5.9 - Owner: https://github.com/g8e-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-protocol.yml@167d094a9f9600951c587a17d3f2b22af83739bf -
Trigger Event:
push
-
Statement type: