Cookwala / حزمة التطوير والسيناريوهات / 071
A farm offer reaches a robot kitchen: from SMS to a dry run
The robot-kitchen flow starts with a cooperative's FARM message for 120 kg of tomatoes. Parse it, check the recorded offer, then dry-run salata baladi, a tomato dish, on an example hob robot.
اقرأ أولًا: /docs/HUMANITARIAN-PROFILE/ /humanitarian/
الخطوات
The message recorded in the offer's note.
parseSmsThe recorded offer passes the basic pack.
humanitarianCheckIt validates as a profile document.
validateDry-run salata baladi on the example hob robot with a person present.
dryRun
النتيجة
You have followed produce from a phone message to a plan a robot can check. Next: scenario 001 explains dry runs in depth.
سطر الأوامر
cookwala sms "FARM 120KG TOMATO A BB2411"
cookwala humanitarian examples/humanitarian/flows/robot-kitchen/offer.json
cookwala dryrun examples/salata-baladi.cookwala.json --device examples/capabilities/demo-hob-robot.json --human-presentالمخرجات المسجلة
الحالة: ok
[1] parseSms: {"ok": true, "command": "OFFER", "kg": 120.0, "item": "tomato", "storage": "ambient", "origin": "farm", "dateMark": {"kind": "best_before", "dayMonth": "24-11"}, "findings": []}
[2] humanitarianCheck: {"results": [{"id": "of-2026-11-20-rk-002", "kind": "Offer", "findings": []}]}
[3] validate: {"ok": true, "errors": []}
[4] dryRun: {"state": "accepted", "plan": [{"node": "n1", "op": "cw.op.wash", "by": "device", "verifiedBy": "time", "rung": "time"}, {"node": "n8", "op": "cw.op.wash", "by": "device", "verifiedBy": "time", "rung": "time"}, {"node": "n2", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n9", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n3", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n4", "op": "cw.op.whisk", "by": "device", "verifiedBy": "time", "rung": "…الكود
التشغيل: python scenarios/out/071-robot-kitchen-offer-from-a-farm/python.py
# Scenario 071: A farm offer reaches a robot kitchen: from SMS to a dry run
# The robot-kitchen flow starts with a cooperative's FARM message for 120 kg of tomatoes. Parse it, check the recorded offer, then dry-run salata baladi, a tomato dish, on an example hob robot.
# Run a hub first: python hub/cookwala_hub.py --recipes examples
import json, os
from cookwala.client import CookwalaClient, CookwalaProblem
def load(path):
with open(path, encoding="utf-8") as f:
return json.load(f)
def pick(obj, path):
for part in path.replace("]", "").replace("[", ".").split("."):
obj = obj[int(part)] if part.isdigit() else (len(obj) if part == "length" else obj.get(part))
return obj
c = CookwalaClient(os.environ.get("COOKWALA_HUB", "http://localhost:7878"))
# Step 1: The message recorded in the offer's note.
farm = c.parse_sms("FARM 120KG TOMATO A BB2411")
assert pick(farm, "origin") == "farm", pick(farm, "origin")
print("ok", "origin", "=", "farm")
assert pick(farm, "kg") == 120.0, pick(farm, "kg")
print("ok", "kg", "=", 120.0)
assert pick(farm, "findings.length") == 0, pick(farm, "findings.length")
print("ok", "findings.length", "=", 0)
# Step 2: The recorded offer passes the basic pack.
checked = c.humanitarian_check([{"profile": "0.2.0", "kind": "Offer", "id": "of-2026-11-20-rk-002", "donor": "did:web:farmcoop.example", "createdAt": "2026-11-20T05:30:00+02:00", "items": [{"lineId": "1", "name": "Tomatoes", "ingredientId": "cw.ing.tomato", "kg": 120, "storage": "ambient", "origin": "farm", "harvestedAt": "2026-11-19", "dateMark": {"kind": "best_before", "date": "2026-11-24"}, "allergens": []}], "window": {"from": "2026-11-20T06:00:00+02:00", "to": "2026-11-20T12:00:00+02:00"}, "site": {"country": "EG", "admin1": "Beheira", "siteName": "Cooperative packing shed"}, "state": "distributed", "version": 5, "note": "SMS: FARM 120KG TOMATO A BB2411"}], ["basic-nutrition-food-safety"])
assert pick(checked, "results[0].findings.length") == 0, pick(checked, "results[0].findings.length")
print("ok", "results[0].findings.length", "=", 0)
# Step 3: It validates as a profile document.
valid = c.validate("humanitarian", load("examples/humanitarian/flows/robot-kitchen/offer.json"))
assert pick(valid, "ok") == True, pick(valid, "ok")
print("ok", "ok", "=", True)
# Step 4: Dry-run salata baladi on the example hob robot with a person present.
plan = c.dry_run(recipe_id="salata-baladi", device_id="demo-hob-robot", human_present=True)
assert pick(plan, "state") == "accepted", pick(plan, "state")
print("ok", "state", "=", "accepted")
assert pick(plan, "plan.length") == 9, pick(plan, "plan.length")
print("ok", "plan.length", "=", 9)
print("scenario complete")