oficina / agent-access Public

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

Plain git — no account needed to clone.

Download this file

Oficina agent access

One operation contract for Oficina HTTP APIs, the oficina CLI, and MCP. The transport and credential interfaces are independent of the app operations so they can be replaced by Rastrillo implementations later.

Status: implementation in progress. Shared operations, HTTP/MCP adapters, the CLI, browser consent with PKCE, rotating refresh tokens and revocation are implemented. Tests exercise browser authorization through an HTTPS fixture, including real loopback callbacks and the signed Home identity handoff. A runnable connection service and reviewed adapters for Docs, Sheets, Memoria, Calendar, Calls and Slides are on feature branches, exposing 27 app operations plus the shared calls_schedule workflow (28 total). Live four-client acceptance and deployment remain outstanding. No production endpoint is deployed.

Each request supplies a verified person, client, grant, selected teams and scopes. The registry rejects unauthorized team/scope combinations before calling an app, validates inputs and outputs, and returns bounded JSON. The app remains responsible for current local admission, resource access, data storage and edit semantics. MCP uses the official Go SDK, with stateless requests to avoid retaining one person's authorization in another request.

Run make ci for formatting, vet, and tests. Integration tests drive the same operation through HTTP and MCP and verify that grant revocation prevents writes through an already connected MCP client.

Rastrillo coordination. The JSON API framework landed at Rastrillo 2e833dd; its MCP and OAuth packages are separate ongoing work. This module will not wait on them, per Paul's 2026-10-24 direction.

The grant package is mounted by the connection service with verified browser identity and current-team callbacks. The issuer and consent UI run separately from Home's credential origin. App tokens are restricted to one audience, team and scope set; RemoteVerifier checks them online before the app resolves the Home subject to an existing local account. Revoking the parent grant also invalidates every downstream token.

oficina auth login --server https://… opens the system browser and stores the connection in the OS credential store. oficina tools lists operations; oficina notes create --team acme --input note.json calls one. oficina mcp serve provides a local stdio adapter backed by the same API. The server must have this integration mounted; these commands do not work against the current production apps yet. oficina auth logout revokes the server-side connection and then removes local credentials. If revocation fails it keeps the credential so you can retry. oficina teams list and MCP oficina_connection discover currently permitted team IDs; ordinary commands never open a browser implicitly.

Running the connection service

For local development, build go build ./cmd/oficina-connect and go build ./cmd/oficina. oficina-connect -config connection.json -db /persistent/connect.db listens on 127.0.0.1:8080 behind an HTTPS reverse proxy preserving the public Host. Configure an independent origin such as https://connect.example.test; this is separate from both Home's credential and directory origins. Forwarding headers never choose a trusted host or issuer. The service exposes /mcp, /api/v1/operations, /api/v1/connection, OAuth metadata, and /connections for browser revocation.

