# Isolink interactive cards: format and scripts

This is the complete reference for Isolink cards: the JSON a card is made of, and the script language a scripted card runs. It is written so that a person or a language model can make a valid card from this file alone. The web versions, with pictures of each example, are at <https://isolink.app/docs/cards.html> and <https://isolink.app/docs/card-scripts.html>.

Every example here passes the app's own checks.

## Contents

1. What a card is
2. Getting a card into Isolink
3. The card format
4. Blocks
5. Answer values
6. Params
7. Pictures, assets and sites
8. Relay actions
9. Cards from relay bots
10. Codes and files
11. Card limits
12. Block card examples
13. Scripted cards: how a card runs
14. card(): the manifest
15. Actions and ctx
16. view() and me
17. Components and styles
18. Canvas and gestures
19. Pictures in scripts
20. Files and the device
21. Screens
22. Timers, pause and resume
23. Lanes and matches
24. Sounds, buzzes and keys
25. Bot slots
26. Web requests and ctx.bot
27. The language
28. Built-ins
29. Script limits
30. Errors and checks
31. Script examples
32. Prompt template
33. Common mistakes

## 1. What a card is

A card is a small interactive message in a chat: a poll, a sign-up sheet, a checklist, a feedback form, or a scripted game. Everyone in the chat gets the same card, and answers sync between their phones end-to-end encrypted, like messages. A card can also show people different things: its sender sees the answers to a private form while everyone else fills it in, and a block can be for some people only (sections 4 and 5).

There are two kinds:

- **Block cards** are a list of blocks (text, pictures, buttons, choices, checklists, text fields, star ratings, links). No code.
- **Scripted cards** carry a `script` in a small version of JavaScript. Every phone runs the same script on the same taps and reaches the same state.

## 2. Getting a card into Isolink

- **Card Studio**: You → My cards → +. Build a block card, or pick a scripted template.
- **Paste**: My cards → Import a card → Paste a card code. The app takes a card code (`isolink-card:…`) anywhere in the text, or the whole text as a card's plain JSON when it starts with `{`.
- **Open a file**: an `.isocard` file.
- **Send from a relay bot**: a fixed reply (`isolink-relay bot rule add … --card file.json`) or a language model's card tools. See section 9.
- **A relay's card library**: members publish cards there and others save or send them.

My cards keeps at most 200 cards.

## 3. The card format

A card is one JSON object. This is the app's own short form, used in chats, card codes and `.isocard` files. Relay bots also accept a longer form (section 9).

| Field | Type | Rules |
| --- | --- | --- |
| `v` | number | Format version. Write `1`. Ignored when reading. |
| `id` | string | **Required.** 1 to 40 characters from `A-Z a-z 0-9 _ -`. My cards keeps cards by id, so give each card its own. |
| `title` | string | **Required.** Not blank, at most 80 characters. |
| `emoji` | string | Optional. 1 to 8 Unicode code points, shown before the title. |
| `icon` | string | Optional. One of the icon names in section 14, shown for the card in My cards, the templates and a relay's card library. A scripted card names its icon in `card()` instead, which wins. A name this version doesn't know is left out, not refused. |
| `accent` | integer | Optional. The colour as a decimal ARGB integer, 0 to 4294967295. Always made opaque. Default `4284704497` (0xFF6366F1, indigo). To get one: 4278190080 + 0xRRGGBB. |
| `blocks` | array | Up to 30 blocks, shown in order (section 4). |
| `form` | object | Optional. Makes the card a form, with one button that sends every answer together (section 5). `{ "send": "Send answers", "to": "sender" }`: `send` is the button's label (1 to 40 characters, *Send* when left out); `to` is `"sender"` (only the card's sender gets the answers) or `"all"` (the default: everyone does). Any other `to` refuses the card. |
| `script` | string | Optional. A card script, up to 49,152 characters (sections 13 to 31). When present, the script draws the card. |
| `p` | object | Optional. Params: read-only values (section 6). At most 8 KB as JSON. |
| `as` | array | Optional. Up to 16 assets: pictures a script draws by id (section 7). |
| `sites` | array of strings | Optional. Up to 16 host names the card reaches, like `api.example.com`. |
| `act` | array | Optional. Up to 8 relay actions (section 8). |
| `src` | object | Set by the app on cards from a relay's library. Never write it. |

The app checks every card strictly when it arrives. A bad top-level field, or one past a limit, refuses the whole card. A single block that doesn't check out (an unknown kind, a choice with one option, a repeated block id, a button with no `a`) is dropped and the rest of the card shows.

## 4. Blocks

| Key | Meaning |
| --- | --- |
| `id` | **Required.** 1 to 40 of `A-Z a-z 0-9 _ -`, unique in the card. Answers are kept by block id. Never `_fb`: it is kept for scripted cards. |
| `k` | **Required.** The kind: `text`, `image`, `button`, `choice`, `checklist`, `input`, `rating` or `link`. |
| `t` | The words: text, label, question, heading, caption or title. At most 2,000 characters in a `text` block and 120 in the others. |
| `o` | Options or checklist items: an array of strings, none blank, each at most 120 characters. |
| `m` | `true` lets people pick more than one option of a `choice`. Default `false`. |
| `a` | A button's action, **required on buttons**: `respond`, `link` or `reply`. |
| `u` | A link block's or link button's address: `http://` or `https://`, at most 1,000 characters. On an image block without `img`, a picture the phone holds (below). |
| `img` | An image block's picture, base64: JPEG, PNG, GIF or WebP, at most 160 KB. |
| `h` | An input block's hint, at most 120 characters. |
| `for` | Who sees the block: `"sender"` (only whoever sent the card), `"others"` (everyone but the sender), or a list of 1 to 32 account ids (from the group info in section 6). Everyone, when left out. Anything else drops the block. |

| Kind | Needs | Optional |
| --- | --- | --- |
| `text` | `t`, not blank. Markdown: `**bold**`, `_italic_`, lists, links. | |
| `image` | `img`, or `u` naming a picture the phone holds: `avatar:` or `cover:` followed by an account id, `me`, `viewer` or `sender`; or `chat:` followed by a number (0 is the newest picture in the chat) or a message id. An `https://` address is not valid here. | `t` (caption) |
| `button` | `t` (label) and `a`. With `"a": "link"`, also `u`. | |
| `choice` | `o`: 2 to 12 options, all different. | `t` (question), `m` |
| `checklist` | `o`: 1 to 30 items. | `t` (heading) |
| `input` | `t` (question), not blank. | `h` |
| `rating` | `t` (question), not blank. Five stars. | |
| `link` | `u` | `t` (title; the host shows when empty) |

Button actions: `respond` records the tap as that person's answer and shows how many tapped; `link` opens `u`; `reply` starts a reply to the card in the chat. Fields a kind doesn't use are dropped. A card holds at most 3 image blocks. A picture the phone holds shows only after the person allows it.

A block with `for` shows only to those people: a thank-you for the people it's sent to (`"others"`), a note for the sender alone (`"sender"`). The block still travels in the card to everyone in the chat, so never put a secret in it.

## 5. Answer values

Answers are not part of the card. They travel separately, one per person per block, each with a time stamp; the newest wins.

| Block | Answer value |
| --- | --- |
| `button` with `respond` | The button's label, exactly. |
| `choice` | An array of option indexes from 0, sorted. One index unless `m` is true. An empty pick takes the answer back. |
| `input` | The words, trimmed, at most 500 characters. Empty takes it back. |
| `rating` | A whole number from 1 to 5. |
| `checklist` | Not an answer: each item has one shared state, ticked or not, set by whoever changed it last. |
| `text`, `image`, `link`, other buttons | No answers. |

`null` takes an answer back. Only the card's sender can close a card to answers, and open it again.

### Forms

A card with `form` is filled in as a form. Its choices, fields and stars keep what's picked and typed on the phone, with no send arrow of their own, until the one button at the bottom sends every answer at once (a question left empty sends `null`). Afterwards the person sees *Sent*, what they sent, and *Change answers* while the card is open. Checklists and buttons work as they always do.

With `"to": "sender"` the form is private:

- Its answers go to the sender's devices and the answerer's own, and nobody else in the chat. Others in a group never see them, or how many people answered.
- The sender doesn't get the questions. They see *No answers yet, waiting on Sam*; *Sam is filling it in* once Sam starts (sent once, never with what's typed); then each question with Sam's answer. In a group they see *2 of 4 answered*, how far each person has got, choices as bars, stars as an average and words with names.
- Everyone else sees *Only Kyle sees your answers* above the button.

An older version of the app shows a form's questions with a send arrow each, and sends answers to everyone in the chat; this version keeps only the sender's copy of them.

## 6. Params

`p` holds read-only values. Write `{param:name}` in the `title` or in any block's `t`, and the app shows the value. Strings, numbers and booleans are filled in; a missing name or an object leaves the placeholder as it is. A script reads the same values as `ctx.params`. Names are 1 to 64 of `A-Z a-z 0-9 _`. Never put secrets in params: everyone in the chat holds them.

```json
{
  "v": 1,
  "id": "welcome",
  "title": "Welcome, {param:name}",
  "emoji": "👋",
  "accent": 4280138122,
  "p": { "name": "Sam", "room": "Room 4" },
  "blocks": [
    { "id": "where", "k": "text", "t": "Your desk is in **{param:room}**." },
    { "id": "ok", "k": "button", "t": "Got it", "a": "respond" }
  ]
}
```

When a card is sent in a group with "Add the group's info", the app adds:

