Skip to main content

maivn-shared

Shared contracts, models, utilities, and logging primitives for the mAIvn platform.

Overview

maivn-shared is the public shared package used by the mAIvn SDK and service repos. It provides the shared domain entities, configuration models, serialization helpers, event contracts, and logging abstractions that need to stay consistent across the platform.

Key Design Principles:

  • ✅ Environment-agnostic (no environment variable access)
  • ✅ Immutable configuration objects
  • ✅ Type-safe Pydantic models
  • ✅ Proper dependency inversion
  • ✅ Zero external service dependencies

Ecosystem

maivn-shared provides the shared contracts in the mAIvn developer ecosystem. Learn more at maivn.io — or dive into the developer hub at developer.maivn.io.

flowchart TD
    platform["mAIvn platform<br/>hosted agent API"]
    sdk["maivn<br/>Python SDK — agents · tools · swarms"]
    shared["maivn-shared<br/>shared contracts & models"]
    tools["maivn-tools<br/>optional connector toolsets"]
    studio["maivn-studio<br/>local studio — run & debug demos"]

    sdk -->|HTTPS + API key| platform
    sdk -->|depends on| shared
    tools -->|add_toolset| sdk
    studio -->|maivn studio CLI| sdk

    classDef current fill:#dbeafe,stroke:#2563eb,stroke-width:2px;
    class shared current;

Installation

# Using uv (recommended)
uv add maivn-shared

# Using pip
pip install maivn-shared

Architecture

maivn-shared/
├── domain/          # Pure business entities (no external dependencies)
│   └── entities/    # Pydantic models for tasks, tools, sessions, etc.
├── core/            # Application services
│   ├── config/      # Configuration management
│   ├── data/        # Data utilities (UUID generation)
│   └── http/        # HTTP client
└── infrastructure/  # Factories and adapters
    └── factories/   # Object creation logic

Domain Layer

Pure business entities with no external dependencies:

  • Tasks: Planning-time task models (Task, TaskList, TaskToolCall)
  • Tools: Tool specifications and execution models (ToolSpec, ToolExecutionCall)
  • Sessions: Session request/response models
  • Messages: LangChain message wrappers
  • Dependencies: Tool dependency models (agent, tool, data, user)
  • Status: Lifecycle status enumeration

Core Layer

Application services and utilities:

  • ConfigManager: Factory for creating HTTPConfig and ServerConfig
  • HTTPClient: Unified HTTP client with proper error handling
  • UUID utilities: Deterministic and random UUID generation
  • ArgumentResolver: Resolves TaskReferences, DataReferences, and ArgValues in task arguments
  • MessageFilter: Filters messages and events for client consumption
  • constants: Shared non-sensitive constants (timeouts, separators, etc.)

Infrastructure Layer

Factories and adapters:

  • TaskExecutionCallFactory: Creates TaskExecutionCall instances from tasks

Usage Examples

Configuration Management

from maivn_shared.core import config

# Get HTTP configuration with defaults
http_config = config.get_http_config()

# Override specific values
http_config = config.get_http_config(
    timeout=30.0,
    max_retries=5
)

# Get server configuration
server_config = config.get_server_config(
    base_url="https://api.example.com"
)

HTTP Client

from maivn_shared.core import HTTPClient

client = HTTPClient(timeout=10.0)

# Make POST request
response = client.post(
    "https://api.example.com/endpoint",
    payload={"key": "value"}
)

# Make GET request
response = client.get("https://api.example.com/data")

Task Models

from maivn_shared.domain.entities import (
    Task,
    TaskList,
    TaskToolCall,
    ArgValue,
    TaskReference,
    Status
)

# Create a task
task = Task(
    index=0,
    status=Status.PENDING,
    tool_call=TaskToolCall(
        name="search_web",
        args={"query": ArgValue(value="python tutorial")}
    )
)

# Create task list
task_list = TaskList(items=[task])

# Check dependencies
deps = task.get_dependency_indices()
can_run = task.can_start(completed_task_indices=set())

Task Execution Calls

from maivn_shared import ToolSpec
from maivn_shared.domain.entities import Task, TaskList
from maivn_shared.infrastructure.factories import TaskExecutionCallFactory

# Define available tools
tools = [
    ToolSpec(
        tool_id="tool_1",
        agent_id="agent_1",
        name="search_web",
        description="Search the web",
        args_schema={"query": {"type": "string"}}
    )
]

# Create factory
factory = TaskExecutionCallFactory(tools=tools)

# Build execution call from task
execution_call = factory.build(task)

# Build from entire task list
call_list = factory.build_from_tasklist(task_list)

Argument Resolution

from maivn_shared import ArgumentResolver, TaskReference, DataReference, ArgValue

# Create resolver
resolver = ArgumentResolver()

# Resolve TaskReference
result = resolver.resolve(
    TaskReference(task_index=0),
    task_results={0: "search results"}
)
# Result: "search results"

# Resolve DataReference
result = resolver.resolve(
    DataReference(key_name="user_id"),
    private_data={"user_id": "user_123"}
)
# Result: "user_123"

# Resolve nested structure
args = {
    "query": TaskReference(task_index=0),
    "limit": 10,
    "user": DataReference(key_name="user_id")
}
resolved = resolver.resolve(
    args,
    task_results={0: "python tutorial"},
    private_data={"user_id": "user_123"}
)
# Result: {"query": "python tutorial", "limit": 10, "user": "user_123"}

