Skip to main content

Typed interfaces for building CortexFlow plugins, tools, and channel adapters — no gateway dependencies required.

Project description

cortexflow-sdk

Typed interfaces for building CortexFlow plugins — without installing the full gateway.

CortexFlow's gateway depends on FastAPI, Redis, Qdrant, and SDKs for all 14 supported channels. None of that is needed to write a plugin — only to run the gateway that loads it. This package contains just the three base classes a plugin author needs, with zero third-party dependencies.

Install

pip install cortexflow-sdk

Writing a plugin

Every plugin package registers a Plugin subclass via a cortexflow.plugins entry point:

# my_plugin/plugin.py
from cortexflow_sdk import Plugin, PluginMetadata, Tool, ToolResult


class WeatherTool(Tool):
    name = "get_weather"
    description = "Get the current weather for a city."
    parameters = {
        "city": {"type": "str", "description": "City name", "required": True},
    }
    permissions = ["network"]

    async def execute(self, city: str) -> ToolResult:
        # ... call a weather API ...
        return ToolResult(tool=self.name, output=f"Sunny in {city}")


class WeatherPlugin(Plugin):
    metadata = PluginMetadata(
        name="cortexflow-weather",
        version="1.0.0",
        plugin_type="tool",
        description="Adds a get_weather tool.",
        permissions=["network"],
    )

    def get_tools(self):
        return [WeatherTool()]
# my_plugin/pyproject.toml
[project.entry-points."cortexflow.plugins"]
cortexflow-weather = "my_plugin.plugin:WeatherPlugin"

Once published to PyPI and installed alongside the CortexFlow gateway, cortex plugin add cortexflow-weather discovers and loads it.

Plugin types

plugin_type Implement Contributes
tool get_tools() One or more Tool instances
channel get_channel_adapter() A ChannelAdapter instance
tts / stt / memory Loaded by name; see gateway docs
generic on_load() / on_unload() Lifecycle hooks only

Writing a channel adapter plugin

from cortexflow_sdk import ChannelAdapter, InboundMessage


class MyChannelAdapter(ChannelAdapter):
    channel_id = "my_channel"

    async def connect(self) -> None: ...
    async def disconnect(self) -> None: ...
    async def send(self, target, text, *, reply_to=None, attachments=None):
        ...

    async def _on_platform_event(self, raw_event: dict) -> None:
        await self._dispatch(InboundMessage(
            channel=self.channel_id,
            sender_id=raw_event["user_id"],
            sender_name=raw_event["user_name"],
            text=raw_event["text"],
        ))

License

MIT

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

cortexflow_sdk-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cortexflow_sdk-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file cortexflow_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: cortexflow_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cortexflow_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 30dea69c513a40576ef7ba29356796f2ba78266a125b77fecb2eebc7bcf34dd9
MD5 000af1e75dedbc7d3b6d65b92475d028
BLAKE2b-256 1a94cda53486e5bc3b3034cb6c01012f49e39e7a8ac2f30e6ab5adc12673654e

See more details on using hashes here.

File details

Details for the file cortexflow_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cortexflow_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cortexflow_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a44716af0b33fae1b373f99643022dcef59b3415f4db2a8a953b68c501d27650
MD5 4faf87206bc1265da6f9b50cad4a0b0c
BLAKE2b-256 6a8593be50cb94753a60a198646bdc5a40b3525569ed3937443b694e90e94b4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page