oficina / agent-access Public

Clone
git clone https://amadan.net/oficina/agent-access

Plain git — no account needed to clone.

Download this file

1# Oficina agent access
2
3One operation contract for Oficina HTTP APIs, the `oficina` CLI, and MCP.
4The transport and credential interfaces are independent of the app operations
5so they can be replaced by Rastrillo implementations later.
6
7Status: implementation in progress. Shared operations, HTTP/MCP adapters, the
8CLI, browser consent with PKCE, rotating refresh tokens and revocation are
9implemented. Tests exercise browser authorization through an HTTPS fixture,
10including real loopback callbacks and the signed Home identity handoff. A runnable
11connection service and reviewed adapters for Docs, Sheets, Memoria, Calendar,
12Calls and Slides are on feature branches, exposing 27 app operations plus the
13shared `calls_schedule` workflow (28 total). Live four-client
14acceptance and deployment remain outstanding. No production endpoint is deployed.
15
16Each request supplies a verified person, client, grant, selected teams and
17scopes. The registry rejects unauthorized team/scope combinations before calling
18an app, validates inputs and outputs, and returns bounded JSON. The app remains
19responsible for current local admission, resource access, data storage and edit
20semantics. MCP uses the official Go SDK, with stateless requests to avoid retaining
21one person's authorization in another request.
22
23Run `make ci` for formatting, vet, and tests. Integration tests drive the same
24operation through HTTP and MCP and verify that grant revocation prevents writes
25through an already connected MCP client.
26
27[Rastrillo coordination](https://amadan.net/rastrillo/rastrillo/-/discussion/116).
28The JSON API framework landed at Rastrillo `2e833dd`; its MCP and OAuth packages
29are separate ongoing work. This module will not wait on them, per Paul's
302026-10-24 direction.
31
32The `grant` package is mounted by the connection service with verified browser
33identity and current-team callbacks. The issuer and consent UI run separately
34from Home's credential origin. App tokens are restricted to one audience, team
35and scope set; `RemoteVerifier` checks them online before the app resolves the
36Home subject to an existing local account. Revoking the parent grant also
37invalidates every downstream token.
38
39`oficina auth login --server https://…` opens the system browser and stores the
40connection in the OS credential store. `oficina tools` lists operations;
41`oficina notes create --team acme --input note.json` calls one. `oficina mcp serve`
42provides a local stdio adapter backed by the same API. The server must have this
43integration mounted; these commands do not work against the current production
44apps yet. `oficina auth logout` revokes the server-side connection and then removes local
45credentials. If revocation fails it keeps the credential so you can retry.
46`oficina teams list` and MCP `oficina_connection` discover currently permitted
47team IDs; ordinary commands never open a browser implicitly.
48
49
50## Running the connection service
51
52For local development, build `go build ./cmd/oficina-connect` and `go build ./cmd/oficina`.
53`oficina-connect -config connection.json -db /persistent/connect.db` listens on
54127.0.0.1:8080 behind an HTTPS reverse proxy preserving the public Host. Configure
55an independent origin such as `https://connect.example.test`; this is separate
56from both Home's credential and directory origins. Forwarding headers never
57choose a trusted host or issuer. The service exposes `/mcp`, `/api/v1/operations`,
58`/api/v1/connection`, OAuth metadata, and `/connections` for browser revocation.
59
60Configuration fields are `origin`, `home_issuer`, `consumer_id`, `home_keys`
61(a key-ID to base64 Home signing-public-key map), `directory`, `clients`, and
62`routes`. A route binds `team`, `resource` (the app HTTPS origin plus `/api/v1`),
63and `operations` (the app's exported operation descriptors). Routes are operator
64configuration, never tool arguments. Only current Home membership and live app
65destinations matching those configured routes are eligible. Configure the Home
66consumer with this origin and the `/auth/assertion` callback. Require an existing
67admitted local app account linked to Home; the service does not provision one.
68
69Set `OFICINA_CONNECT_DEK` to a persistent, random 32-byte base64 encryption key
70and `OFICINA_DIRECTORY_TOKEN` to a random service token of at least 32 bytes via
71deployment secret configuration. Home's directory role stores only the SHA-256
72hex digest as `HOME_AGENT_DIRECTORY_TOKEN_SHA256`. That new Home endpoint is
73currently on its feature branch and must be deployed before this service can
74work. Rotation requires coordinated configuration and process restarts. Keep the
75DEK stable across restarts; changing it invalidates pending identity/consent flows.
76
77`oficina-cli` is registered automatically for a random loopback callback port.
78Remote MCP hosts must be registered in `clients`, with a unique `id`, a person-
79readable `name`, and exact HTTPS `redirects`. There is no dynamic client
80registration. Use authorization-code + S256 PKCE and the `/mcp` resource audience.
81Registration and host interoperability must be verified before offering a host
82as supported.
83
84Consent requires a Home authentication at most five minutes old. Connections
85expire after 90 days; access tokens last five minutes, rotating refresh tokens
86have a 30-day idle lifetime, and downstream app tokens last at most one minute.
87Current membership is checked online. Reusing a consumed refresh token revokes
88its whole connection. Cleanup retains refresh replay evidence until the parent
89connection ends. A disconnected browser connection stops downstream tokens too.
90
91The service retains opaque identity, client, team, scope and grant metadata. It
92never persists operation payloads or results. App implementations retain their
93own content storage, permissions and retry receipts. JSON validation preserves
94large integer IDs and decimal bounds and cannot fetch external schema references.
95
96## Rastrillo convergence
97
98The agent on `docs-t1` confirmed explicit descriptors, shared policy checks and
99verifier/actor interfaces as the intended integration boundary in discussion 116.
100The Oficina `Operation`, `Verifier` and gateway contracts isolate the current
101SDK/HTTP implementation. Memoria's handwritten operations are the first planned
102interoperability fixture. Replacing these adapters requires parity, revocation
103and numeric-fidelity tests; this branch does not claim upstream compatibility
104until those tests run against the released Rastrillo implementation.
105
106
107## Initial client targets
108
109Paul selected all four: Oficina CLI, Paseo, ChatGPT and Claude (2026-10-25).
110The CLI browser flow and SDK-level HTTP/MCP flow have automated TLS coverage.
111Real hosted-client runs remain a release gate; none is claimed here as deployed.
112
113| Client | Initial connection | Verification still needed |
114| --- | --- | --- |
115| Oficina CLI | `oficina auth login --server <origin>`, OS credential store | Deployed Home/app flow with a real linked account |
116| Paseo | Agent provider launches `oficina mcp serve` on the machine holding the CLI grant | Provider configuration, keychain availability, discovery and calls in an actual Paseo agent |
117| ChatGPT | Remote `<origin>/mcp`, pre-registered public OAuth client | Exact redirect from its management page, browser consent, tool discovery/read/write, refresh, denial and revocation |
118| Claude | Remote `<origin>/mcp`, own pre-registered public OAuth client | Exact redirect from its connector setup, browser consent, tool discovery/read/write, refresh, denial and revocation |
119
120Give each remote host its own client ID and exact redirect allowlist. The service
121supports public-client `none` with S256 PKCE, not client secrets or client
122assertions. Choose the host's predefined/own OAuth client option and use its
123actual displayed callback. Do not enable automatic registration or published
124identity/CIMD against this implementation: those paths are not implemented.
125Remote-host support requires a public HTTPS endpoint reachable by that host.
126A locally launched Paseo provider requires the CLI connection on that same
127machine; credentials are not copied to another Paseo host automatically.
128
129ChatGPT supports predefined OAuth clients and Streamable HTTP, and requires the
130advertised issuer to match authorization-response `iss`. This server advertises
131and returns that value. Register the exact callback shown for the connection;
132do not infer one from a hostname. See [OpenAI authentication](https://developers.openai.com/plugins/build/auth)
133and [custom MCP setup](https://developers.openai.com/api/docs/guides/custom-mcp-server).
134Claude exposes an own-OAuth-client configuration option; its remote connector
135runs from Anthropic's cloud even on desktop. See [Claude custom connectors](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp).
136
137For each host, record the tested host version/date, configured client ID (never
138credentials), callback, consent scopes/teams, and results. Required exercises:
139allow and deny; missing scope; wrong team; create and same-key retry; explicit
140invitation-link permission where applicable; refresh; revoke in `/connections`;
141then repeat a call in the already open host session and require refusal.
142
143Credential introspection includes `identity_issuer`, the fixed Home identity
144namespace, distinct from the connection service issuer. Each app must supply its
145configured Home issuer to `NewRemoteVerifier`; subjects are released only after
146an exact match. A grant database binds that Home issuer persistently and refuses
147a changed issuer or an unbound database already containing grants. Changing the
148Home authority requires an explicit migration, not a configuration-only restart.
149
150## Platform deployment
151
152`OFICINA_CONNECT_CONFIG_BASE64` selects the Rastrillo/CARLOS runtime before
153standalone flag parsing. It contains the same strict public JSON as `-config`,
154limited to 64 KiB decoded. Secrets remain separate. This mode accepts `serve`,
155`-socket`, `-addr`, and `-db`; relative database paths resolve beneath
156`STATE_DIRECTORY`. It provides framework health/version probes and graceful
157shutdown. `-config` and `-listen` belong to standalone mode and are refused here.
158See [the runtime contract](docs/platform-runtime.md) for limits and tests.
159
160Build committed release artifacts with `scripts/build-release.sh /absolute/output`.
161The output includes Linux/arm64 service and CLI binaries, native equivalents,
162`VERSION` (the full source SHA), and `SHA256SUMS`. Use exactly that `VERSION` as
163`carlos deploy --version`; the service reports it from `/api/version`.
164
165Before publishing, run `scripts/vet-release.py /absolute/output --carlos /path/to/carlos`.
166This uses a temporary local CARLOS store and a synthetic configuration; no upload
167or infrastructure change occurs. It checks the native artifact through the real
168`carlos vet --boot` contract. Repeat on Linux/arm64 with `--target linux-arm64`
169for the deployment artifact. The generated fixture is only for boot verification,
170never a production secret or a valid live app registration.
171
172
173## Editing and interoperability
174
175The [shared conventions](docs/api-conventions.md) define opaque IDs, resource
176references, revision preconditions, immutable retry acknowledgements and stable
177failure categories. Existing operation names and identifier types are retained.
178
179| App | Added operation | Supported editing |
180| --- | --- | --- |
181| Docs | `docs_update` | Bounded paragraph/heading splices; untouched rich content is preserved |
182| Sheets | `sheets_set_range` | Atomic ordered cell inputs with native formula recalculation |
183| Slides | `slides_update_deck` | Thirteen discoverable semantic operation variants |
184| Memoria | `notes_get`, `notes_update` | Read/replace local notes with indexing; imported items remain read-only |
185| Calendar | `calendar_update_event` | Patch single noncancelled events, preserving omitted fields and repairing reminders |
186| Calls | `calls_reserve_schedule` | Bind a workflow UUID to a keyed request fingerprint |
187
188Each new edit requires the revision returned by its app's read operation and a
189fresh UUID `client_id`. An exact retry returns its original acknowledgement;
190a changed request with that UUID conflicts. Read again for the current content.
191This is bounded editing support, not complete browser feature parity: Docs rich
192formatting, Sheets tab/format management, and Calendar recurrence/cancellation
193remain outside these new operations.
194
195`oficina calls schedule --team acme --input schedule.json` invokes
196[resumable scheduling](docs/resumable-scheduling.md). It creates an optional Docs
197agenda, a Calls meeting, and a Calendar event containing their member URLs.
198The same operation is available through HTTP and MCP. It requires read and write
199scopes in each selected app. No invitation is sent and a URL grants no access.
200A partial result identifies confirmed and unconfirmed steps. Resume with the
201same UUID and exact original JSON: a lost response may hide a committed write.
202This is synchronous retry-based recovery, not a background job or a transaction
203spanning apps.
204
205Run `python3 scripts/suite-interop.py --workspace /path/to/oficina` with sibling
206`docs-agent-access`, `calls-agent-access` and `calendar-agent-access` worktrees.
207It builds opt-in test binaries and uses temporary sealed app stores and private
208HTTPS fixtures. The test exercises CLI creation, a lost committed response,
209fresh-gateway MCP resumption, readable linked resources, exact retries, conflicting
210retry arguments and revocation. No live account or production service is used.
211