```json
{
  "me": { "id": "<your account id>", "name": "Alex" },
  "group": {
    "count": 3,
    "members": [
      { "id": "<account id>", "name": "Sam", "status": "At the gym", "online": true }
    ]
  }
}
```

A scripted card with bot slots gets `"bots": { "slotName": "<bot account id>" }` when it is sent.

## 7. Pictures, assets and sites

A card's own pictures go in image blocks as base64 (`img`). All the card's own pictures together, picture blocks and embedded assets, take at most 480 KB. The card's JSON without pictures is at most 64 KB.

An image block can instead name a picture the phone already holds, with no bytes in the card:

```json
{
  "v": 1,
  "id": "profile-card",
  "title": "Who's this?",
  "blocks": [
    { "id": "pic", "k": "image", "u": "avatar:sender", "t": "The sender's profile picture" },
    { "id": "guess", "k": "input", "t": "Say hello" }
  ]
}
```

Assets (`as`) are pictures a script draws by id. Each has an `id` (1 to 32 of `A-Z a-z 0-9 _ -`, not shared with a block id) and exactly one of `img` (base64, at most 160 KB) or `url` (an `https://` address). A web picture loads only after the person lets the card reach that site. One bad asset refuses the whole card.

```json
"as": [
  { "id": "logo", "img": "iVBORw0KGgo…" },
  { "id": "map", "url": "https://tiles.example.com/map.png" }
],
"sites": ["api.example.com"]
```

`sites` lists the hosts a scripted card reaches with `ctx.fetch` or for pictures. People see them, each with a switch, before they add the card. The hosts of web assets count too.

## 8. Relay actions

A relay action lets a scripted card call a web service with keys the person never sees. The card carries the action's definition; the relay bot that sent the card runs it, filling in secrets from its own store. The script calls it with `ctx.bot(name, args)` and needs `'bot:name'` in its permissions.

| Key | Meaning |
| --- | --- |
| `n` | **Required.** The name `ctx.bot` uses: a small letter, then up to 31 small letters, digits or `_`. Unique in the card. |
| `m` | `GET` (default) or `POST`. |
| `u` | **Required.** An `https://` address, at most 1,000 characters. The host is fixed: only the path, query and body may hold placeholders. |
| `h` | Headers, name to value. At most 16, each value at most 1,000 characters. |
| `b` | A body template for `POST`, at most 4,000 characters. |
| `x` | Extra hosts the relay may reach for this action, at most 8. The action's own host is always included. |
| `e` | Names of secrets it reads from the relay's env store, at most 8, like `STOCK_KEY`. |
| `k` | Key values, packaged by a relay owner only. Moved into the relay's store on install and stripped from the stored card. Never put them in shared cards. |

Placeholders: `{arg:name}` takes a value from the `args` the card passes (escaped); `{env:NAME}` takes a secret the relay keeps. A `ctx.bot` call works only in a one-to-one chat with the relay bot that sent the card, and waits up to 20 seconds.

```json
{
  "v": 1,
  "id": "stock-check",
  "title": "Stock check",
  "emoji": "📦",
  "accent": 4281244656,
  "blocks": [{ "id": "b1", "k": "text", "t": "Checks the shop's stock through the relay." }],
  "script": "card({ name: 'Stock check', permissions: ['bot:stock'] });\n\nfunction init() {\n  return { result: '' };\n}\n\non.check = (state, args, ctx) => {\n  const r = ctx.bot('stock', { sku: 'A-100' });\n  state.result = r.ok ? 'In stock: ' + r.json.count : 'Could not check: ' + (r.error || r.status);\n};\n\nfunction view(state) {\n  return column([text(state.result || 'Tap to check'), button('Check', 'check')]);\n}\n",
  "act": [
    {
      "n": "stock",
      "m": "POST",
      "u": "https://api.example.com/v1/stock/{arg:sku}",
      "h": { "Authorization": "Bearer {env:STOCK_KEY}" },
      "b": "{\"store\": \"main\"}",
      "e": ["STOCK_KEY"]
    }
  ]
}
```

## 9. Cards from relay bots

A relay bot sends cards with a fixed reply (`isolink-relay bot rule add … --card file.json`) or from a language model with its card tools. The relay accepts the long form below as well as the short form, checks the card as the app does, and fills in missing block ids. In the long form, `accent` may be a colour like `"#6366F1"`, and an image block may name an `https` picture by `url`, which the relay fetches and puts in the card.

```json
{"title": "Wi-Fi", "emoji": "📶", "blocks": [
  {"type": "text", "text": "The password is **on the fridge**."},
  {"type": "choice", "id": "worked", "text": "Did it work?", "options": ["Yes", "No"]}
]}
```

When someone answers a bot's card, the bot hears it.

## 10. Codes and files

- **Card code**: `isolink-card:` followed by the card's JSON, gzipped, in base64url. Spaces and line breaks in a pasted code are ignored. The part after the prefix is at most 1 MB and unpacks to at most 2 MB.
- **`.isocard` file**: the card code as UTF-8 text, MIME type `application/x-isolink-card`. A file may also hold plain gzip or a card's plain JSON. At most 2 MB.
- The app refuses to send a card whose script doesn't parse.

## 11. Card limits

| What | Limit |
| --- | --- |
| Blocks | 30 (plus the `_fb` block on a scripted card) |
| Card id, block id | 1 to 40 of `A-Z a-z 0-9 _ -` |
| Title | 80 characters |
| Emoji | 8 code points |
| Icon picture | A square PNG, 48 to 256 pixels a side, 32 KB, embedded as an asset |
| `text` block | 2,000 characters |
| Other `t`, options, items, hints | 120 characters |
| Choice options | 2 to 12, all different |
| Checklist items | 1 to 30 |
| Web address | 1,000 characters, http or https |
| Typed answer | 500 characters |
| Picture blocks | 3 |
| One picture | 160 KB, JPEG, PNG, GIF or WebP |
| All the card's own pictures | 480 KB |
| Card JSON without pictures | 64 KB |
| Params | 8 KB as JSON |
| Assets, sites, relay actions | 16, 16, 8 |
| Script | 49,152 characters |
| Fallback text | 500 characters |
| Form button label | 40 characters |
| People a block is `for` | 32 |
| My cards | 200 cards |
| Relay card library | 768 KB a card; by default 50 cards an account and 2,000 in all |

## 12. Block card examples

A poll:

```json
{
  "v": 1,
  "id": "dinner-poll",
  "title": "Where should dinner be?",
  "emoji": "📊",
  "accent": 4284704497,
  "blocks": [
    { "id": "pick", "k": "choice", "t": "Pick one", "o": ["Pizza", "Curry", "Burgers", "Something else"] },
    { "id": "note", "k": "text", "t": "Results update as people vote. Tap your pick again to take it back." }
  ]
}
```

A sign-up sheet with a checklist:

```json
{
  "v": 1,
  "id": "beach-clean",
  "title": "Beach clean-up sign-up",
  "emoji": "📝",
  "accent": 4287323382,
  "blocks": [
    { "id": "intro", "k": "text", "t": "**Saturday 10am**, by the pier. Pick the slots you can do." },
    { "id": "slots", "k": "choice", "t": "Slots", "o": ["10 to 11", "11 to 12", "12 to 1"], "m": true },
    { "id": "bring", "k": "checklist", "t": "Who brings what", "o": ["Bin bags", "Gloves", "Litter pickers", "Water"] },
    { "id": "note", "k": "input", "t": "Anything to add?", "h": "Times, a phone number, questions" }
  ]
}
```

A feedback form with a rating:

```json
{
  "v": 1,
  "id": "workshop-feedback",
  "title": "How was the workshop?",
  "emoji": "⭐",
  "accent": 4294096196,
  "blocks": [
    { "id": "stars", "k": "rating", "t": "Overall" },
    { "id": "best", "k": "choice", "t": "What worked?", "o": ["The pace", "The examples", "The room", "The snacks"], "m": true },
    { "id": "better", "k": "input", "t": "What would make it better?", "h": "One thing is plenty" },
    { "id": "slides", "k": "link", "t": "Slides and notes", "u": "https://example.com/workshop" }
  ]
}
```

A plan with every kind of button:

```json
{
  "v": 1,
  "id": "picnic",
  "title": "Picnic on Sunday",
  "emoji": "🧺",
  "accent": 4279548070,
  "blocks": [
    { "id": "when", "k": "text", "t": "**Sunday, 1pm** at the park gates.\n- Bring a blanket\n- Rain plan: the café" },
    { "id": "in", "k": "button", "t": "I'm in", "a": "respond" },
    { "id": "map", "k": "button", "t": "Open the map", "a": "link", "u": "https://example.com/map" },
    { "id": "ask", "k": "button", "t": "Ask a question", "a": "reply" },
    { "id": "food", "k": "checklist", "t": "Food", "o": ["Sandwiches", "Fruit", "Drinks"] },
    { "id": "hungry", "k": "rating", "t": "How hungry will you be?" },
    { "id": "site", "k": "link", "t": "Park opening times", "u": "https://example.com/park" }
  ]
}
```

A private form, like asking someone how much they need to borrow:

```json
{
  "v": 1,
  "id": "borrow",
  "title": "How much do you need to borrow?",
  "emoji": "💷",
  "accent": 4284704497,
  "form": { "send": "Send answers", "to": "sender" },
  "blocks": [
    { "id": "hi", "k": "text", "for": "others", "t": "Happy to help out. Just let me know the details." },
    { "id": "amount", "k": "input", "t": "How much do you need?", "h": "e.g. £50" },
    { "id": "why", "k": "input", "t": "What's it for? (optional)", "h": "A few words" },
    { "id": "when", "k": "input", "t": "When can you pay it back?", "h": "e.g. end of the month" }
  ]
}
```

