| 1 | # Delegated Sheets access |
| 2 | |
| 3 | The Oficina connection exposes `sheets_list`, `sheets_list_tabs`, |
| 4 | `sheets_get_range`, `sheets_create` and `sheets_set_range`. CLI, Paseo, ChatGPT and Claude use the |
| 5 | same contracts. Existing Home links and current app permissions are required. |
| 6 | |
| 7 | Set `SHEETS_AGENT_ISSUER` to the HTTPS connection-service origin and |
| 8 | `SHEETS_AGENT_TEAM` to this instance's team, alongside existing Home settings. |
| 9 | Both settings are required together. Credentials must target this app's exact |
| 10 | origin plus `/api/v1` and name the configured Home identity issuer. |
| 11 | |
| 12 | Export contracts with `go run ./cmd/sheets-contract`. The bearer endpoints are |
| 13 | `GET /api/v1/operations` and `POST /api/v1/operations/{name}`. The connection |
| 14 | service obtains app credentials; browser cookies do not authenticate them. |
| 15 | Read operations require `sheets:read`; create requires `sheets:write` and current |
| 16 | team membership. Explicitly granted guests can read their permitted sheets. In roster team mode, |
| 17 | creation uses current Home membership; stored local roles do not grant standing. |
| 18 | The configured agent team must match the provisioned roster team. Full lists |
| 19 | return a retryable failure when roster authority is unavailable, while exact |
| 20 | items independently shared with the caller remain readable. This initial API |
| 21 | requires an existing Home-linked local account. |
| 22 | |
| 23 | IDs, revisions and pagination cursors are decimal JSON strings. IDs must be |
| 24 | positive, canonical and at most 9223372036854775807. Omit the cursor on the first |
| 25 | page. Sheet listing descends by ID; tab listing ascends. Both default to 20 |
| 26 | items and permit at most 100. |
| 27 | |
| 28 | Create accepts a nonzero canonical UUID `client_id`, a title and `tab_name` |
| 29 | (up to 200 Unicode characters each), and `cells` containing up to 500 distinct |
| 30 | `row`, `column`, `raw` entries. Coordinates are zero-based: rows 0–4999 and |
| 31 | columns 0–599. Raw cell input is at most 8 KiB and uses the browser's formula |
| 32 | parser and calculator. The entire sheet, first tab, owner grant, initial cells, |
| 33 | sealed attribution and receipt commit together. Create returns sheet/tab IDs, |
| 34 | a browser URL and current revision; reuse the UUID only for an identical retry. |
| 35 | A retry preserves intervening browser edits and never recreates a deleted sheet. |
| 36 | |
| 37 | Range reads return raw input, calculated value/type, default display text and a |
| 38 | coherent revision for at most 500 cells. Incomplete calculation is an explicit |
| 39 | failure. Inputs and encoded responses are capped at 1 MiB; oversized results |
| 40 | fail without truncation. Formula error values are returned as cell errors. |
| 41 | The revision is the store's next-stamp watermark, shared with range reads. |
| 42 | |
| 43 | The receipt marker binds the Home key, Home issuer, connection issuer and team. |
| 44 | Changes require an explicit operator migration. Never delete the marker or |
| 45 | receipts to make old requests appear new. Creation does not send invitations. |
| 46 | Formatting, additional tabs, comments, sharing and import/export remain |
| 47 | separate capability slices. |
| 48 | |
| 49 | See [the reviewed specification](superpowers/specs/2026-10-25-agent-access.md). |
| 50 | This branch does not claim deployment or live client certification. |
| 51 | |
| 52 | `sheets_set_range` requires `team`, `sheet_id`, `tab_id`, `expected_revision`, |
| 53 | `client_id` and an ordered `cells` array of 1–500 `{row,column,raw}` entries. |
| 54 | Read a range first and copy its revision string into `expected_revision`. |
| 55 | The native batch updates exactly those cells, recalculates formulas atomically |
| 56 | and blanks a cell when raw is empty. Current editor permission is required; |
| 57 | an independent editor share works under the same roster rules as browser edits. |
| 58 | |
| 59 | A stale revision returns `conflict` without changing cells. After an uncertain |
| 60 | response, repeat the same UUID, revision and ordered cell values. The response |
| 61 | contains sheet/tab IDs, URL and the original **applied** revision, even when |
| 62 | later edits advanced the tab. It never replays the cell writes; read again for |
| 63 | current values and revision. Choose a new UUID for a changed edit. |
| 64 | |