# Yumina Link (script-only games)

Some games give modders a script language but no network: Baldur's Gate 3's Script Extender can only read and write files, Papyrus has no HTTP, and many Lua hosts have no HTTPS. **Yumina Link** is a small program that runs beside the game on the player's PC. It keeps the player's Yumina sign-in and answers the game in one of two ways.

Both take exactly the requests in the [HTTP reference](./http); Link only adds the player's sign-in.

## Local HTTP

```
POST http://127.0.0.1:47600/v1/<client_id>/signin     { "mode": "qr" }      → status with qr / user_code
GET  http://127.0.0.1:47600/v1/<client_id>/status                            → { signed_in, sign_in, username, qr? }
POST http://127.0.0.1:47600/v1/<client_id>/turns      <a turn request>       → the turn
GET  http://127.0.0.1:47600/v1/<client_id>/me
POST http://127.0.0.1:47600/v1/<client_id>/signout
```

Link answers only requests from this PC that don't come from a web page (it refuses any request with a foreign `Origin` or `Host`), so no website can spend the player's mushies through it.

## File drop-box

Start Link with a folder your script can write to, e.g. the Script Extender's own folder:

```
YuminaLink --watch "%LOCALAPPDATA%\Larian Studios\Baldur's Gate 3\Script Extender\Yumina"
```

The script writes `<id>.yumina-request.json`:

```json
{ "client_id": "ym_…", "op": "turns", "body": { "character": "shadowheart", "card": { "id": "…" }, "text": "…", "memory": { "head": null } } }
```

and reads `<id>.yumina-response.json` when it appears — `{ "result": … }` or `{ "error": { "message", "code" } }`. `op` is `turns`, `status`, `signin`, `signout`, `me` or `cards`. Use a new `id` per request.

## Sending a turn again

A turn takes 5–10 seconds, and some engines' HTTP gives up sooner. Give each turn a request id: the `Idempotency-Key` header (or `?request=<id>` on the URL, for scripts that can't set headers), or `"request_id"` in a drop-box request. If the same id comes again while that turn runs or within 10 minutes, Link answers with the same turn instead of running (and charging) another. A turn that failed isn't kept: sending it again runs it.

## Signing in from a full-screen game

`http://127.0.0.1:47600` is also a page that shows every game connected through Link, a QR code to sign in, and a sign-out button. Open it in the Steam overlay's browser and the player never leaves the game.
