Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ packages = [{include = "omnibase_infra", from = "src"}]
[tool.poetry.scripts]
omni-infra = "omnibase_infra.cli.commands:cli"
onex-runtime = "omnibase_infra.runtime.kernel:main"
emit-daemon = "omnibase_infra.runtime.emit_daemon.cli:main"

[tool.poetry.dependencies]
python = "^3.12"
Expand Down
4 changes: 4 additions & 0 deletions src/omnibase_infra/event_bus/event_bus_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ async def handler(msg):
Protocol Compatibility:
This class implements ProtocolEventBus from omnibase_core using duck typing
(no explicit inheritance required per ONEX patterns).

TODO: Consider formalizing the EventBusKafka interface as a Protocol
(ProtocolEventBusKafka) in the future to enable better static type checking
and IDE support for consumers that depend on Kafka-specific features.
"""

from __future__ import annotations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from __future__ import annotations

from datetime import UTC, datetime, timezone
from datetime import UTC, datetime

from pydantic import BaseModel, ConfigDict, Field, field_validator

Expand Down
97 changes: 97 additions & 0 deletions src/omnibase_infra/runtime/emit_daemon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 OmniNode Team
"""Hook Event Daemon - Event emission infrastructure for OmniClaude hooks.

This package provides the daemon and supporting infrastructure for emitting
events from OmniClaude hooks to Kafka topics.

Components:
- EmitDaemon: Unix socket server for persistent Kafka event emission
- EmitClient: Client for emitting events via the daemon
- EventRegistry: Maps event types to Kafka topics with metadata injection
- ModelEventRegistration: Configuration model for event type mappings
- ModelEmitDaemonConfig: Configuration model for the daemon
- BoundedEventQueue: In-memory queue with disk spool overflow
- ModelQueuedEvent: Event model for queued events

Example Usage:
```python
from omnibase_infra.runtime.emit_daemon import (
EmitClient,
EmitDaemon,
EventRegistry,
ModelEmitDaemonConfig,
ModelEventRegistration,
emit_event,
)

# Client usage (recommended for hooks)
async with EmitClient() as client:
event_id = await client.emit("prompt.submitted", {"prompt_id": "abc123"})

# Or use convenience function
event_id = await emit_event("prompt.submitted", {"prompt_id": "abc123"})

# Daemon usage (for running the server)
config = ModelEmitDaemonConfig(
kafka_bootstrap_servers="kafka:9092",
)
daemon = EmitDaemon(config)
await daemon.start()
await daemon.run_until_shutdown()

# Or use the registry directly
registry = EventRegistry(environment="dev")
topic = registry.resolve_topic("prompt.submitted")
```
"""

from omnibase_infra.runtime.emit_daemon.cli import main as cli_main
from omnibase_infra.runtime.emit_daemon.client import (
EmitClient,
EmitClientError,
emit_event,
emit_event_with_fallback,
)
from omnibase_infra.runtime.emit_daemon.config import ModelEmitDaemonConfig
from omnibase_infra.runtime.emit_daemon.daemon import EmitDaemon
from omnibase_infra.runtime.emit_daemon.event_registry import (
EventRegistry,
ModelEventRegistration,
)
from omnibase_infra.runtime.emit_daemon.model_daemon_request import (
ModelDaemonEmitRequest,
ModelDaemonPingRequest,
parse_daemon_request,
)
from omnibase_infra.runtime.emit_daemon.model_daemon_response import (
ModelDaemonErrorResponse,
ModelDaemonPingResponse,
ModelDaemonQueuedResponse,
parse_daemon_response,
)
from omnibase_infra.runtime.emit_daemon.queue import (
BoundedEventQueue,
ModelQueuedEvent,
)

__all__: list[str] = [
"BoundedEventQueue",
"EmitClient",
"EmitClientError",
"EmitDaemon",
"EventRegistry",
"ModelDaemonEmitRequest",
"ModelDaemonErrorResponse",
"ModelDaemonPingRequest",
"ModelDaemonPingResponse",
"ModelDaemonQueuedResponse",
"ModelEmitDaemonConfig",
"ModelEventRegistration",
"ModelQueuedEvent",
"cli_main",
"emit_event",
"emit_event_with_fallback",
"parse_daemon_request",
"parse_daemon_response",
]
Loading