A sign-up sheet everyone sees, sent with one button:

```json
{
  "v": 1,
  "id": "signup",
  "title": "Sign-up sheet",
  "emoji": "📝",
  "form": { "send": "Sign up" },
  "blocks": [
    { "id": "slots", "k": "choice", "t": "Slots", "o": ["Morning", "Afternoon", "Evening"], "m": true },
    { "id": "note", "k": "input", "t": "Anything to add?" }
  ]
}
```

## 13. Scripted cards: how a card runs

A card with a `script` is drawn by the script, not its blocks. Its blocks are for older versions of the app, after a text block with id `_fb` the app adds itself (the fallback, *Update Isolink to use this card.* by default). The script can still draw the card's picture blocks by id. A minimal scripted card:

```json
{
  "v": 1,
  "id": "counter-1",
  "title": "Counter",
  "emoji": "🔢",
  "blocks": [{ "id": "_fb", "k": "text", "t": "Update Isolink to use this card." }],
  "script": "function init() {\n  return { count: 0 };\n}\n\non.add = (state, args) => {\n  state.count += args.by;\n};\n\nfunction view(state) {\n  return column([\n    text(String(state.count), { size: 'huge', align: 'center' }),\n    button('+1', 'add', { by: 1 }, { tone: 'accent' }),\n  ]);\n}\n"
}
```

A script has three parts: `init()` returns the starting state, actions on the global `on` object change it, and `view()` says what the card shows.

- **Taps are events.** A tap runs the action on the tapper's phone first. If it throws, the tapper sees the message and nothing is sent. Otherwise the event (action, args, who, when) goes to everyone.
- **Every phone replays every event** in the same order: by time, then author, then event id, starting from `init()`. A card keeps its first 1,000 events.
- **Be deterministic.** Use `ctx.random()` and `ctx.time`, the same on every phone for a tap. `Math.random()` and `Date.now()` give the same values.
- **State is JSON**: objects, arrays, strings, numbers, booleans, `null`; at most 64 KB.
- **Fresh globals each run.** The top level runs again before every call. Only the state carries over.
- **Functions are hoisted**: `on.reset = () => init();` works.
- If an action fails on another phone's replay, that event is skipped there.

People allow what a card's manifest asks for (sounds, sites, pictures, the camera…) before it runs, and are asked again when its code changes. Scripts run in a sandbox: no access to messages, contacts, files or location. A card reaches the camera, the microphone, where someone is or a contact only through parts that Isolink draws and opens on a tap, and what they send goes into the chat for everyone to see (section 20).

## 14. card(): the manifest

A script may call `card({...})` once, at the top level. A card without one runs with no permissions. A card with one may use only what it names.

```js
card({
  name: 'Lane race',                     // 1 to 60 characters
  icon: 'run',                           // an icon name, or 'asset:id'
  mode: 'lanes',                         // 'shared' (default) or 'lanes'
  players: { min: 2, max: 6 },           // whole numbers, 1 to 16
  match: { bestOf: 3 },                  // an odd number, 1 to 99
  permissions: ['keyboard', 'sound'],    // at most 20
  keys: { ArrowRight: 'step', Space: 'step' },
  sounds: ['win'],
  bots: { judge: { grants: ['card.read'] } },
  private: { guess: 'judge' },
  nav: { each: true, who: 'anyone' },
});
```

| Key | What it does |
| --- | --- |
| `name` | 1 to 60 characters. |
| `icon` | What lists show for the card: an icon name, or `'asset:id'` for a picture the card carries. See *Icons* below. |
| `mode` | `'shared'`: one state. `'lanes'`: each player has a lane (section 23). |
| `permissions` | At most 20 of: `'sound'`, `'keyboard'`, `'pictures'` (profile pictures and covers of people in the chat), `'chat_images'` (pictures sent in the chat), `'files'` (asking for a file), `'camera'` (`camera()`, `scan()`), `'microphone'` (`record()`), `'location'` (`place()`), `'contacts'` (`contact()`), `'remind'` (`remind()`), `'motion'` (`me.tilt`), `'memory'` (`ctx.remember`, `me.memory`), `'web:host.com'` (a site for `ctx.fetch` and `link()`; subdomains count), `'bot:name'` (a relay action for `ctx.bot`). `'location'`, `'contacts'` and `'memory'` can't go with any `web:` or `bot:`: a card with both loses them. |
| `keys` | Key to action, at most 40. Needs `'keyboard'`. |
| `sounds` | The card's own sound names, at most 24: small letters, digits, `_`, `-`. Needs `'sound'`. |
| `players` | `{ min, max }`, 1 to 16. In lanes mode a player past `max` is turned down: *The game is full*. |
| `match` | `{ bestOf }`; `ctx.endRound(winner)` counts rounds. |
| `bots` | Up to 4 slots, each `{ grants: [...], model }`. Slot names: a small letter, then up to 23 small letters, digits or `_`. `model` is the level the slot's bot plays with: `'low'`, `'medium'`, `'high'` or `'xhigh'` (section 25). |
| `private` | Action name to bot slot: that action goes to the bot alone. The slot needs `'card.private'`. |
| `nav` | `{ each, who }` for screens (section 21). |
| `smooth` | `true` for games with motion: `every()` goes down to 16 ms and redraws on the screen's frames. Asleep after 30 s with no touch, key or move; a tap or a move wakes it. |

Anything wrong in `card()` is left out, never granted, and listed as a problem (like *keys need 'keyboard' in permissions*).

### Icons

My cards, the New card templates, the card install sheet and a relay's card library show each card's icon on its accent colour. A card picks one of two kinds:

- **An icon name.** One of the app's own icons, drawn in white on the card's `accent`. It costs nothing and looks right in light and dark. The names are: `alarm`, `bell`, `bolt`, `book`, `bot`, `brain`, `cake`, `calendar`, `camera`, `car`, `cards`, `cart`, `chart`, `chat`, `check`, `checklist`, `clock`, `cloud`, `code`, `coffee`, `compass`, `dice`, `divide`, `drink`, `event`, `fist`, `flag`, `flight`, `food`, `game`, `gift`, `globe`, `grid`, `heart`, `home`, `hourglass`, `idea`, `leaf`, `link`, `list`, `location`, `map`, `money`, `music`, `palette`, `party`, `people`, `person`, `pets`, `photo`, `pin`, `poll`, `puzzle`, `question`, `quiz`, `receipt`, `rocket`, `run`, `school`, `shield`, `shopping`, `shuffle`, `sparkle`, `sports`, `star`, `steps`, `sun`, `tasks`, `ticket`, `timer`, `tools`, `travel`, `trophy`, `vote`, `weather`, `work`.
- **A picture**, for a service that wants its own logo: `icon: 'asset:logo'`, where `logo` is the id of an asset the card carries (section 7). The picture must be:
  - a PNG (no JPEG, GIF, WebP or SVG)
  - square, 48 to 256 pixels a side (128 × 128 looks sharp everywhere)
  - at most 32 KB
  - embedded in the card. A web asset can't be an icon, so browsing a library never reaches anyone's site.

  It's drawn as it is, with rounded corners, so give it its own background. The app re-encodes it before it draws, the same as every other card picture, and it counts toward the card's 480 KB of pictures.

If the icon can't be shown, the card falls back, in this order: a picture that doesn't fit the rules or won't decode, then the card's own `icon` field, then its `emoji`, then the plain card icon. Card Studio lists why a picture won't do (like *the icon is square, but this one is 200 × 100*) and won't save until it's fixed; a card from anywhere else just falls back.

A train-times card from a service, with its own logo:

```json
{
  "id": "trains-1",
  "title": "Train times",
  "emoji": "🚆",
  "accent": 4278229247,
  "as": [{ "id": "logo", "img": "iVBORw0KGgo…" }],
  "sites": ["api.trains.example"],
  "script": "card({ name: 'Train times', icon: 'asset:logo', permissions: ['web:api.trains.example'] });\n…"
}
```

## 15. Actions and ctx

An action is `on.name = (state, args, ctx) => { ... }`. Names: a letter, `_` or `$`, then up to 63 letters, digits, `_`, `$` or `-`. Change `state` in place or return a new state. To turn a tap down, `throw 'Not your turn'` or `throw new Error('…')`: the tapper sees it and nothing is sent. A tap's `args` are any JSON, at most 4 KB.

`init(ctx)` returns the starting state (default `{}`, or `{ lanes: {} }` in lanes mode). In `init`, `ctx.author` is the sender, `ctx.time` the sent time, and `ctx.fetch` is refused.

| In an action | What it is |
| --- | --- |
| `ctx.author` | Account id of who tapped. |
| `ctx.authorName` | Their name (at most 64 characters). |
| `ctx.sender` | Account id of whoever sent the card. `ctx.author === ctx.sender` lets only them reset, draw or move on. |
| `ctx.time` | When they tapped, ms since 1970. |
| `ctx.random()` | 0 to 1, the same on every phone for this tap. |
| `ctx.params` | The card's `p`, read-only. |
| `ctx.slot` | The bot slot of whoever tapped, or `null` for a person. |
| `ctx.fetch(url, options)` | Web request (section 26). |
| `ctx.bot(name, args)` | Relay action (section 26). |
| `ctx.sound(name, { volume, for })` | Plays a sound (section 24). |
| `ctx.buzz(kind, { for })` | Buzzes the phone (section 24). |
| `ctx.remember(key, value)` | Keeps a value on the tapper's devices in every chat (section 20). |
| `ctx.push(screen, who?)`, `ctx.pop(who?)`, `ctx.go(screen?, who?)` | Screens (section 21). |
| `ctx.lane`, `ctx.laneOf(id)` | Lanes mode (section 23). |
| `ctx.endRound(winner)` | Ends a round of a match. |
| `ctx.can(grant)` | Whether whoever tapped holds a bot grant. |
| `ctx.hint(player, words)` | Bots with `card.hint`: sets `state.hints[player]`, up to 280 characters. |
| `ctx.removePlayer(id)` | Bots with `card.moderate`. |
| `ctx.act(action, args)` | Only in `pause()`, once (section 22). |

