# Next Session: Annie Food Ordering — Continue from Cart Sync Test

## Context
Session 393 (2026-04-02) did deep research + prototype + live testing of Swiggy MCP and ADB food ordering. Read `memory/project_swiggy_mcp_integration.md` for ALL technical details.

## Where We Left Off
- **Cart sync test in progress**: MCP cart is empty, Pixel cart is empty. Need to:
  1. Add item via MCP (`update_food_cart` with `cartItems` array)
  2. Open Swiggy on Pixel (fresh launch)
  3. Check if item appears on Pixel → determines architecture

- **Previous test results** (3 rounds):
  - MCP → Pixel: did NOT sync (but old Pixel cart may have been interfering)
  - Pixel → MCP: DID sync
  - Phone → MCP: DID sync
  - **This final test with both empty will be definitive**

## Immediate TODO (in order)
1. **Complete cart sync test** (both empty now, add via MCP, check Pixel)
2. **Finish Zepto login** on Pixel (app installed, stopped at phone number entry)
3. **Finish Blinkit login** on Pixel (app installed, not started)
4. **Rewrite MCP prototype** to use raw httpx (SDK transport broken — see research doc)
5. **Call `your_go_to_items`** on Instamart MCP — get Rajesh's frequently bought groceries
6. **Build Telegram "order ready, send OTP" notification**
7. **ADB order history scraping** — read full order history from each app via accessibility tree
8. **Test full automated order with credit card OTP**

## Key Technical Details

### MCP Connection (WORKING)
```python
# Token at ~/.her-os/annie/mcp-tokens/swiggy_tokens.json (5-day expiry, no refresh)
headers = {
    'Authorization': f'Bearer {token}',
    'Content-Type': 'application/json',
    'Accept': 'application/json, text/event-stream',  # REQUIRED
}
# Initialize → notify → tools/call via raw httpx POST to https://mcp.swiggy.com/food
```

### MCP SDK DOES NOT WORK for transport
`sse_client` and `streamablehttp_client` both fail. Use raw `httpx.AsyncClient.post()` with JSON-RPC payloads. SDK OAuth (`OAuthClientProvider`) works fine for token acquisition.

### Add to Cart via MCP
```python
{'jsonrpc':'2.0','method':'tools/call','params':{'name':'update_food_cart','arguments':{
    'restaurantId':'70003',
    'addressId':'d4r3nu7mqkqe26kcujt0',
    'restaurantName':'Sangam Sweets',
    'cartItems':[{'menu_item_id':'100524671','quantity':1}]  # Bhel Puri
}},'id':4}
```

### MCP Endpoints (same token)
- Food: `https://mcp.swiggy.com/food` (16 tools)
- Instamart: `https://mcp.swiggy.com/im` (13 tools, has order history + your_go_to_items)
- Dineout: `https://mcp.swiggy.com/dineout` (untested)

### Pixel 9a (Panda via USB ADB)
- **Apps installed**: Swiggy (logged in), Zomato (logged in), Zepto (login pending), Blinkit (login pending)
- **Credentials on Panda** (`~/.her-os/annie/`): `.pixel_pin`, `.pixel_email`, `.pixel_email_password` (all 0600)
- **Screen timeout**: 10 min (`settings put system screen_off_timeout 600000`)
- **Unlock**: `adb shell input keyevent KEYCODE_POWER && sleep 2 && adb shell input swipe 540 1800 540 600 300 && sleep 1 && adb shell input text "$(cat ~/.her-os/annie/.pixel_pin)" && adb shell input keyevent KEYCODE_ENTER`
- **Saved credit card**: IDFC VISA •••• 2041 (visible on payment page)
- **MCP payment**: COD only. Credit card payment ONLY via app (ADB).

### Rajesh's Swiggy Info
- Address ID (Home HSR): `d4r3nu7mqkqe26kcujt0`
- Phone: +917899218911
- Last restaurant order: March 11, 2026
- Last Instamart order: March 30, 2026 (via MCP), April 1 (per Rajesh, not in MCP)
- Sangam Sweets ID: 70003

### Prices
MCP prices are in RUPEES (not paise). ₹140 = ₹140. Some have decimals (₹319.05).

## Files to Read
- `memory/project_swiggy_mcp_integration.md` — COMPLETE working config, all gotchas
- `docs/RESEARCH-SWIGGY-MCP-INTEGRATION.md` — Human-readable research doc
- `scripts/prototypes/swiggy_prototype.py` — OAuth + CLI (needs raw httpx rewrite)
- `scripts/prototypes/reports/swiggy_capability_report.json` — Food tools
- `scripts/prototypes/reports/swiggy_instamart_capability_report.json` — Instamart tools
- `~/.claude/plans/curried-seeking-porcupine.md` — Full plan (adversarially reviewed)

## Commits This Session
`83690b0` research docs | `0ad5e04` prototype | `599c5c4` transport fix + 40 tests | `01fe3ff` capability report | `5df538c` Instamart | `04a79bf` integration guide | `4bfead0` food history limitation | `ff1ae1c` ADB history decision | `94c69e8` price format | `1c86045` COD confirmed | `512f025` cart sync + card | `18a5555` one-way sync
