haive.core.config.auth_runnableΒΆ

Haive-specific extension of runnable config management with PostgreSQL integration.

from typing import Any This module extends RunnableConfigManager to provide both Supabase authentication integration and PostgreSQL persistence support for the Haive framework. It creates a unified configuration system that handles authentication, session management, and database persistence in a cohesive manner.

The HaiveRunnableConfigManager inherits all functionality from the base RunnableConfigManager while adding specialized methods for Supabase user authentication, thread persistence, and PostgreSQL integration. This design ensures proper user context is maintained throughout conversation threads and persisted correctly in PostgreSQL.

Classes:

HaiveRunnableConfigManager: Extended config manager with Supabase auth and PostgreSQL integration

Example:

Examples

>>> # Create a config with Supabase authentication
>>> config = HaiveRunnableConfigManager.create_with_auth(
>>> supabase_user_id="auth0|1234567890",
>>> username="john.doe",
>>> email="john.doe@example.com"
>>> )
>>>
>>> # Add PostgreSQL persistence information
>>> config = HaiveRunnableConfigManager.add_persistence_info(
>>> config,
>>> db_session_id="pgsql-session-123",
>>> persistence_type="postgres"
>>> )
>>>
>>> # Add engine-specific configuration
>>> config = HaiveRunnableConfigManager.add_engine_config(
>>> config,
>>> "my_llm_engine",
>>> temperature=0.7
>>> )

ClassesΒΆ

HaiveRunnableConfigManager

Enhanced runnable config manager with Supabase authentication and PostgreSQL integration.

Module ContentsΒΆ

class haive.core.config.auth_runnable.HaiveRunnableConfigManager[source]ΒΆ

Bases: haive.core.config.runnable.RunnableConfigManager

Enhanced runnable config manager with Supabase authentication and PostgreSQL integration.

Extends the base RunnableConfigManager with methods for Supabase user authentication, enhanced session management, and PostgreSQL persistence configuration. This class provides a unified interface for managing authentication context and database persistence throughout the Haive framework.

Key capabilities: - Authentication context management with Supabase user IDs - Session tracking with user-agent associations - Thread persistence configuration for PostgreSQL - Permission and authorization management - Serialization utilities for database storage

static add_engine_by_id(config, engine_id, **params)[source]ΒΆ

Add configuration specifically targeting an engine by ID.

Parameters:
  • config (langchain_core.runnables.RunnableConfig) – RunnableConfig to update

  • engine_id (str) – Engine ID to target

  • **params – Parameters for the engine

Returns:

Updated RunnableConfig

Return type:

langchain_core.runnables.RunnableConfig

static add_permissions(config, *permissions)[source]ΒΆ

Add permissions to the configuration.

Parameters:
  • config (langchain_core.runnables.RunnableConfig) – RunnableConfig to update

  • *permissions (str) – Permissions to add

Returns:

Updated RunnableConfig

Return type:

langchain_core.runnables.RunnableConfig

static add_persistence_info(config, db_session_id=None, persistence_type='postgres', db_pool_id=None, checkpoint_ns='', **persistence_params)[source]ΒΆ

Add PostgreSQL persistence information to a config.

Parameters:
  • config (langchain_core.runnables.RunnableConfig) – Existing RunnableConfig to update

  • db_session_id (str | None) – Optional database session identifier

  • persistence_type (str) – Type of persistence (postgres, memory, etc.)

  • db_pool_id (str | None) – Optional connection pool identifier

  • checkpoint_ns (str) – Checkpoint namespace for organizing checkpoints

  • **persistence_params – Additional persistence parameters

Returns:

Updated RunnableConfig with persistence information

Return type:

langchain_core.runnables.RunnableConfig

static create_agent_session(supabase_user_id, agent_id, agent_type=None, session_data=None, thread_id=None, **kwargs)[source]ΒΆ

Create a session configuration for agent interaction.

Parameters:
  • supabase_user_id (str) – The Supabase/Auth0 user ID

  • agent_id (str) – Unique identifier for the agent

  • agent_type (str | None) – Optional type of agent

  • session_data (dict[str, Any] | None) – Optional additional session data

  • thread_id (str | None) – Optional thread ID (generated if not provided)

  • **kwargs – Additional parameters

Returns:

RunnableConfig with session information

Return type:

langchain_core.runnables.RunnableConfig

static create_thread_checkpoint_config(thread_id, checkpoint_id=None, checkpoint_ns='', **kwargs)[source]ΒΆ

Create a minimal config for checkpoint operations with thread ID.

Parameters:
  • thread_id (str) – Thread ID for the conversation

  • checkpoint_id (str | None) – Optional specific checkpoint ID

  • checkpoint_ns (str) – Checkpoint namespace

  • **kwargs – Additional parameters

Returns:

RunnableConfig suitable for checkpoint operations

Return type:

langchain_core.runnables.RunnableConfig