## 16. view() and me

`view(state, me, now, local)` returns components (section 17). It has no `ctx`, a smaller budget, and runs often. Returning nothing shows that the card has nothing to show.

- `me.id`, `me.name`: the person on this phone.
- `me.sender`: the account id of whoever sent the card; `me.isSender`: whether that's the person on this phone. Show the sender the answers and the host's buttons, and everyone else the questions: `return me.isSender ? Results(state) : Questions(state);`. A script's state is on every phone in the chat, so this hides things from view but doesn't keep them secret. For answers only the sender may hold, use a block card with `"form": { "to": "sender" }` (section 5).
- `me.lane`: lanes mode, their lane.
- `me.screen`, `me.stack`: the top screen (`'main'` for `view`) and the open stack, bottom first.
- `me.device`, `me.chat`: `{ width, height }` of the screen and of the chat, logical pixels.
- `me.drag`: a drag under way on a canvas on this phone, `{ x, y, sx, sy, canvas }`, or nothing (section 18).
- `me.card`: `{ width, height, fullScreen }`; `height` is `null` where the card may grow.
- `me.memory`: what this person's devices keep for the card with `ctx.remember`, in every chat. Needs `'memory'`.
- `me.tilt`: how the phone is tilted, `{ x, y }` from -1 to 1, or nothing where there's no motion sensor. Needs `'motion'` (section 20).
- `now`: this phone's time in ms. `local`: this phone's own object (section 22).

## 17. Components and styles

Each built-in component is a global function (also on `ui`, like `ui.text`). A style object may go last.

| Component | What it makes |
| --- | --- |
| `text(value, style?)` | Words. Plain text that contains any of `` * _ ` [ # > - `` and has no `size`, `align` or `bold` is drawn as Markdown. |
| `button(label, action?, args?, style?)` | A tap runs `on[action]` with `args`. Without an action it can't be tapped. |
| `row(...children, style?)` or `row([children], style?)` | Side by side, wrapping. |
| `column(...children, style?)` or `column([children], style?)` | Stacked. |
| `grid(columns, ...children, style?)` or `grid(columns, [children], style?)` | 1 to 8 columns. Buttons in a grid are square tiles and may have an empty label. |
| `input(name, placeholder?, action?, style?)` | Text field with Send. Runs `action` with `{ name, value }`. At most 500 characters; empty isn't sent. |
| `choice(name, options, action?, style?)` | Options (first 20 show). A tap runs `action` with `{ name, index, option }`. |
| `form(name, fields, label, action, style?)` | The `input`s and `choice`s in `fields` keep what's typed and picked on this phone, with no Send of their own, and the one `label` button runs `action` with `{ name, values }`: each field by its name, an input's words or a choice's index, `null` when left empty. Fields in a form need no action. |
| `image(src, style?)` | A picture (section 19). Full width, at most 260 px tall. |
| `avatar(who, style?)`, `cover(who, style?)` | Needs `'pictures'`. |
| `chatImage(n, style?)` | Needs `'chat_images'`. |
| `upload(label, action, accept?, style?)` | Asks for a file. Needs `'files'` (section 20). |
| `progress(value, style?)` | A bar, 0 to 1. |
| `badge(label, style?)` | A small pill. |
| `divider(style?)` | A line. |
| `spacer(size?)` | 0 to 64, default 8. |
| `canvas({...})` | Section 18. |

A list returned from `view` is a column; a string or number is text. Inside components, lists are flattened and `null`/`false` skipped, so `cond && component` works. At most 400 components, nested 12 deep.

| Style key | Values | Used by |
| --- | --- | --- |
| `tone` | `'accent'`, `'success'`, `'warning'`, `'danger'`, `'muted'` | Text colour; buttons (accent and success filled, danger red, muted plain); progress; badges. |
| `size` | `'small'`, `'large'`, `'huge'` | Text, grid button labels. |
| `bold` | `true` | Text. |
| `align` | `'center'`, `'end'`; rows also `'between'` | Text, buttons, badges, uploads, rows, columns. |
| `selected` | An index or list of indexes | `choice`. |
| `counts` | A number per option | `choice`: counts and bars. |

Colours follow the person's light or dark theme and the card's `accent`. Use tones, not hand-picked colours.

### Your own components

A card can build a piece of view once and use it again, by name, like a built-in. Set it up on the global `components`, at the top level:

```js
components.Stat = {
  about: 'A number with a label under it',
  props: { label: '', value: 0, tone: 'accent' },
  view: (props, children) => column([
    text(String(props.value), { size: 'large', bold: true, tone: props.tone }),
    text(props.label, { tone: 'muted' }),
    ...children,
  ]),
};

function view(state) {
  return row([Stat({ label: 'Wins', value: state.wins }), Stat({ label: 'Losses', value: state.losses, tone: 'danger' })]);
}
```

- Call it as `Name(props?, ...children)`. `props` is an object; children are components, one by one or in a list, and reach `view` as a list.
- Each key in `props` is a prop and its default: a call that leaves one out (or passes `null`) gets the default.
- `components.Name = (props, children) => ...` works too, with no defaults.
- `about` is what Card Studio shows in its toolbox, suggestions and hover.
- Start the name with a capital letter, and don't reuse a built-in's name. Lint flags a component with no `view`, a prop it doesn't have (with the nearest one), and one nothing uses.
- A component runs inside the view, with its budget; it can call other components.

## 18. Canvas and gestures

`canvas({ shapes, onTap, onDragStart, onDragEnd, axis, ratio, fill, id })`. Positions and sizes are fractions of the box, 0 to 1.

- `shapes`: at most 200, drawn in order.
- `ratio`: width over height, 0.3 to 5, default 1.6.
- `fill`: background tone. Default: the theme's sunken surface.
- `onTap`: action run with `{ x, y, phase: 'tap' }`.
- `onDragStart`: action run once when a drag starts to move, with `{ x, y, sx, sy, phase: 'start' }`: `sx`, `sy` where the finger landed, `x`, `y` where it is now.
- `onDragEnd` (or `onDrag`, its older name): action run once when a drag ends, with `{ x, y, sx, sy, dx, dy, phase: 'end' }`: `x`, `y` where it ended, `sx`, `sy` where it started, `dx`, `dy` its fling speed in box fractions per second. With `onDragStart`, a drag something else takes (a call, the app closing) still ends, with `phase: 'cancel'`. A drag that moves too little to start still ends, after its start.
- While a drag moves, nothing is sent. The view gets `me.drag`, `{ x, y, sx, sy, canvas }`, on this phone only, and draws again as the finger moves; it's gone once the end is in. `canvas` is the canvas's `id`, for a view with more than one.
- `id`: names the canvas in `me.drag`.
- `axis`: `'x'` or `'y'` takes drags one way only, so the chat still scrolls the other way.

| Shape | Style keys |
| --- | --- |
| `rect(x, y, w, h, style?)` | `fill`, `stroke`, `width`, `round` (fraction of shorter side). `fill: { image: src }` fills with a picture. |
| `circle(x, y, r, style?)` | `fill`, `stroke`, `width`; `r` is a fraction of the shorter side. Also `fill: { image: src }`. |
| `dot(x, y, r?, style?)` | `r` defaults to 0.03. |
| `line(x1, y1, x2, y2, style?)` | `stroke`, `width` (0.5 to 40 px, default 2). |
| `label(x, y, text, style?)` | Centred. `fill`, `size` (default 0.09), `bold`. |
| `img(x, y, w, h, src, style?)` | `clip: 'circle'` or `round`. |

Drag and drop: draw what's held at `me.drag`, and move it in the state when it's dropped. Every phone sees the start and the drop; only yours sees it move.

```js
const at = (x, y) => Math.min(3, Math.floor(x * 4)) + 4 * Math.min(3, Math.floor(y * 4));

function init() { return { pieces: { 0: '🍎', 5: '🍐' } }; }

on.pick = (state, a, ctx) => { state.holding = ctx.authorName; };
on.drop = (state, a) => {
  state.holding = null;
  const from = at(a.sx, a.sy), to = at(a.x, a.y);
  if (a.phase !== 'end' || !state.pieces[from] || state.pieces[to]) return;
  state.pieces[to] = state.pieces[from];
  delete state.pieces[from];
};

