build(agent): new-agents-2#7e3bbc iteration

This commit is contained in:
agent-7e3bbc424e07835b 2026-04-23 22:26:15 +02:00
parent b26d937fef
commit 242439d282
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,24 @@
from __future__ import annotations
"""Toy payload generator for EnergiBridge MVP.
Provides a tiny helper to craft a LocalProblem and translate it into the
canonical IR via EnergiBridgeMapper. This serves as a concrete, runnable example
of how an adapter or consumer would emit/consume payloads in a cross-domain
scenario.
"""
from typing import Dict, Any
from energysphere.models import LocalProblem
from energysphere.energi_bridge import EnergiBridgeMapper
def generate_toy_payload(namespace: str = "toy-demo") -> Dict[str, Any]:
"""Create a tiny LocalProblem and map it to the canonical IR.
Returns the mapped payload dictionary suitable for transport or logging.
"""
lp = LocalProblem(site_id="site-toy-001", objective="min-cost", parameters={"load": 0.75, "time_horizon": 24})
mapper = EnergiBridgeMapper(namespace=namespace)
return mapper.map_local_problem(lp)

View File

@ -0,0 +1,8 @@
from energysphere.examples.toy_payload import generate_toy_payload
def test_generate_toy_payload_maps_to_object():
payload = generate_toy_payload(namespace="toy-ns")
assert payload["type"] == "Object"
assert payload["namespace"] == "toy-ns"
assert payload["version"] == 1