# SupportMCP code mode

Use this when you need **bulk TicketApp data** and only a **selected shape** should enter context.

Named tools stay for one ticket, one note, one close, one reassign.

## Tools

| Tool | Purpose |
|------|---------|
| `ticketapp_search` | Find read tools and shape names |
| `ticketapp_execute` | Run read-only JS. Only the `return` value enters context |

**Wall-clock timeout: 180000 ms (3 minutes).** Constant `CODE_MODE_TIMEOUT_MS`.

## Rules

1. Execute is **read-only**. Writes (`post_ticket_note`, `close_ticket`, `reassign_ticket`, intake, tags) stay named tools.
2. Call `tools.<readTool>(args)` then filter/project. Do not return the raw bulk.
3. Must `return` a JSON value.
4. Caps fail loud: 8 upstream calls, 32 KiB, 200 rows.
5. HOS 5-minute cycle: use shape `hos_cycle_roster`. Do **not** call `list_support_tickets` + `list_overdue_tickets` + `list_tickets_by_user`.
6. Tool names inside the sandbox are **unprefixed** (`tools.hos_list_ticket_population`). An optional OpenCode/MCP `ticketapp_` prefix is also accepted and normalized to the same registry name (DEV-32).

## Shapes

Copy a script from `scripts/` into `ticketapp_execute.code`, or pass `shape` and `params`.

| Shape | When |
|-------|------|
| `hos_cycle_roster` | HOS roster (one `hos_list_ticket_population`) |
| `customer_closed_history` | Closed tickets for a customer + `from`/`to` |
| `overdue_support` | Overdue Support rows from the population |

## Example

```json
ticketapp_execute({ "shape": "hos_cycle_roster" })
```

```json
ticketapp_execute({
  "shape": "customer_closed_history",
  "params": { "customerId": 7457, "from": "2026-05-30", "to": "2026-07-31" }
})
```