function view(state, me) {
  const held = me.drag ? at(me.drag.sx, me.drag.sy) : -1;
  const shapes = Object.keys(state.pieces).map((k) => {
    const n = Number(k);
    const [x, y] = n === held ? [me.drag.x, me.drag.y] : [(n % 4 + 0.5) / 4, (Math.floor(n / 4) + 0.5) / 4];
    return label(x, y, state.pieces[k], { size: 0.2 });
  });
  return column([
    canvas({ ratio: 1, shapes, onDragStart: 'pick', onDragEnd: 'drop' }),
    state.holding ? text(state.holding + ' is moving a piece', { tone: 'muted' }) : null,
  ]);
}
```

Colours: `'accent'`, `'fg'`, `'muted'`, `'good'`, `'warn'`, `'bad'`, `'bg'` (or `'text'`, `'success'`, `'warning'`, `'danger'`, `'surface'`), or `'#rrggbb'`. A shape with neither `fill` nor `stroke` is filled with the accent. At most 16 different pictures. For motion, keep state still and compute positions in the view from the time since the last event, with `every(30)`.

### Make it hands-on

Let people touch the thing itself rather than buttons about it. When a card has something to pick, place, move or set, draw it on a canvas:

- **Pick or place:** tap the square, piece, seat or day (`onTap`). A board is a canvas of cells, not a grid of buttons naming them. The cell is `Math.floor(y * rows) * cols + Math.floor(x * cols)`.
- **Set an amount:** drag along a bar (`onDragEnd` with `axis: 'x'`, plus `onTap`); draw the knob at `me.drag.x` while it moves, and where the finger lifts is the value.
- **Move or sort:** the drag's start (`sx`, `sy`) finds the piece, the view draws it at `me.drag` while it's held, and the end (`x`, `y`) is where it lands, as in the drag and drop example above.
- **Throw or swipe:** a flick's `dx`, `dy` throws a ball, or says yes (right) or no (left).
- Keep buttons for commands with nothing to touch (Start, Rematch, Reset), and `choice` for a plain vote on words.

## 19. Pictures in scripts

`image(src)`, `img(...)` and `fill: { image: src }` take:

- the id of an `image` block or an asset (shows straight away);
- an `https://` address (after the person allows that site; until then, a *Show* button);
- `'avatar:who'` / `'cover:who'` (`who`: account id, `'me'`, `'viewer'`, `'sender'`), needs `'pictures'`, people in the chat only;
- `'chat:n'` (0 is newest) or `'chat:messageId'`, needs `'chat_images'`.

Phones draw people's pictures from what they hold; the card never gets the bytes.

## 20. Files and the device

### Files

`upload(label, action, accept)`: `accept` is `'image'` or left out for any file. Needs `'files'`.

1. The app first runs `action` with a stand-in: `{ message: 'pending', name: '', mime: 'image/jpeg' or '', size: 0 }`. If it would throw, the person sees why and nothing is sent.
2. It asks every time: the file goes into the chat where everyone sees it.
3. The file is sent as an ordinary message.
4. `action` runs with `args.file = { message, name, mime, size }`; `chatImage(args.file.message)` shows a picture.

### Camera, voice notes, places and contacts

These parts are buttons. A tap by the person on this phone opens Isolink's own camera, scanner, recorder, place sheet or contact picker, with the card's name on it; nothing else opens them, not an action, a timer, a replay or a bot. Nothing is sent until they press Send. Like `upload`, the app first runs the action with a stand-in, so a card that would turn it down sends nothing.

| Part | Needs | The action gets |
| --- | --- | --- |
| `camera(label, action, { facing: 'front' })` | `'camera'` | `args.file = { message, name, mime, size }`: the photo, sent to the chat. |
| `scan(label, action)` | `'camera'` | `args.scan = { text, format }`: a QR code or barcode, like `qr` or `ean13`. |
| `record(label, action)` | `'microphone'` | `args.file = { message, name, mime, size, duration }`: a voice note of up to 2 minutes, sent to the chat. |
| `place(label, action)` | `'location'` | `args.place = { message, lat, lng, exact }`: where they are, sent to the chat. Approximate (about 1 km) unless they pick Exact. |
| `contact(label, action)` | `'contacts'` | `args.contact = { name, phone, email }`: the one contact they picked, its first number and address. |

The card never gets a photo's or a voice note's bytes, only its message. `chatImage(args.file.message)` shows a photo and `voice(args.file.message)` plays a voice note; `voice` needs `'microphone'` or `'chat_images'`. Everyone in the chat sees the photo, voice note or place as a message from whoever sent it, and whatever the action keeps in the state.

Phones have all of these. Computers have the camera (their webcam) and the microphone; Macs have places, and Windows when its location is on. Scanning works on phones and Macs, and contacts on phones. Where a part can't work, its button is greyed out.

### On this phone

These parts do one thing on the phone of whoever taps them, and send nothing:

| Part | Needs | What a tap does |
| --- | --- | --- |
| `remind(label, at, words)` | `'remind'` | A reminder at `at` (ms), up to a year ahead, with the card's name and `words` (up to 120 characters). One a card: another tap moves it. |
| `calendar(label, { title, start, end, place, notes })` | | The calendar's own add sheet. Times in ms. |
| `copy(label, text)` | | Copies `text`, up to 2,000 characters. |
| `share(label, text)` | | The system's share sheet with `text`. |
| `link(label, url)` | `'web:host'` | Opens an `https://` page on a site the card names. |
| `directions(label, to)` | | The maps app, with directions to `{ lat, lng }` or a place's name. |

### Tilt

With `'motion'`, `me.tilt` is how the phone is held: `x` from -1 (tipped left) to 1 (right), `y` from -1 (top away) to 1 (top towards you), 0 lying flat. It's on this phone only, never sent, and only while the card is on screen; use `every(30)` (or `smooth: true`) to redraw as it moves. Like `me.drag`, send where things ended up with a tap.

### Memory

With `'memory'`, `ctx.remember(key, value)` keeps a value on the devices of whoever tapped, for this card (by its `id`) in every chat: a best score, a setting. It's kept only when they tap: replays on other phones, and later replays on theirs, keep nothing. `me.memory` reads it in a view; actions can't, so every phone still reaches the same state. Keys are 1 to 40 characters; all of it at most 4 KB as JSON; `null` forgets a key.

```js
card({ name: 'Reaction time', permissions: ['memory'] });

on.done = (state, args, ctx) => {
  state.last = args.ms;
  ctx.remember('best', Math.min(args.ms, args.best ?? args.ms));
};

function view(state, me) {
  const best = me.memory.best;
  return column([
    text(best ? 'Your best: ' + best + ' ms' : 'No best yet'),
    button('I did it in 240 ms', 'done', { ms: 240, best }),
  ]);
}
```

## 21. Screens

`view()` is the main screen. Other screens are functions on the global `screens`, with the same arguments as `view`.

- Built-in actions: `push` with `{ screen }`, `pop`, and `go` with `{ screen }` (no screen or `'main'` goes home). Use them on buttons: `button('Back', 'pop')`. Defining `on.push`, `on.pop` or `on.go` replaces the built-in one.
- In actions: `ctx.push(screen)`, `ctx.pop()`, `ctx.go(screen)` for whoever tapped.
- Default: one stack shared by everyone, in `state.stack`. With `nav: { each: true }`, each person has their own, in `state.stacks[id]`; a last argument picks who: an id, or `'all'`.
- `nav: { who: 'sender' }`: only the sender (and bots granted `card.screens`) moves a shared stack. Default `'anyone'`.
- At most 16 open. The state must be an object.

## 22. Timers, pause and resume

`every(ms)` redraws every `ms` (30 ms to 1 hour; 16 ms, every frame, for a card with `smooth: true`). It never sends anything. Call it at the top level or in a view. `setInterval(f, ms)` does the same; `f` is never called. Anything time-based compares `now` with a time stored in the state, and a deadline needs a tap after it to change state.

`function pause(local, ctx)` runs on one phone when the card leaves the screen there; `function resume(local, ctx)` when it returns. A card without `pause` never pauses. `local` is this phone's own object, never sent, at most 16 KB; change it in place or return a new one; `view` gets it fourth. `pause` may call `ctx.act(action, args)` once to send one action.

## 23. Lanes and matches

With `mode: 'lanes'`, each player's lane is `state.lanes[id]`. `ctx.lane` is the tapper's lane (made empty the first time); `ctx.laneOf(id)` reads anyone's; a view gets `me.lane`. An action may change only its own lane, unless a bot holds `card.lanes.write`.

With `match: { bestOf: n }`, `ctx.endRound(winner)` keeps `state.match = { round, wins: { id: n }, winner }`. `winner` is set once someone has won more than half; then `endRound` throws *The match is over*. If a bot slot holds `card.rounds`, only that bot ends rounds.

## 24. Sounds, buzzes and keys

`ctx.buzz(kind, { for })`: `'tap'` (default), `'light'`, `'heavy'`, `'success'` or `'error'`. At most 4 per action; no permission. Felt once, live only, while the card is on screen, like a sound.

`ctx.sound(name, { volume, for })`: at most 4 per action, needs `'sound'`. `volume` 0 to 1; `for` an account id. Built-in: `tap`, `tick`, `pop`, `coin`, `buzz`, `win`, `lose`, and notes `c4` `d4` `e4` `f4` `g4` `a4` `b4` `c5` `d5` `e5` `f5` `g5` `a5` `b5` `c6`; plus names in `card({ sounds })`. Plays once, live only, while the card is on screen and the person has sound on.

`keys` (full screen only): a small letter or digit, `'a-z'`, `'0-9'`, or `ArrowLeft`, `ArrowRight`, `ArrowUp`, `ArrowDown`, `Space`, `Enter`, `Backspace`. Esc, Tab and Ctrl/Cmd/Alt combinations never reach a card. Needs `'keyboard'`.

## 25. Bot slots

A slot is a seat for a relay bot. The sender chooses which of the chat's relay bots sits in each; the card gets `params.bots = { slot: account }`. Grants:

| Grant | The bot may |
| --- | --- |
| `card.read` | Hear events and see the state. |
| `card.peek` | Read the state when it needs to (`read_card`), and hear nothing. |
| `card.act` | Use the card's actions as itself. |
| `card.lanes.read` | See every lane. |
| `card.lanes.write` | Change any lane. |
| `card.private` | Get private actions. |
| `card.secrets` | Keep things off the phones, on its relay. |
| `card.rounds` | End rounds; then nobody else can. |
| `card.background_execute` | Act with nobody tapping. |
| `card.hint` | Show one player words (`ctx.hint`). |
| `card.moderate` | Remove a player (`ctx.removePlayer`). |
| `card.screens` | Move screens without `card.act`. |

