enterprise_ai.channels.bridge
Source: sdks/python/src/enterprise_ai/channels/bridge.py. Back to the Python SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Class ChannelBridgeError
The channel cannot be bridged (no Navin connection, missing secret resolver, adapter not installed).
EaiError
Model Inbound
An inbound message, whatever bus produced it.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
text | str | yes | Text of the message. |
user | str | yes | Sender of the message (sender_id or sender of the bus message, user by default). |
conversation_id | str | yes | Conversation the message belongs to (up to 200 characters). A new one is generated when omitted. |
metadata | dict[str, Any] | no | Free key-value pairs stored with the object and returned as they are; the platform never interprets them. |
Inbound.of
of(message: Any) -> Inbound
Build an Inbound from a bus message read by attribute: content, sender_id or sender, chat_id or session_id, metadata.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
message | Any | yes | Message of the Navin bus or of enterprise_ai.runtime.bus; without text content ChannelBridgeError is raised. |
Returns: Inbound. A Inbound: An inbound message, whatever bus produced it.
Raises: ChannelBridgeError.
Class ChannelBridge
Relay between a Navin channel adapter and the channel name of the platform.
Attributes:
| Name | Type | Required | Description |
|---|---|---|---|
adapter | tuple[str, str] | yes | Module and class of the Navin adapter, split from spec.connection.adapter ("<module>:<class>"). |
channel | yes | The channel as returned by channels.get(name). | |
client | yes | Platform client used for the channel, runs and sessions calls. | |
connection | yes | The spec.connection of the channel manifest: provider, adapter, settings, secret_refs. | |
name | yes | Name of the bridged platform channel. | |
outbound_factory | yes | Function building the outbound messages published on the bus. | |
poll_interval | yes | Seconds between two reads of the run state. | |
resolve_secret | yes | Function resolving the secret references of the connection. | |
timeout | yes | Maximum wait in seconds for a run to stop. |
Constructor ChannelBridge
ChannelBridge(client: Any, name: str, resolve_secret: Callable[[str], str] = env_resolver, outbound_factory: Callable[[str, str, str, dict[str, Any]], Any] | None = None, poll_interval: float = 1.0, timeout: float = 300.0) -> None
Read the channel name and keep its spec.connection; raises ChannelBridgeError when it is not a Navin connection (provider: navin, adapter: "<module>:<class>").
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
client | Any | yes | Parent client. | |
name | str | yes | Name of the platform channel to bridge. | |
resolve_secret | Callable[[str], str] | env_resolver | no | Function turning a secret reference of secret_refs into its value; default env_resolver (env://NAME only). |
outbound_factory | Callable[[str, str, str, dict[str, Any]], Any] | None | None | no | Builds the outbound message from (channel, chat_id, content, metadata); default a BusMessage sent by assistant. |
poll_interval | float | 1.0 | no | Seconds between two reads of the run state while waiting for the replies (default 1). |
timeout | float | 300.0 | no | Maximum wait in seconds for the run to stop (default 300); past it ChannelBridgeError is raised. |
Raises: ChannelBridgeError.
ChannelBridge.adapter_config
adapter_config() -> dict[str, Any]
Configuration of the Navin adapter: settings plus resolved secrets, enabled true. Dotted names (dm.allowFrom) become nested objects, as the Navin configuration expects.
This element takes no parameter.
Returns: dict[str, Any]. Configuration dict given to the adapter class.
ChannelBridge.handle
async handle(message: Any, bus: Any) -> dict[str, Any]
Relay one message and publish the replies on bus (publish_outbound).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
message | Any | yes | Inbound message of the bus, read by attribute (content, sender_id, chat_id, metadata). | |
bus | Any | yes | Message bus of the adapter; replies go out through its publish_outbound. |
Returns: dict[str, Any]. Answer of POST /v1/channels/{name}/inbound (session_id, run_id, message_id).
ChannelBridge.load_adapter
load_adapter(bus: Any, config_factory: Callable[[dict[str, Any]], Any] | None = None) -> Any
Instantiate the Navin adapter class (navin.channels.<module>) on bus; needs the navin package.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
bus | Any | yes | Message bus given to the adapter. | |
config_factory | Callable[[dict[str, Any]], Any] | None | None | no | Optional function turning the adapter_config dict into the configuration object the adapter expects. |
Returns: Any. The adapter instance; ChannelBridgeError when the navin channels are not installed.
Raises: ChannelBridgeError.
ChannelBridge.relay
relay(message: Any) -> dict[str, Any]
Post an inbound message. Delivers a message from an end user (202) and returns session_id, session_created, message_id, run_id (or run_skipped when the agent is not active) and the DLP result. Needs tenant_admin, developer or agent. Steps: 1. The channel must be active (409 channel_disabled); a signed_webhook channel checks X-EAI-Signature (t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>." + raw body>, 5 minute window; 401 invalid_signature). 2. The policy channel.inbound is evaluated; size (413 message_too_large) and rate per user (429 rate_limited) are checked. 3. Inbound DLP runs (default detect; block answers 403 dlp_blocked, mask stores the masked text). 4. The open session of the user and conversation is reused, or a new one opened (429 too_many_sessions, 409 session_closed past max_session_minutes). 5. The message is added and a run of the channel agent starts with trigger channel.
Route: /v1/channels/{name}/inbound (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
message | Any | yes | Status message (up to 2000 characters). |
Returns: dict[str, Any]. Decoded JSON answer of the operation "Post an inbound message".
Raises: the typed errors of the transport (Errors).
ChannelBridge.replies
replies(accepted: dict[str, Any]) -> list[str]
Assistant messages of the session written after the inbound message, once the run stopped.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
accepted | dict[str, Any] | yes | Answer of the inbound call, with session_id, run_id and message_id. |
Returns: list[str]. Texts of the replies in order; empty when the answer has no session or run.
Raises: ChannelBridgeError.
ChannelBridge.run
async run(bus: Any, stop: asyncio.Event | None = None) -> None
Consume bus.consume_inbound() until stop is set, relaying every message.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
bus | Any | yes | Message bus to consume (consume_inbound) and to answer on (publish_outbound). | |
stop | asyncio.Event | None | None | no | asyncio.Event that ends the loop once set; default a new event never set. |
Returns: None.
Functions
env_resolver
env_resolver(ref: str) -> str
Resolve env://NAME from the process environment.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ref | str | yes | Secret reference, env://NAME; any other scheme raises ChannelBridgeError. |
Returns: str. Value of the environment variable; ChannelBridgeError when it is not set.
Raises: ChannelBridgeError.