# Convenience function for resolving all args
from maivn_shared import resolve_arguments
resolved_args = resolve_arguments(
    args,
    task_results={0: "value"},
    private_data={"key": "value"}
)

Message Filtering

from maivn_shared import MessageFilter, HumanMessage, AIMessage, SystemMessage

messages = [
    HumanMessage(content="Hello"),
    SystemMessage(content="System prompt"),
    AIMessage(content="Hi there!")
]

# Filter for client messages only (human + AI)
filtered = MessageFilter.filter_client_messages(messages)
# Result: [HumanMessage(...), AIMessage(...)]

# Filter by specific types
filtered = MessageFilter.filter_messages_by_type(
    messages,
    allowed_types={"human", "system"}
)

# Filter event data
event = {
    "results": ["result1"],
    "messages": [...],
    "metadata": {...},
    "_internal": {...}  # filtered out
}
filtered_event = MessageFilter.filter_update_event(event)

Constants

from maivn_shared import constants

# Use shared constants
timeout = constants.DEFAULT_TASK_TIMEOUT_SECONDS
separator = constants.INPUT_SEPARATOR

Logging

from maivn_shared import get_logger

# Initialize with file logging (first call only)
logger = get_logger(log_file_path="/path/to/logs/agent_execution.log")

# Or initialize with console-only logging
logger = get_logger()  # No file logging, only console output

# Use logger
logger.log_session_start(
    session_id="session_123",
    assistant_id="assistant_1",
    thread_id="thread_1"
)

logger.log_task_execution(
    phase="completed",
    task_idx=0,
    tool_name="search_web",
    result={"results": [...]}
)

logger.log_session_end(session_id="session_123")

API Reference

Core Exports

from maivn_shared import (
    # Utilities
    ArgumentResolver,
    resolve_arguments,
    MessageFilter,
    constants,

    # Configuration
    ArgsSchema,
    HTTPConfig,
    ServerConfig,

    # Session
    SessionResponse,

    # Tools
    ToolExecutionCall,
    ToolSpec,
    ToolType,

    # Logging
    MaivnLogger,
    get_logger,
    get_optional_logger,
)

Domain Entities

from maivn_shared.domain.entities import (
    # Tasks
    Task,
    TaskList,
    TaskToolCall,
    TaskResult,
    ArgValue,
    DataReference,
    TaskReference,

    # Tools
    ToolSpec,
    ToolType,
    ToolExecutionCall,
    ToolExecutionCallList,

    # Sessions
    SessionRequest,
    SessionResponse,
    SessionStartupResponse,

    # Messages
    BaseMessage,
    HumanMessage,
    AIMessage,
    SystemMessage,
    ToolMessage,

    # Dependencies
    BaseDependency,
    AgentDependency,
    ToolDependency,
    DataDependency,
    InterruptDependency,

    # Status
    Status,
)

Core Services

from maivn_shared.core import (
    ArgumentResolver,    # Argument resolution utility
    resolve_arguments,   # Convenience function for arg resolution
    MessageFilter,       # Message/event filtering
    constants,           # Shared constants module
    config,              # Global ConfigManager instance
    ConfigManager,       # Configuration factory
    HTTPClient,          # HTTP client
    HTTPClientError,     # Base HTTP exception
    create_uuid,         # UUID generation
)

Infrastructure

from maivn_shared.infrastructure.factories import (
    TaskExecutionCallFactory,
)

Configuration

maivn-shared is intentionally environment-agnostic and does not read deployment-specific environment variables or configuration files. Applications should inject those values explicitly.

Development

Requirements

  • Python 3.10+
  • langchain-core >= 0.3.76

Code Quality

# Format code
ruff format .

# Lint code
ruff check .

# Type checking
pyright

Releases

  • CI runs on pull requests and pushes to main.
  • Publish PyPI runs on version tags that match v*.
  • Configure PyPI Trusted Publishing for this repository before the first release.
  • See DEPLOYMENT.md for the full GitHub and PyPI release procedure.

License

See LICENSE file in the repository root.

Related Packages

  • maivn: Public SDK that depends on maivn-shared
  • maivn-tools: Optional connector layer for the mAIvn SDK

Metadata

Release files for maivn-shared 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maivn-shared 0.4.3
File Size Uploaded Provenance
maivn_shared-0.4.3.tar.gz 187.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for maivn-shared 0.4.3
File Interpreter ABI Platform
maivn_shared-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 297.4 kB

Release files / maivn_shared-0.4.3.tar.gz

Download URL maivn_shared-0.4.3.tar.gz
Size 187.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e8a2f055a49e407d4e22cc099a4b79d0b5ae6e83fc98eab9d7ebbfc6d731cd73
BLAKE2b-256 checksum
How to use checksums
dfda9971a38a8044a46ba5ae1d86ad3c0448652a73b4552ab3c88d6fa020dd82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / maivn_shared-0.4.3-py3-none-any.whl

Download URL maivn_shared-0.4.3-py3-none-any.whl
Size 109.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e781771ce369625309ae223ddf514049d94689937c06d3e20d34698f85f9380
BLAKE2b-256 checksum
How to use checksums
7ef48c17d32bf5fbfbbcd1d07ac8e61fa058966e8988c7b34775b416008f24c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Security for maivn-shared 0.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for maivn_shared-0.4.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page