**Model level.** A slot can ask for a model level with `model`: `bots: { rival: { grants: ['card.read', 'card.act'], model: 'low' } }`. The bot then plays this card's turns on that level's model, and its other chats keep its own. The relay's owner sets what each level means (by default on Claude: `low` Haiku, `medium` Sonnet with Opus as advisor, `high` the bot's own model, `xhigh` Opus at extra high effort). A level the relay hasn't set uses the bot's own model. Pick `low` for quick games, a higher level when the bot must think hard.

Keep the rules in the card's code. Give the fewest grants: `card.peek` when the bot only needs to answer "what's the score?", `card.read` when it must hear every move.

A bot with `card.peek` or `card.read` can read the card's state on demand. It sees only cards that seat it, players' lanes stay hidden without `card.lanes.read`, and `local` never leaves the phone.

## 26. Web requests and ctx.bot

`ctx.fetch(url, { method, headers, body })` answers at once (no `await`) and never throws: `{ ok, status, text, json, error }`.

- The tapper is asked first: *Allow once*, *Always for this card*, *Don't allow*. Kept per card and script.
- Only the tapper's phone fetches; the answer travels in the event and others replay it.
- A card with a manifest reaches only `'web:host'` sites (and subdomains).
- `https://` only, no user info, at most 2,000 characters. `GET` (default, no body) or `POST`.
- Headers: at most 16, values up to 1,024 characters. Not allowed: `cookie`, `cookie2`, `host`, `content-length`, `connection`, `keep-alive`, `transfer-encoding`, `upgrade`, `origin`, `referer`, `te`, `trailer`, `via`, `expect`, `proxy-*`, `sec-*`.
- Body: a string, or an object sent as JSON; at most 16,384 characters.
- 3 requests a tap; 256 KB per answer and per tap; 10 seconds each; no cookies, no redirects.
- `error`: `declined`, `offline`, `timeout`, `too big`, `failed`, `too many requests`, `no answer`, or a refusal reason like `only https:// addresses work`.

`ctx.bot(name, args)` runs a relay action (section 8) and answers in the same shape. Needs `'bot:name'`; args at most 4 KB; one-to-one chat with the bot that sent the card; 20 seconds.

## 27. The language

A subset of JavaScript, checked by the app and run on QuickJS, the engine apps run on.

**Supported:** `let`, `const`, `var` (all block-scoped; redeclaring in one scope is an error); function declarations and expressions, arrows, default and rest parameters; destructuring with defaults and `...rest`; spread; template strings; object shorthand, methods and computed keys; `if`/`else`, `for`, `for...of` (arrays, strings), `for...in` (keys), `while`, `do...while`, `break`, `continue`, `switch`; `try`/`catch`/`finally`, `throw`; `?.`, `??`, `? :`, `typeof`, `void`, `delete`, `in`, `++`, `--`; arithmetic, comparison, bitwise and logical operators; all compound assignments up to `??=`. Numbers: `0x`, `0b`, `0o`, `1e3`, `1_000`. Comments `//` and `/* */`. Semicolons are optional at line breaks.

**Not supported:** classes, `this`, `async`/`await`/`yield`/promises, `import`/`export`, `with`, `instanceof`, regular expressions, tagged templates, labels, getters/setters, `Map`, `Set`, `Symbol`, `Date` objects (only `Date.now()`). `new` works only with `Error`, `TypeError`, `RangeError`, `Array`.

Values leave a script as JSON: `undefined` and functions are dropped from objects (`null` in arrays); `NaN` and `Infinity` become `null`.

## 28. Built-ins

- Globals: `undefined`, `NaN`, `Infinity`, `isNaN`, `isFinite`, `parseInt(s, radix?)`, `parseFloat`, `String`, `Number`, `Boolean`, `console.log` (50 lines of 500 characters, shown in Card Studio).
- `Math`: `PI`, `E`, `abs`, `floor`, `ceil`, `round`, `trunc`, `sign`, `sqrt`, `cbrt`, `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `log`, `log2`, `log10`, `exp`, `pow`, `hypot`, `min`, `max`, `random`.
- `JSON.stringify(value, _, space?)`, `JSON.parse`.
- `Object`: `keys`, `values`, `entries`, `assign`, `fromEntries`, `freeze` (does nothing).
- `Array(n)`, `Array(...items)`, `Array.isArray`, `Array.of`, `Array.from(arrayOrStringOr{length}, mapFn?)`.
- `Number.isInteger`, `isFinite`, `isNaN`, `MAX_SAFE_INTEGER`, `MIN_SAFE_INTEGER`.
- `Error`, `TypeError`, `RangeError` make `{ name, message }`. `Date.now()`.
- Array methods: `length`, `push`, `pop`, `shift`, `unshift`, `slice`, `splice`, `concat`, `join`, `indexOf`, `lastIndexOf`, `includes`, `map`, `filter`, `reduce`, `reduceRight`, `forEach`, `find`, `findIndex`, `findLast`, `findLastIndex`, `some`, `every`, `sort` (stable; as strings without a compare function), `reverse`, `flat`, `flatMap`, `fill`, `at`, `toString`.
- String methods: `length`, `charAt`, `charCodeAt`, `indexOf`, `lastIndexOf`, `includes`, `startsWith`, `endsWith`, `slice`, `substring`, `toUpperCase`, `toLowerCase`, `trim`, `trimStart`, `trimEnd`, `split(sep, limit?)`, `replace`/`replaceAll` (string to find; replacement may be a function), `repeat`, `padStart`, `padEnd`, `at`, `concat`, `localeCompare` (-1, 0 or 1), `toString`.
- Number methods: `toFixed(digits)`, `toString(radix?)`.

## 29. Script limits

| What | Limit |
| --- | --- |
| Script | 49,152 characters |
| `init` and each action | 100,000 steps, 2 seconds |
| Each view, `pause`, `resume` | 25,000 steps, 500 ms |
| Nested calls | 150 |
| A string | 524,288 characters |
| An array | 50,000 items |
| State | 64 KB as JSON |
| `local` | 16 KB |
| A tap's args | 4 KB |
| One event, with what it fetched | 300 KB |
| Events kept | 1,000 |
| Components in a view | 400, nested 12 deep |
| Canvas | 200 shapes, 16 pictures |
| Redraw interval | 30 ms to 1 hour |
| Web requests | 3 a tap, 10 s each, 256 KB an answer and a tap |
| Sounds | 4 an action |
| Buzzes | 4 an action |
| Memory | 4 KB a card, keys of 40 characters |
| Reminders | 1 waiting a card, up to a year ahead, 120 characters |
| Copy, share | 2,000 characters |
| Open screens | 16 |
| `card()` | name 60; 20 permissions; 40 keys; 24 sounds; 1 to 16 players; best of 1 to 99; 4 bot slots |

A memory budget also counts items, keys and characters made.

## 30. Errors and checks

- Errors read `Line N: message`, like `Line 4: Can't read score of undefined`, or *This script ran too long: more than 100000 steps. Look for a loop that never ends*.
- A script that doesn't parse, or a view that fails, shows *This card hit a problem* with the line and message.
- An action that throws on the tapper's phone shows them the message; nothing is sent.
- `catch (e)` gets what was thrown; built-in errors are `{ name, message }`.

Before a bot sends a scripted card or Card Studio saves one, the app runs it: `init`, the view for two people, every screen, and each button's action once. It reports unknown components, buttons whose action doesn't exist, pictures or uploads without permission, and an empty view. An action that throws in this check is fine; one past a limit is not. In Dart: `cardScriptProblem(card)`.

Card Studio also requires a `card({...})` manifest and these four functions, each with this exact first line (bodies may be empty): `function init(ctx) {`, `function view(state, me, now, local) {`, `function pause(local, ctx) {`, `function resume(local, ctx) {`. Every key in `keys` must name an action, and every feature used needs its permission (`cardStudioProblems(source)`). Its editor checks as you type, without running anything (`lintCardSource(source)` in Dart): a script that doesn't parse; names that aren't defined, assigned without `let`, or declared twice; `const` and built-ins assigned to; members that `ctx`, `me`, `Math`, `JSON` and the like don't have; buttons, keys and `ctx.push` naming an action or screen that isn't there; unknown sounds and permissions; style values a component ignores; the card's own components named like a built-in, with no `view`, or called with a prop they don't have; calls with too few or too many arguments; code after `return`; and what's never used. Most come with a fix, like the nearest name. It also warns about `==` and `var`. Suggestions (`cardScriptCompletions`) know the components (the card's own too, with their props) and their styles, `ctx` and `me`, the script's own actions, screens and state keys, and string values such as tones and sounds.

