Examples · learn/19-capabilities · 240 of 339
shop.caps
tin run examples/learn/19-capabilities/shop.caps.tin/// Look up a price, in cents.
tool fn price(item: string): int => 300
/// Today's date, for the receipt.
tool fn today(): string => "{now()}"
/// Charge a card. A person approves every charge.
guarded tool fn charge(card: string, cents: int): string => "charged {cents}"
/// Answers questions about the menu. Read-only.
agent Menu { model: "mock", tools: [price] }
/// Takes orders and charges for them.
agent Till { model: "mock", tools: [Menu, today, charge] }
fn main() {
print(Till("charge 'visa' 300"))
}