# Read-only agent access

This interface uses Oficina Connect delegated credentials. It exposes no
conversation posting, task changes, merge, or other write operation.
Model-written text is never treated as the person's words.

## Configuration

Set `EQUIPO_AGENT_ISSUER` (normally `https://connect.oficina.works`) and
`EQUIPO_AGENT_TEAM` together. The team is the existing Home directory team's
canonical SQID, encoded from one positive team ID with Home's default Sqids
codec. It is not a team label, hostname, or Equipo's local database ID.
Both absent leaves the existing API authentication unchanged. Partial or
malformed values refuse startup. Equipo currently has no separate Home team
mode; this setting binds its one existing local team to the directory team.

Agent access requires valid `EQUIPO_HOME_ISSUER`,
`EQUIPO_HOME_CONSUMER_ID`, `EQUIPO_HOME_KEYS_BASE64`, and
`EQUIPO_HOME_DEK_BASE64`, plus the normal instance configuration. Preserve
existing identity keys and local account links. Configuration does not
create accounts, link people, or add roster members.

`GET /auth/start` is an alias for the existing Home sign-in entry point,
`GET /auth/home`. Both directly redirect to the configured Home issuer's
`/authorize` URL. Health and version endpoints are unchanged.

## Authentication and discovery

`GET /api/v1/operations` takes no arguments. Send
`Authorization: Bearer <delegated credential>`. Device credentials and
browser cookies do not grant agent access. These routes run ahead of the
device and session middleware.

Every call uses `agent-access` revision `8ed8ba826000` and its
`NewRemoteVerifier(agentIssuer, equipoOrigin+"/api/v1", homeIssuer)`.
The verifier calls the issuer's `POST /api/v1/credential`, forwarding the
bearer and `{"resource":"<equipoOrigin>/api/v1"}`. It checks the returned
resource and identity issuer and requires a subject and grant. There is no
local credential cache or offline fallback.

Equipo resolves that Home subject through its existing authenticated local
identity binding and checks the current roster. An absent, removed, or
unlinked person is refused. Invocation resolves the link again inside the
application read transaction and checks the current roster/session epoch.
Lookup failures deny access. A role change takes effect through these
existing read paths; all active roster roles can read shared team work.

Missing or invalid credentials return 401, `Cache-Control: no-store`,
`Content-Type: application/json`, exactly one `WWW-Authenticate: Bearer`,
and only this envelope (the nonempty message may vary):

```json
{"error":{"code":"unauthenticated","message":"Send a valid delegated bearer."}}
```

A valid linked person gets `{"operations":[...]}`. Each descriptor includes
its name, description, scope, read-only/idempotent flags, and JSON input and
output schemas. Only operations allowed for this exact team and
`equipo:read` scope appear. Other teams or scopes get an empty list.

## Invocation

`POST /api/v1/operations/{name}` accepts `Content-Type: application/json`
and the same delegated bearer. The body is the operation's arguments,
including the exact `team` SQID. Unknown fields, duplicate JSON field names,
invalid JSON, missing required arguments, and out-of-range limits are
rejected by the shared registry. Input is capped at 2 MiB.

| Operation | Arguments besides `team` | Output |
| --- | --- | --- |
| `equipo_projects_list` | Optional `limit`, integer 1 to 100, default 100 | `{"items":[Project],"truncated":boolean}` |
| `equipo_tasks_list` | Optional `limit`, integer 1 to 100, default 100 | `{"items":[Task],"truncated":boolean}` |
| `equipo_task_get` | Required `id`, nonempty string, at most 128 characters | `{"task":Task}` |
| `equipo_needs_you` | Optional `limit`, integer 1 to 100, default 100 | `{"items":[Task],"truncated":boolean}` |

All four descriptors set `read_only` and `idempotent` to true and
`destructive` to false. The returned Project and Task objects are the
current thin device API's data, documented in [Equipo v1](equipo-v1.md).
Projects include ID, title, repository, state, revision, and current
metadata. Tasks include ID, project, title, brief, stage, revision,
creator, steps, findings, thread, questions, and current decision fields.
The output schemas guarantee IDs, titles, revisions, and the enclosing
shape; additional device fields are preserved. No prose is generated.

Projects use the existing `Chat.Projects` read and omit the device API's
repository-add allowlist and home namespace. Task listing uses `Chat.Tasks`,
including its test-person visibility filter. Task get uses `Chat.Task`.
Needs you uses `Chat.NeedsYou`, which selects the calling person's recent
nonterminal tasks whose decision field is nonempty.

Lists preserve the existing device ordering. Each response contains at
most 100 items, and invocation output is capped at 1 MiB. Oversized output
returns `too_large` with no partial data. `truncated` is conservative:
it is true when the requested limit cuts a list or completeness cannot be
established. Task listing reads at most the latest 100 tasks and preserves
that source cap before hiding other test people's tasks. If the source hits
100, `truncated` stays true even when fewer visible items are returned.
Needs you already scans at most 100 recent nonterminal tasks before
filtering, so its `truncated` is always true, including an empty result.
An empty result is not proof that there is no older work waiting. There is
no cursor or all-history promise in this first interface.

Example arguments:

```json
{"team":"<Home team SQID>","limit":20}
```

Errors use the same `error.code` / `error.message` envelope: 403 for denied
local access or a different submitted team, 404 for an unavailable
operation or task, 413 for size limits, 415 for other media types, 422 for
invalid arguments, and 503 when verification or reading is unavailable.
All responses from the agent handler have `Cache-Control: no-store`.
