| 1 | # Read-only agent access |
| 2 | |
| 3 | This interface uses Oficina Connect delegated credentials. It exposes no |
| 4 | conversation posting, task changes, merge, or other write operation. |
| 5 | Model-written text is never treated as the person's words. |
| 6 | |
| 7 | ## Configuration |
| 8 | |
| 9 | Set `EQUIPO_AGENT_ISSUER` (normally `https://connect.oficina.works`) and |
| 10 | `EQUIPO_AGENT_TEAM` together. The team is the existing Home directory team's |
| 11 | canonical SQID, encoded from one positive team ID with Home's default Sqids |
| 12 | codec. It is not a team label, hostname, or Equipo's local database ID. |
| 13 | Both absent leaves the existing API authentication unchanged. Partial or |
| 14 | malformed values refuse startup. Equipo currently has no separate Home team |
| 15 | mode; this setting binds its one existing local team to the directory team. |
| 16 | |
| 17 | Agent access requires valid `EQUIPO_HOME_ISSUER`, |
| 18 | `EQUIPO_HOME_CONSUMER_ID`, `EQUIPO_HOME_KEYS_BASE64`, and |
| 19 | `EQUIPO_HOME_DEK_BASE64`, plus the normal instance configuration. Preserve |
| 20 | existing identity keys and local account links. Configuration does not |
| 21 | create accounts, link people, or add roster members. |
| 22 | |
| 23 | `GET /auth/start` is an alias for the existing Home sign-in entry point, |
| 24 | `GET /auth/home`. Both directly redirect to the configured Home issuer's |
| 25 | `/authorize` URL. Health and version endpoints are unchanged. |
| 26 | |
| 27 | ## Authentication and discovery |
| 28 | |
| 29 | `GET /api/v1/operations` takes no arguments. Send |
| 30 | `Authorization: Bearer <delegated credential>`. Device credentials and |
| 31 | browser cookies do not grant agent access. These routes run ahead of the |
| 32 | device and session middleware. |
| 33 | |
| 34 | Every call uses `agent-access` revision `8ed8ba826000` and its |
| 35 | `NewRemoteVerifier(agentIssuer, equipoOrigin+"/api/v1", homeIssuer)`. |
| 36 | The verifier calls the issuer's `POST /api/v1/credential`, forwarding the |
| 37 | bearer and `{"resource":"<equipoOrigin>/api/v1"}`. It checks the returned |
| 38 | resource and identity issuer and requires a subject and grant. There is no |
| 39 | local credential cache or offline fallback. |
| 40 | |
| 41 | Equipo resolves that Home subject through its existing authenticated local |
| 42 | identity binding and checks the current roster. An absent, removed, or |
| 43 | unlinked person is refused. Invocation resolves the link again inside the |
| 44 | application read transaction and checks the current roster/session epoch. |
| 45 | Lookup failures deny access. A role change takes effect through these |
| 46 | existing read paths; all active roster roles can read shared team work. |
| 47 | |
| 48 | Missing or invalid credentials return 401, `Cache-Control: no-store`, |
| 49 | `Content-Type: application/json`, exactly one `WWW-Authenticate: Bearer`, |
| 50 | and only this envelope (the nonempty message may vary): |
| 51 | |
| 52 | ```json |
| 53 | {"error":{"code":"unauthenticated","message":"Send a valid delegated bearer."}} |
| 54 | ``` |
| 55 | |
| 56 | A valid linked person gets `{"operations":[...]}`. Each descriptor includes |
| 57 | its name, description, scope, read-only/idempotent flags, and JSON input and |
| 58 | output schemas. Only operations allowed for this exact team and |
| 59 | `equipo:read` scope appear. Other teams or scopes get an empty list. |
| 60 | |
| 61 | ## Invocation |
| 62 | |
| 63 | `POST /api/v1/operations/{name}` accepts `Content-Type: application/json` |
| 64 | and the same delegated bearer. The body is the operation's arguments, |
| 65 | including the exact `team` SQID. Unknown fields, duplicate JSON field names, |
| 66 | invalid JSON, missing required arguments, and out-of-range limits are |
| 67 | rejected by the shared registry. Input is capped at 2 MiB. |
| 68 | |
| 69 | | Operation | Arguments besides `team` | Output | |
| 70 | | --- | --- | --- | |
| 71 | | `equipo_projects_list` | Optional `limit`, integer 1 to 100, default 100 | `{"items":[Project],"truncated":boolean}` | |
| 72 | | `equipo_tasks_list` | Optional `limit`, integer 1 to 100, default 100 | `{"items":[Task],"truncated":boolean}` | |
| 73 | | `equipo_task_get` | Required `id`, nonempty string, at most 128 characters | `{"task":Task}` | |
| 74 | | `equipo_needs_you` | Optional `limit`, integer 1 to 100, default 100 | `{"items":[Task],"truncated":boolean}` | |
| 75 | |
| 76 | All four descriptors set `read_only` and `idempotent` to true and |
| 77 | `destructive` to false. The returned Project and Task objects are the |
| 78 | current thin device API's data, documented in [Equipo v1](equipo-v1.md). |
| 79 | Projects include ID, title, repository, state, revision, and current |
| 80 | metadata. Tasks include ID, project, title, brief, stage, revision, |
| 81 | creator, steps, findings, thread, questions, and current decision fields. |
| 82 | The output schemas guarantee IDs, titles, revisions, and the enclosing |
| 83 | shape; additional device fields are preserved. No prose is generated. |
| 84 | |
| 85 | Projects use the existing `Chat.Projects` read and omit the device API's |
| 86 | repository-add allowlist and home namespace. Task listing uses `Chat.Tasks`, |
| 87 | including its test-person visibility filter. Task get uses `Chat.Task`. |
| 88 | Needs you uses `Chat.NeedsYou`, which selects the calling person's recent |
| 89 | nonterminal tasks whose decision field is nonempty. |
| 90 | |
| 91 | Lists preserve the existing device ordering. Each response contains at |
| 92 | most 100 items, and invocation output is capped at 1 MiB. Oversized output |
| 93 | returns `too_large` with no partial data. `truncated` is conservative: |
| 94 | it is true when the requested limit cuts a list or completeness cannot be |
| 95 | established. Task listing reads at most the latest 100 tasks and preserves |
| 96 | that source cap before hiding other test people's tasks. If the source hits |
| 97 | 100, `truncated` stays true even when fewer visible items are returned. |
| 98 | Needs you already scans at most 100 recent nonterminal tasks before |
| 99 | filtering, so its `truncated` is always true, including an empty result. |
| 100 | An empty result is not proof that there is no older work waiting. There is |
| 101 | no cursor or all-history promise in this first interface. |
| 102 | |
| 103 | Example arguments: |
| 104 | |
| 105 | ```json |
| 106 | {"team":"<Home team SQID>","limit":20} |
| 107 | ``` |
| 108 | |
| 109 | Errors use the same `error.code` / `error.message` envelope: 403 for denied |
| 110 | local access or a different submitted team, 404 for an unavailable |
| 111 | operation or task, 413 for size limits, 415 for other media types, 422 for |
| 112 | invalid arguments, and 503 when verification or reading is unavailable. |
| 113 | All responses from the agent handler have `Cache-Control: no-store`. |
| 114 | |