Shared knowledge for several agents, with permissions
Put the shared material in one Space and give each agent its own principal and API key. The Space owner limits each agent to a directory for reading and a directory for writing, and the memories an agent gets follow the same limits.
Set it up
Make three calls per agent with an admin key. $SPACE_ID is the shared Space.
# 1. Create the Agent. Keep the id from the response (prn_...).
curl -X POST https://api.mirabase.io/v2/principals \
-H "Authorization: Bearer $MIRABASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"kind": "agent", "grant_capabilities": ["knowledge:read", "knowledge:write"]}'
# 2. Make it a member: it reads /projects/acme and writes only under /projects/acme/drafts.
curl -X PUT "https://api.mirabase.io/v2/spaces/$SPACE_ID/members/$AGENT_ID" \
-H "Authorization: Bearer $MIRABASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"role": "editor", "write_mode": "direct",
"read_root": "/projects/acme", "write_root": "/projects/acme/drafts"}'
# 3. Issue its key, narrowed to that Space. The secret is shown once.
curl -X POST https://api.mirabase.io/v2/api-keys \
-H "Authorization: Bearer $MIRABASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"actor_id": "'$AGENT_ID'", "name": "drafts-agent",
"grant_capabilities": ["knowledge:read", "knowledge:write"],
"allowed_space_ids": ["'$SPACE_ID'"]}'
Both directories must exist before step 2.
What each agent then sees
- Inside its read directory: files, search results, context and the memories derived from those files.
- Outside it: nothing. A path outside the read directory returns 404, the same as a path that does not exist, and search results, context packs and memory lists leave it out.
- A write outside its write directory returns 403
outside_write_root. - Every write and every memory carries the agent's own identity in the audit log, and revoking one agent's key affects no other agent.
See Write roots and read roots.
Limits
- A directory scope is set on the member, not on the key: one read directory and one write directory per member in a Space.
- Entries without a path, such as ingested text and project memories, fall outside both directories and are not visible to the member, except for the member's own agent memories.
- A write directory does not limit branches. A merge into the main line is checked path by path and fails as a whole if any path is outside the write directory.
- Only the Space owner can manage members, and creating a principal requires the
tenant_adminrole. - To separate by label instead of by directory, issue a key with a metadata scope. Such a key can read, search, get answers and ingest; other operations return 403. See Limit a key by metadata.