Configuration fields are origin, home_issuer, consumer_id, home_keys (a key-ID to base64 Home signing-public-key map), directory, clients, and routes. A route binds team, resource (the app HTTPS origin plus /api/v1), and operations (the app's exported operation descriptors). Routes are operator configuration, never tool arguments. Only current Home membership and live app destinations matching those configured routes are eligible. Configure the Home consumer with this origin and the /auth/assertion callback. Require an existing admitted local app account linked to Home; the service does not provision one.

Set OFICINA_CONNECT_DEK to a persistent, random 32-byte base64 encryption key and OFICINA_DIRECTORY_TOKEN to a random service token of at least 32 bytes via deployment secret configuration. Home's directory role stores only the SHA-256 hex digest as HOME_AGENT_DIRECTORY_TOKEN_SHA256. That new Home endpoint is currently on its feature branch and must be deployed before this service can work. Rotation requires coordinated configuration and process restarts. Keep the DEK stable across restarts; changing it invalidates pending identity/consent flows.

oficina-cli is registered automatically for a random loopback callback port. Remote MCP hosts must be registered in clients, with a unique id, a person- readable name, and exact HTTPS redirects. There is no dynamic client registration. Use authorization-code + S256 PKCE and the /mcp resource audience. Registration and host interoperability must be verified before offering a host as supported.

Consent requires a Home authentication at most five minutes old. Connections expire after 90 days; access tokens last five minutes, rotating refresh tokens have a 30-day idle lifetime, and downstream app tokens last at most one minute. Current membership is checked online. Reusing a consumed refresh token revokes its whole connection. Cleanup retains refresh replay evidence until the parent connection ends. A disconnected browser connection stops downstream tokens too.

The service retains opaque identity, client, team, scope and grant metadata. It never persists operation payloads or results. App implementations retain their own content storage, permissions and retry receipts. JSON validation preserves large integer IDs and decimal bounds and cannot fetch external schema references.

Rastrillo convergence

The agent on docs-t1 confirmed explicit descriptors, shared policy checks and verifier/actor interfaces as the intended integration boundary in discussion 116. The Oficina Operation, Verifier and gateway contracts isolate the current SDK/HTTP implementation. Memoria's handwritten operations are the first planned interoperability fixture. Replacing these adapters requires parity, revocation and numeric-fidelity tests; this branch does not claim upstream compatibility until those tests run against the released Rastrillo implementation.

Initial client targets

Paul selected all four: Oficina CLI, Paseo, ChatGPT and Claude (2026-10-25). The CLI browser flow and SDK-level HTTP/MCP flow have automated TLS coverage. Real hosted-client runs remain a release gate; none is claimed here as deployed.

| Client | Initial connection | Verification still needed | | --- | --- | --- | | Oficina CLI | oficina auth login --server <origin>, OS credential store | Deployed Home/app flow with a real linked account | | 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 | | 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 | | 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 |

Give each remote host its own client ID and exact redirect allowlist. The service supports public-client none with S256 PKCE, not client secrets or client assertions. Choose the host's predefined/own OAuth client option and use its actual displayed callback. Do not enable automatic registration or published identity/CIMD against this implementation: those paths are not implemented. Remote-host support requires a public HTTPS endpoint reachable by that host. A locally launched Paseo provider requires the CLI connection on that same machine; credentials are not copied to another Paseo host automatically.

ChatGPT supports predefined OAuth clients and Streamable HTTP, and requires the advertised issuer to match authorization-response iss. This server advertises and returns that value. Register the exact callback shown for the connection; do not infer one from a hostname. See OpenAI authentication and custom MCP setup. Claude exposes an own-OAuth-client configuration option; its remote connector runs from Anthropic's cloud even on desktop. See Claude custom connectors.

For each host, record the tested host version/date, configured client ID (never credentials), callback, consent scopes/teams, and results. Required exercises: allow and deny; missing scope; wrong team; create and same-key retry; explicit invitation-link permission where applicable; refresh; revoke in /connections; then repeat a call in the already open host session and require refusal.

Credential introspection includes identity_issuer, the fixed Home identity namespace, distinct from the connection service issuer. Each app must supply its configured Home issuer to NewRemoteVerifier; subjects are released only after an exact match. A grant database binds that Home issuer persistently and refuses a changed issuer or an unbound database already containing grants. Changing the Home authority requires an explicit migration, not a configuration-only restart.

Platform deployment

OFICINA_CONNECT_CONFIG_BASE64 selects the Rastrillo/CARLOS runtime before standalone flag parsing. It contains the same strict public JSON as -config, limited to 64 KiB decoded. Secrets remain separate. This mode accepts serve, -socket, -addr, and -db; relative database paths resolve beneath STATE_DIRECTORY. It provides framework health/version probes and graceful shutdown. -config and -listen belong to standalone mode and are refused here. See the runtime contract for limits and tests.

Build committed release artifacts with scripts/build-release.sh /absolute/output. The output includes Linux/arm64 service and CLI binaries, native equivalents, VERSION (the full source SHA), and SHA256SUMS. Use exactly that VERSION as carlos deploy --version; the service reports it from /api/version.

Before publishing, run scripts/vet-release.py /absolute/output --carlos /path/to/carlos. This uses a temporary local CARLOS store and a synthetic configuration; no upload or infrastructure change occurs. It checks the native artifact through the real carlos vet --boot contract. Repeat on Linux/arm64 with --target linux-arm64 for the deployment artifact. The generated fixture is only for boot verification, never a production secret or a valid live app registration.

Editing and interoperability

The shared conventions define opaque IDs, resource references, revision preconditions, immutable retry acknowledgements and stable failure categories. Existing operation names and identifier types are retained.

| App | Added operation | Supported editing | | --- | --- | --- | | Docs | docs_update | Bounded paragraph/heading splices; untouched rich content is preserved | | Sheets | sheets_set_range | Atomic ordered cell inputs with native formula recalculation | | Slides | slides_update_deck | Thirteen discoverable semantic operation variants | | Memoria | notes_get, notes_update | Read/replace local notes with indexing; imported items remain read-only | | Calendar | calendar_update_event | Patch single noncancelled events, preserving omitted fields and repairing reminders | | Calls | calls_reserve_schedule | Bind a workflow UUID to a keyed request fingerprint |

Each new edit requires the revision returned by its app's read operation and a fresh UUID client_id. An exact retry returns its original acknowledgement; a changed request with that UUID conflicts. Read again for the current content. This is bounded editing support, not complete browser feature parity: Docs rich formatting, Sheets tab/format management, and Calendar recurrence/cancellation remain outside these new operations.

oficina calls schedule --team acme --input schedule.json invokes resumable scheduling. It creates an optional Docs agenda, a Calls meeting, and a Calendar event containing their member URLs. The same operation is available through HTTP and MCP. It requires read and write scopes in each selected app. No invitation is sent and a URL grants no access. A partial result identifies confirmed and unconfirmed steps. Resume with the same UUID and exact original JSON: a lost response may hide a committed write. This is synchronous retry-based recovery, not a background job or a transaction spanning apps.

Run python3 scripts/suite-interop.py --workspace /path/to/oficina with sibling docs-agent-access, calls-agent-access and calendar-agent-access worktrees. It builds opt-in test binaries and uses temporary sealed app stores and private HTTPS fixtures. The test exercises CLI creation, a lost committed response, fresh-gateway MCP resumption, readable linked resources, exact retries, conflicting retry arguments and revocation. No live account or production service is used.