static create_with_auth(supabase_user_id, username=None, email=None, tenant_id=None, permissions=None, thread_id=None, **kwargs)[source]ΒΆ

Create a RunnableConfig with Supabase authentication information.

Parameters:
  • supabase_user_id (str) – The Supabase/Auth0 user ID

  • username (str | None) – Optional username for user identification

  • email (str | None) – Optional email address for user identification

  • tenant_id (str | None) – Optional tenant/organization ID for multi-tenant systems

  • permissions (list[str] | None) – Optional list of user permissions

  • thread_id (str | None) – Optional thread ID for persistence (generated if not provided)

  • **kwargs – Additional parameters to include in configurable section

Returns:

A properly structured RunnableConfig with authentication information

Return type:

langchain_core.runnables.RunnableConfig

static create_with_postgres(thread_id=None, user_id=None, db_connection_info=None, checkpoint_ns='', **kwargs)[source]ΒΆ

Create a config with PostgreSQL persistence configuration.

Parameters:
  • thread_id (str | None) – Optional thread ID (generated if not provided)

  • user_id (str | None) – Optional user ID for authentication context

  • db_connection_info (dict[str, Any] | None) – Optional database connection parameters

  • checkpoint_ns (str) – Checkpoint namespace for organizing checkpoints

  • **kwargs – Additional parameters to include in configurable section

Returns:

RunnableConfig with PostgreSQL persistence configuration

Return type:

langchain_core.runnables.RunnableConfig

static deserialize_from_json(json_str)[source]ΒΆ

Deserialize a RunnableConfig from a JSON string.

Parameters:

json_str (str) – JSON string to deserialize

Returns:

Deserialized RunnableConfig

Return type:

langchain_core.runnables.RunnableConfig

static get_auth_info(config)[source]ΒΆ

Extract authentication information from a RunnableConfig.

Parameters:

config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from

Returns:

Authentication information dictionary or empty dict if not found

Return type:

dict[str, Any]

static get_checkpoint_id(config)[source]ΒΆ

Extract checkpoint ID from a RunnableConfig.

Parameters:

config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from

Returns:

Checkpoint ID if present, otherwise None

Return type:

str | None

static get_checkpoint_ns(config)[source]ΒΆ

Extract checkpoint namespace from a RunnableConfig.

Parameters:

config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from

Returns:

Checkpoint namespace or empty string if not found

Return type:

str

static get_persistence_info(config)[source]ΒΆ

Extract persistence information from a RunnableConfig.

Parameters:

config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from

Returns:

Persistence information dictionary or empty dict if not found

Return type:

dict[str, Any]

static get_session_info(config)[source]ΒΆ

Extract session information from a RunnableConfig.

Parameters:

config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from

Returns:

Session information dictionary or empty dict if not found

Return type:

dict[str, Any]

static get_supabase_user_id(config)[source]ΒΆ

Extract Supabase user ID from a RunnableConfig.

Parameters:

config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from

Returns:

Supabase user ID if present, otherwise None

Return type:

str | None

static has_permission(config, permission)[source]ΒΆ

Check if the configuration has a specific permission.

Parameters:
  • config (langchain_core.runnables.RunnableConfig) – RunnableConfig to check

  • permission (str) – Permission to check for

Returns:

True if the permission is present, False otherwise

Return type:

bool

static is_postgres_persistence(config)[source]ΒΆ

Check if a config is using PostgreSQL persistence.

Parameters:

config (langchain_core.runnables.RunnableConfig) – RunnableConfig to check

Returns:

True if PostgreSQL persistence is configured, False otherwise

Return type:

bool

static serialize_to_json(config)[source]ΒΆ

Serialize a RunnableConfig to a JSON string.

Parameters:

config (langchain_core.runnables.RunnableConfig) – RunnableConfig to serialize

Returns:

JSON string representation

Return type:

str

static update_auth_info(config, **auth_updates)[source]ΒΆ

Update authentication information in an existing config.

Parameters:
  • config (langchain_core.runnables.RunnableConfig) – Existing RunnableConfig to update

  • **auth_updates – Authentication information to update

Returns:

Updated RunnableConfig

Return type:

langchain_core.runnables.RunnableConfig

static update_checkpoint_id(config, checkpoint_id)[source]ΒΆ

Update the checkpoint ID in a config.

Parameters:
  • config (langchain_core.runnables.RunnableConfig) – RunnableConfig to update

  • checkpoint_id (str) – New checkpoint ID

Returns:

Updated RunnableConfig

Return type:

langchain_core.runnables.RunnableConfig

static update_session_status(config, status)[source]ΒΆ

Update session status in the configuration.

Parameters:
  • config (langchain_core.runnables.RunnableConfig) – RunnableConfig to update

  • status (str) – New session status

Returns:

Updated RunnableConfig

Return type:

langchain_core.runnables.RunnableConfig