No description
Find a file
Dirk Hoyer a278463dee chore: Release v0.17.5
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 21:18:36 +01:00
ixt-public@eaf4205d72 chore: Update ixt-public submodule to include BlobStore schemas 2026-02-23 19:45:13 +01:00
ixt_sdk fix: add KV_CHANGE_NOTIFICATION to message type maps 2026-03-20 22:21:27 +01:00
tests feat: Migrate to Cap'n Proto serialization (Mission I140) 2025-12-24 19:39:46 +01:00
.gitignore fix: Load schemas directly from ixt-public submodule, remove copies 2026-02-17 22:27:42 +01:00
.gitmodules feat: Source IPC schemas from ixt-public submodule 2026-02-17 14:55:11 +01:00
__init__.py feat: Migrate to Cap'n Proto serialization (Mission I140) 2025-12-24 19:39:46 +01:00
BIDIRECTIONAL_IPC_GUIDE.md feat: Migrate to Cap'n Proto serialization (Mission I140) 2025-12-24 19:39:46 +01:00
example_with_services.py feat: Migrate to Cap'n Proto serialization (Mission I140) 2025-12-24 19:39:46 +01:00
LICENSE feat(sdk-python): Add MIT license for SDK distribution 2025-10-23 08:39:02 +02:00
README.md docs: Update documentation for multi-method service patterns (I151) 2026-02-27 13:13:21 +01:00
setup.py chore: Release v0.17.5 2026-03-24 21:18:36 +01:00

IXT Python SDK

Python SDK for building IXT modules that run as separate processes and communicate with the IXT runtime via Cap'n Proto IPC.

Features

  • Simple base class for module development
  • Cap'n Proto serialization for efficient IPC
  • Automatic IPC connection handling
  • Lifecycle management (init, handle, shutdown, health_check)
  • Base64 payload encoding/decoding helpers
  • Error handling and logging
  • Type hints for IDE support

Installation

# Install dependencies
pip install pycapnp>=1.0.0

# Install SDK
cd sdk/ixt-sdk-python
pip install -e .

Quick Start

1. Create Your Module

#!/usr/bin/env python3
from ixt_sdk import IxtProcessModule

class MyModule(IxtProcessModule):
    def on_init(self, config):
        """Initialize module with configuration"""
        self.db_url = config.get('database_url', 'sqlite:///data.db')
        self.log(f"Connecting to database: {self.db_url}")

    def on_handle(self, message, context):
        """Handle incoming messages"""
        # Tip: Use `ixt codegen schema.toml` to generate typed service proxies
        # that handle routing automatically. See examples/codegen/ for details.
        topic = message['topic']
        payload_data = self.decode_payload(message['payload'])

        if topic == 'my.service.process':
            result = self.process_data(payload_data)
            return self.success({'result': self.encode_payload(result)})
        else:
            return self.error('UNKNOWN_TOPIC', f'Unknown topic: {topic}')

    def on_shutdown(self):
        """Clean up resources"""
        self.log("Shutting down module")

    def on_health_check(self):
        """Report health status"""
        return {'healthy': True}

if __name__ == '__main__':
    MyModule().run()

2. Create Manifest

# manifest.toml
schema_version = "3.0"

[module]
name = "my-module"
version = "1.0.0"
description = "My IXT module"
runtime_targets = ["Process"]

[provides]
services = ["my.service"]

# Multi-method services are also supported:
# [services."my.service".methods.process]
# input = "ProcessRequest"
# output = "ProcessResponse"

3. Run Your Module

The IXT runtime spawns your module automatically. For development:

export IXT_IPC_SOCKET=/tmp/ixt-module.sock
export IXT_MODULE_ID=my-module:1.0.0/instance-001
python3 my_module.py

API Reference

IxtProcessModule Base Class

on_init(config: Dict[str, Any]) -> None

Initialize with configuration from the manifest.

on_handle(message: Dict, context: Dict) -> Dict

Handle incoming messages. Returns success or error response.

on_shutdown() -> None

Gracefully shutdown the module.

on_health_check() -> Dict (optional)

Report health status. Default returns {'healthy': True}.

Helper Methods

  • success(data: Dict = None) - Create success response
  • error(code: str, message: str) - Create error response
  • encode_payload(data: bytes) -> str - Encode binary as base64
  • decode_payload(payload: str) -> bytes - Decode base64 to binary
  • log(message: str) - Log to stderr

Requirements

  • Python 3.8+
  • pycapnp >= 1.0.0

License

MIT License