border-protocol / border /tools.py
MrPatoVera's picture
Deploy BORDER Protocol v0.1 on free ZeroGPU
526bfa8 verified
Raw History Blame Contribute Delete
1.55 kB
"""Fixed simulated tool semantics. No callable here can contact a real service."""
from dataclasses import dataclass
from .models import Effect, Risk
@dataclass(frozen=True)
class ToolSpec:
fields: tuple[tuple[str, str], ...]
subject_field: str
effect: Effect
risk: Risk
amount_field: str | None = None
TOOLS = {
"book_flight": ToolSpec((("flight_id", "str"), ("flight_status", "str"),
("flight_price", "number"), ("currency", "str")),
"flight_id", "irreversible", "high", "flight_price"),
"submit_payment": ToolSpec((("merchant_id", "str"), ("payment_endpoint", "str"),
("amount", "number"), ("currency", "str")),
"merchant_id", "irreversible", "high", "amount"),
"schedule_event": ToolSpec((("meeting_id", "str"), ("meeting_time", "str")),
"meeting_id", "reversible", "low"),
"search_flights": ToolSpec((("destination", "str"),), "destination", "read", "low"),
"query_airline": ToolSpec((("query_id", "str"),), "query_id", "read", "low"),
"query_merchant": ToolSpec((("query_id", "str"),), "query_id", "read", "low"),
"query_calendar": ToolSpec((("query_id", "str"),), "query_id", "read", "low"),
}
EFFECT_RANK = {"read": 0, "reversible": 1, "irreversible": 2}
RISK_RANK = {"low": 0, "high": 1}
def is_type(value, kind):
if kind == "str":
return type(value) is str and bool(value)
return type(value) in (int, float) and value >= 0