The editor numbers lines as the whole script does, so `Line 80: …` in an error is line 80 in the gutter, and the preview offers to go there. What lint finds shows at the end of its line. Hovering a name (or F1 at the cursor) says what it is (`cardScriptHoverAt`), and its **Reference** describes every function a card writes, the shape of each object it's given or gives (the manifest, `state`, `me`, `ctx`, `local`, what each component sends as `args`), how to write your own components, and the options of components and shapes (`cardScriptTypes` in Dart). Down the side, under the outline, a toolbox shows every component, the card's own first, each with an icon: drag one into the code to put it on its own line under the line you let go on, or tap it to put it in at the cursor (`cardScriptComponents` lists a card's own). Above the toolbox, a collapsible **Component tree** shows what the view (or the component or screen the cursor is in) is built from, nested as in the code: the one under the cursor is picked, a tap goes to it, and an arrow folds what's inside (`cardComponentTree`). On a phone it opens from the bar under the code. On a wide screen each panel down the sides (Parts, Component tree, Toolbox, and with Split, Preview and Properties) folds to its heading with a tap, moves by dragging its heading onto another (on either side) or from its ⋯ menu or a right-click, and the edge between a side and the code drags to make the side wider (a double-click puts it back); where they are is kept in the app's prefs (`StudioPanelLayout`). Keys: Ctrl+Space suggestions, Ctrl+/ comment, Tab and Shift+Tab indent, Alt+Up/Down move lines, Shift+Alt+Down copy them, Shift+Alt+F format.

A script opened in Card Studio keeps working when its functions name their arguments differently: `function view(s, me)` becomes `view(state, me, now, local)` with `s` read as `state` in its body.

## 31. Script examples

Each is a complete `script` value. Put it in a card's `script` field as a JSON string.

Counter:

```js
// One number everyone in the chat shares.
function init() {
  return { count: 0 };
}

on.add = (state, args) => {
  state.count += args.by;
};

on.reset = (state) => {
  state.count = 0;
};

function view(state) {
  return column([
    text(String(state.count), { size: 'huge', bold: true, align: 'center', tone: 'accent' }),
    row([
      button('−1', 'add', { by: -1 }),
      button('+1', 'add', { by: 1 }, { tone: 'accent' }),
      button('Reset', 'reset', null, { tone: 'muted' }),
    ], { align: 'center' }),
  ], { align: 'center' });
}
```

The Card Studio shape:

```js
card({
  name: 'Tap counter',
  permissions: [],
});

on.tap = (state, args, ctx) => {
  state.taps += 1;
  state.last = ctx.authorName;
};

function init(ctx) {
  return { taps: 0, last: '' };
}

function view(state, me, now, local) {
  return column([
    text('Tapped ' + state.taps + ' times', { size: 'large', bold: true, align: 'center' }),
    state.last ? text('Last tap: ' + state.last, { tone: 'muted', align: 'center' }) : null,
    button('Tap', 'tap', null, { tone: 'accent', align: 'center' }),
  ]);
}

function pause(local, ctx) {
  // Runs on this phone when the card leaves the screen.
}

function resume(local, ctx) {
  // Runs on this phone when it comes back.
}
```

A vote with `choice`:

```js
const options = ['Pizza', 'Sushi', 'Tacos'];

function init() {
  return { votes: {} };
}

// Tap an option to vote for it, tap it again to take the vote back.
on.vote = (state, args, ctx) => {
  if (state.votes[ctx.author] === args.index) delete state.votes[ctx.author];
  else state.votes[ctx.author] = args.index;
};

function view(state, me) {
  const counts = options.map(() => 0);
  for (const id in state.votes) counts[state.votes[id]]++;
  const mine = state.votes[me.id];
  const total = Object.keys(state.votes).length;
  return column([
    text('Tap to vote, tap again to take it back.', { tone: 'muted', size: 'small' }),
    choice('food', options, 'vote', { selected: mine === undefined ? [] : mine, counts }),
    row([badge(total + ' voted', { tone: 'accent' })], { align: 'end' }),
  ]);
}
```

Tic-tac-toe:

```js
// Two players. The first to tap is X, the next person is O.
const lines = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]];

function init() {
  return { board: Array(9).fill(''), x: null, o: null, names: {}, turn: 'x', winner: null };
}

on.play = (s, args, ctx) => {
  if (s.winner) throw 'The game is over';
  if (!s.x) s.x = ctx.author;
  else if (!s.o && ctx.author !== s.x) s.o = ctx.author;
  const mark = ctx.author === s.x ? 'x' : ctx.author === s.o ? 'o' : null;
  if (!mark) throw 'Two people are already playing';
  if (mark !== s.turn) throw 'Not your turn';
  if (s.board[args.cell]) throw 'That square is taken';
  s.names[ctx.author] = ctx.authorName;
  s.board[args.cell] = mark;
  for (const [a, b, c] of lines) {
    if (s.board[a] && s.board[a] === s.board[b] && s.board[b] === s.board[c]) s.winner = ctx.author;
  }
  if (!s.winner && s.board.every((m) => m)) s.winner = 'draw';
  s.turn = mark === 'x' ? 'o' : 'x';
};

on.reset = () => init();

function view(s, me) {
  const next = s.turn === 'x' ? s.x : s.o;
  let status;
  if (s.winner === 'draw') status = "It's a draw";
  else if (s.winner) status = s.winner === me.id ? 'You won!' : s.names[s.winner] + ' won';
  else if (!s.x) status = 'Tap a square to start';
  else if (next === me.id || (!next && me.id !== s.x)) status = 'Your turn';
  else status = 'Waiting for ' + (s.names[next] || 'the other player');
  const marks = { x: 'X', o: 'O', '': '' };
  return column([
    text(status, { bold: true, align: 'center', tone: s.winner === me.id ? 'success' : undefined }),
    grid(3, s.board.map((m, i) => button(marks[m], 'play', { cell: i }, { tone: m === 'x' ? 'accent' : m === 'o' ? 'warning' : undefined }))),
    s.winner ? button('New game', 'reset', null, { tone: 'accent', align: 'center' }) : null,
  ]);
}
```

A timer:

```js
// One timer for the whole chat. Anyone can start or stop it.
// Draw the card again every second. This never sends anything.
every(1000);
const lengths = [1, 5, 10];

function init() {
  return { ends: null, length: 0, by: '' };
}

on.start = (s, args, ctx) => {
  if (!lengths.includes(args.minutes)) throw 'Pick one of the times';
  s.length = args.minutes * 60000;
  s.ends = ctx.time + s.length;
  s.by = ctx.authorName;
};

on.stop = (s) => {
  s.ends = null;
};

function starts() {
  return row(lengths.map((m) => button(m + ' min', 'start', { minutes: m }, { tone: 'accent' })), { align: 'center' });
}

function view(s, me, now) {
  if (s.ends === null) return column([text('Pick a time to start', { tone: 'muted', align: 'center' }), starts()]);
  const left = Math.max(0, s.ends - now);
  const secs = Math.ceil(left / 1000);
  const pad = (n) => String(n).padStart(2, '0');
  return column([
    left === 0
      ? text("Time's up!", { size: 'large', bold: true, align: 'center', tone: 'success' })
      : text(pad(Math.floor(secs / 60)) + ':' + pad(secs % 60), { size: 'huge', bold: true, align: 'center', tone: 'accent' }),
    progress(left / s.length),
    text('Started by ' + s.by, { size: 'small', tone: 'muted', align: 'center' }),
    left === 0 ? starts() : button('Stop', 'stop', null, { tone: 'muted', align: 'center' }),
  ]);
}
```

A canvas people tap:

```js
// Tap the canvas to drop a dot in your colour. Everyone sees every dot.
const colours = ['accent', 'success', 'warning', 'danger', '#a78bfa'];

function init() {
  return { dots: [], colour: {} };
}

on.drop = (state, args, ctx) => {
  if (state.colour[ctx.author] === undefined) {
    state.colour[ctx.author] = Object.keys(state.colour).length % colours.length;
  }
  state.dots.push({ x: args.x, y: args.y, c: state.colour[ctx.author] });
  if (state.dots.length > 150) state.dots.shift();
};

on.clear = (state) => {
  state.dots = [];
};

function view(state) {
  const shapes = [
    line(0.05, 0.5, 0.95, 0.5, { stroke: 'muted', width: 1 }),
    label(0.5, 0.08, 'Tap anywhere', { fill: 'muted', size: 0.07 }),
    ...state.dots.map((d) => circle(d.x, d.y, 0.04, { fill: colours[d.c] })),
  ];
  return column([
    canvas({ ratio: 1.6, onTap: 'drop', shapes }),
    row([badge(state.dots.length + ' dots'), button('Clear', 'clear', null, { tone: 'muted' })], { align: 'between' }),
  ]);
}
```

Screens:

```js
card({
  name: 'Party RSVP',
  // Each person opens and closes screens on their own.
  nav: { each: true },
});

// Opens over the main screen when someone says yes.
screens.food = (state, me) => column([
  text("Anything you don't eat?", { bold: true, align: 'center' }),
  row(['Nothing', 'Meat', 'Nuts', 'Dairy'].map((f) => button(f, 'food', { food: f })), { align: 'center' }),
  button('Back', 'pop', null, { tone: 'muted' }),
]);

function init() {
  return { answers: {} };
}

on.answer = (state, args, ctx) => {
  state.answers[ctx.author] = { name: ctx.authorName, coming: args.coming, food: '' };
  if (args.coming) ctx.push('food');
};

on.food = (state, args, ctx) => {
  if (!state.answers[ctx.author]) throw "Say if you're coming first";
  state.answers[ctx.author].food = args.food;
  ctx.pop();
};

on.change = (state, args, ctx) => {
  delete state.answers[ctx.author];
};

// The main screen: the question until you answer, then who's coming.
function view(state, me) {
  if (!state.answers[me.id]) {
    return column([
      text('Are you coming?', { size: 'large', bold: true, align: 'center' }),
      row([button('Yes', 'answer', { coming: true }, { tone: 'accent' }), button('No', 'answer', { coming: false })], { align: 'center' }),
    ]);
  }
  const coming = Object.values(state.answers).filter((a) => a.coming);
  return column([
    text(coming.length + ' coming', { size: 'large', bold: true, align: 'center' }),
    ...coming.map((a) => row([text(a.name), a.food && a.food !== 'Nothing' ? badge('No ' + a.food.toLowerCase()) : null])),
    button('Change my answer', 'change', null, { tone: 'muted' }),
  ]);
}
```

Pictures and files:

```js
card({
  name: 'Photo board',
  permissions: ['pictures', 'chat_images', 'files'],
});

function init() {
  return { photos: [] };
}

// upload() sends the picked file into the chat first, then runs this
// with args.file = { message, name, mime, size }.
on.add = (state, args, ctx) => {
  if (!args.file.mime.startsWith('image/')) throw 'Pick a picture';
  if (state.photos.length >= 6) throw 'The board is full';
  state.photos.push({ by: ctx.author, name: ctx.authorName, message: args.file.message });
};

function view(state, me) {
  return column([
    row([avatar('sender'), text('Photo board', { size: 'large', bold: true })]),
    ...state.photos.map((p) => column([chatImage(p.message), text('From ' + p.name, { size: 'small', tone: 'muted' })])),
    state.photos.length === 0 ? text('No photos yet', { tone: 'muted' }) : null,
    upload('Add a photo', 'add', 'image'),
  ]);
}
```

Lanes, a match, keys and sounds:

```js
card({
  name: 'Lane race',
  mode: 'lanes',
  players: { min: 2, max: 6 },
  match: { bestOf: 3 },
  permissions: ['keyboard', 'sound'],
  keys: { ArrowRight: 'step', Space: 'step' },
});

const finish = 20;

function init() {
  return { lanes: {} };
}

on.step = (state, args, ctx) => {
  if (state.match && state.match.winner) throw 'The match is over';
  const round = state.match ? state.match.round : 1;
  // A new round starts everyone at the start line.
  if (ctx.lane.round !== round) {
    ctx.lane.round = round;
    ctx.lane.pos = 0;
  }
  ctx.lane.name = ctx.authorName;
  ctx.lane.pos += 1;
  if (ctx.lane.pos >= finish) {
    ctx.sound('win');
    ctx.endRound(ctx.author);
  }
};

function view(state, me) {
  const round = state.match ? state.match.round : 1;
  const wins = state.match ? state.match.wins : {};
  const rows = Object.keys(state.lanes).map((id) => {
    const lane = state.lanes[id];
    const pos = lane.round === round ? lane.pos : 0;
    return column([
      row([text(lane.name + (id === me.id ? ' (you)' : '')), badge((wins[id] || 0) + ' won')], { align: 'between' }),
      progress(pos / finish),
    ]);
  });
  if (state.match && state.match.winner) {
    rows.push(text(state.lanes[state.match.winner].name + ' wins the match!', { bold: true, align: 'center' }));
  }
  return column([
    text('Round ' + round + ' · first to ' + finish, { tone: 'muted', align: 'center' }),
    ...rows,
    button('Step →', 'step', null, { tone: 'accent' }),
  ]);
}
```

The weather, with `ctx.fetch`:

```js
card({
  name: 'Weather',
  permissions: ['web:api.open-meteo.com'],
});

const place = { name: 'London', lat: 51.5, lon: -0.1 };

function init() {
  return { status: 'empty' };
}

on.refresh = (state, args, ctx) => {
  // Answers straight away: no await. The person who taps is asked first.
  const r = ctx.fetch('https://api.open-meteo.com/v1/forecast?latitude=' + place.lat +
    '&longitude=' + place.lon + '&current=temperature_2m,wind_speed_10m');
  state.by = ctx.authorName;
  if (!r.ok || !r.json || !r.json.current) {
    state.status = 'error';
    state.error = r.error || ('HTTP ' + r.status);
    return;
  }
  state.status = 'ok';
  state.temp = r.json.current.temperature_2m;
  state.wind = r.json.current.wind_speed_10m;
};

function view(state) {
  return column([
    text(place.name, { bold: true }),
    state.status === 'ok'
      ? text(Math.round(state.temp) + '°C, wind ' + Math.round(state.wind) + ' km/h', { size: 'large', tone: 'accent' })
      : state.status === 'error'
        ? text("Couldn't get the weather: " + state.error, { tone: 'danger' })
        : text('Tap to check the weather', { tone: 'muted' }),
    state.by ? text('Checked by ' + state.by, { size: 'small', tone: 'muted' }) : null,
    button('Check the weather', 'refresh', null, { tone: 'accent' }),
  ]);
}
```

A bot slot with a private action:

```js
card({
  name: 'Secret word',
  // A bot in the judge slot hears guesses privately and keeps the word on its relay.
  bots: { judge: { grants: ['card.read', 'card.act', 'card.private', 'card.secrets', 'card.hint'] } },
  private: { guess: 'judge' },
});

function init() {
  return { solved: null, tries: 0 };
}

// Only the judge bot runs this: it checks a guess against its secret word.
on.verdict = (state, args, ctx) => {
  if (ctx.slot !== 'judge') throw 'Only the judge decides';
  state.tries += 1;
  if (args.right) state.solved = args.name;
  else ctx.hint(args.player, 'Not ' + args.word + '. Try again.');
};

function view(state, me) {
  if (state.solved) return text(state.solved + ' found the word!', { size: 'large', bold: true, tone: 'success' });
  const hint = state.hints && state.hints[me.id];
  return column([
    text('Guess the secret word', { bold: true }),
    hint ? text(hint, { tone: 'warning' }) : null,
    input('word', 'Your guess', 'guess'),
    text(state.tries + ' guesses so far', { size: 'small', tone: 'muted' }),
  ]);
}
```

Feedback for the sender: everyone else fills in a form, sent with one button, and the sender sees the answers:

```js
card({ name: 'Feedback', icon: 'chat' });

const moods = ['Great', 'Fine', 'Not great'];

function init() {
  return { answers: {} };
}

on.answer = (s, args, ctx) => {
  if (ctx.author === ctx.sender) throw 'You sent this, so you see the answers';
  s.answers[ctx.author] = { name: ctx.authorName, ...args.values };
};

function view(s, me) {
  const all = Object.values(s.answers);
  if (me.isSender) {
    if (!all.length) return text('No feedback yet', { tone: 'muted' });
    return column(all.map(a => text('**' + a.name + '**: ' + (moods[a.mood] || '–') + (a.best ? ', ' + a.best : ''))));
  }
  if (s.answers[me.id]) return text('Thanks! Your feedback went to the sender.', { tone: 'success' });
  return form('feedback', [
    text('How did it go?', { bold: true }),
    choice('mood', moods),
    input('best', 'The best bit'),
  ], 'Send feedback', 'answer');
}
```

## 32. Prompt template

Paste this into a language model, with this whole document above it, and fill in the brackets.

```text
You are making an interactive card for the Isolink messaging app. Follow
"Isolink interactive cards: format and scripts" above exactly.

What I want:
- Title: [at most 80 characters], emoji: [one emoji]
- Kind: [a block card (no code) / a scripted card]
- What it does: [e.g. "a poll for Friday's dinner with four options",
  "tic-tac-toe for two players with a rematch button"]
- Colour: [e.g. "teal" or "no preference"]
- It may use: [nothing / sounds / keyboard / people's pictures / pictures in
  the chat / files / the web site api.example.com]

Rules:
1. Output only one JSON object: the card from section 3. No prose, no
   Markdown fences, no comments, no trailing commas.
2. "v" is 1. "id" and every block id match [A-Za-z0-9_-]{1,40} and are
   unique. Never use the block id "_fb".
3. "accent" is a decimal ARGB integer: 4278190080 + 0xRRGGBB. Compute it.
4. Block cards: use only the kinds and keys in section 4. Every button has
   "a". Choices have 2 to 12 different options. Keep within section 11.
5. Scripted cards: "script" is one JSON string with \n line breaks. Use only
   the language in section 27 and the components in sections 17 to 24. Start with
   card({...}) naming every permission used, and write init, view, pause and
   resume with the exact first lines in section 30. Use ctx.random() and
   ctx.time, never anything that differs between phones. Every button's
   action must exist on `on` (or be push, pop or go).
   When there is something to pick, place, move or set, draw it on a
   canvas people tap or drag (section 18), not a row of buttons.
6. Add one text block for older apps, unless it is a block card.
7. Never invent base64 pictures. Use no img fields unless I give you one.
8. Before answering, check the result against section 33.
```

## 33. Common mistakes

| Mistake | What happens |
| --- | --- |
| A button without `a` | The block is dropped. |
| A `choice` with one option, or two the same | The block is dropped. |
| Two blocks with the same id | The later one is dropped. |
| An image block with an `https://` `u` | The block is dropped. Use an asset `url` in a script, or `img`. |
| `accent` as `"#6366F1"` in the short form | The card is refused. Use an integer (only the bot long form takes hex). |
| A title over 80 characters, or 31 blocks | The card is refused. |
| `Math.random()` expected to differ per phone | It doesn't; it is the tap's shared random. That is correct. |
| `await ctx.fetch(...)` | Not supported: `fetch` answers at once. |
| A class, `this`, a regular expression or `Map` | *Line N:* parse or type error. |
| `ctx.sound` without `'sound'` in permissions | The check lists the missing permission. |
| A button naming an action that doesn't exist | The check reports it. |
| Changing state in `view` | Lost: only actions change state. |
| Answers only the sender should see, kept in a script's state | Every phone holds the state. Use a block card with `"form": { "to": "sender" }`. |
| A form `to` other than `"sender"` or `"all"` | The card is refused. |
| A loop that never ends | Stops at 100,000 steps with *This script ran too long*. |
