Operator HTTP API
All paths are relative to /api/mods/burrow-menagerie. This API is for authenticated operator integrations. Agent tools have their own narrower tool schemas; do not send HTTP-only fields to them.
Core supplies trusted operator authentication to every route. Missing or malformed authentication is rejected; Core's explicitly disabled-auth mode is supported. Every response uses Cache-Control: no-store. Errors normally use { "ok": false, "error": "public_error_code" }; some actionable conflicts and capability errors instead include a machine-readable code and a readable error message. Unexpected failures return internal_error, not raw exception or provider details.
Request objects are closed: unknown fields are rejected. String limits below use JavaScript UTF-16 code units. Examples use synthetic IDs, not installed models or real identities.
Resident lifecycle and selection
| Method | Path | Input / result |
|---|---|---|
| GET | /residents | {ok:true,residents} with native identity fields, ownerAgentId and hasReferenceImage |
| POST | /residents | Create body below; {ok:true,resident,replayed} |
| GET | /residents/:agentId | {ok:true,resident,notebook,inventory,recentInteractions,dreamConfiguration} |
| PUT | /residents/:agentId | Nonempty subset of editable create fields, excluding id; {ok:true,resident} |
| DELETE | /residents/:agentId | No body. Permanently removes the resident; {ok:true,agentId,replayed} |
| GET | /models | {ok:true,models} from Core's safe model catalog |
| GET | /owner-agents | {ok:true,agents:[{id,name,enabled}]}; excludes Menagerie residents |
{
"id": "moss",
"name": "Moss",
"soul": "",
"orientation": "",
"modelConnectionId": "connection-from-model-catalog",
"model": "model-from-model-catalog",
"ownerAgentId": null,
"capabilities": {"a2a": true, "forge": true, "brains": false, "mcp": false, "skills": false},
"visibility": {"agents": false, "chat": false}
}
Required create fields are id, name, soul, orientation, modelConnectionId and model. Soul/Orientation may be empty. Optional capabilities/visibility merge with the defaults shown. ownerAgentId omitted or null means independent.
- ID: 1–96 ASCII letters, digits,
.,_or-, excluding.and... - Name: nonblank, maximum 64. Model connection: maximum 128. Model: maximum 256. These three values must not have surrounding whitespace.
- Soul and Orientation: maximum 100,000 each.
- Model changes require both model fields together and an available catalog pair.
- New owner assignments require an enabled nonresident directory agent. An unchanged saved owner is retained even if disabled or unavailable.
visibility.agentscontrols native sidebar placement. Compatibility fieldvisibility.chatdoes not hide enabled residents from native chat.- Requests to enable
brains,mcp,skillsor unknown capabilities are rejected.
Native resident summaries include agentId, name, avatar, enabled, modelConnectionId, model, capabilities and visibility. Detail/create/update profiles include world-owned identity documents and ownership where applicable; the avatar response is only the native projection.
Safe creation and update retries
Creation records its intent before native identity creation. After an uncertain response, retry the same ID and identical original body. Changed create input under that ID is a conflict. Existing regular or foreign identities are never adopted, overwritten or migrated. An existing mod identity without the recorded creation intent is not an adoption route either.
Native metadata and world records are separate stores, not a distributed transaction. Retry an uncertain profile update with the same intended values. Do not delete state to repair a conflict. Use one writable active mod host.
Permanently delete a resident
Only the operator can DELETE /residents/:agentId. There is no undo. Check the ID, not just the display name. The first request requires both a registered world resident and a verified Menagerie-owned native identity. An ordinary agent, foreign mod agent or unregistered identity is never adopted or removed. If the installed Core lacks context.agents.owned.remove, the request returns 503 (upgrade_core_for_owned_agent_removal) without starting deletion. There is no disable-only or local-purge fallback.
Return all outstanding loans involving the resident first (409, return_outstanding_loans_before_deleting_resident). This preserves custody rather than destroying someone else’s property or inventing a return. If Core reports agent_has_active_work (409), let the active or queued work finish and retry. Core removes the native identity and its Dream schedule together; Menagerie retires the resident’s pending visit opportunities. Already submitted turns in other agents’ sessions are not erased or cancelled.
Deletion removes the profile (including SOUL, orientation and assignment), personal notebook and revisions, Dreams, the resident’s own visitor journal, private holdings and their retry snapshots. Other people’s holdings and journals, shared gifts, loans, interactions and referenced inventory provenance survive. A lot needed by another record stays as historical evidence, with zero live quantity if it belonged to the deleted resident. This is not a global erasure of all mentions of an ID or a purge of backups and diagnostics.
After a timeout, interruption or lost acknowledgement, Menagerie resumes a durably pending deletion when the mod starts. Reload Settings to see the current resident list; no manual REST request is needed for recovery. If recovery fails, the server logs menagerie_resident_deletion_recovery_failed with the ID, a safe code and an action. Resolve the reported issue, then restart the mod while the marker is pending or retry DELETE with the exact same ID. An active-work rejection releases the marker, so retry Delete after that work finishes. An interrupted deletion can be hidden from the active resident list while pending. Core rechecks ownership before cleanup resumes; a foreign identity at that ID blocks cleanup. A completed retry reports replayed:true without touching Core again. The ID remains retired within Menagerie to keep old retries and surviving history separate from any new identity. Choose a new ID for a new resident. Use one active writable mod host; do not manually edit the settings rows.
Images
| Method | Path | Input / result |
|---|---|---|
| PUT | /residents/:agentId/avatar | {avatar} → {ok:true,resident} |
| GET | /residents/:agentId/reference-image | {ok:true,referenceImage} |
| PUT | /residents/:agentId/reference-image | {fileName,content} → {ok:true,referenceImage} |
| DELETE | /residents/:agentId/reference-image | {ok:true,referenceImage} |
Avatar is a string up to 512,000 code units. Empty clears it; a nonempty value must begin data:image/. The native host owns further avatar handling. The Settings UI uses the host's avatar optimization, not the original-photo store.
Reference images use a full base64 PNG/JPEG/WebP data URL in content and a nonblank fileName up to 256. Maximum decoded size is 20 MiB. Core validates image signatures and preserves original bytes in the canonical agent reference store. Missing support returns reference_images_unavailable; there is no mod-local Forge fallback. Images and separate save scopes explain the operator UI.
Notebook and inventory
| Method | Path | Input / result |
|---|---|---|
| GET | /residents/:agentId/notebook | {ok:true,entries} |
| POST | /residents/:agentId/notebook | {operationKey,text,title?,tags?,aboutAgentIds?} → {ok:true,entry,replayed} |
| PUT | /residents/:agentId/notebook/:entryId | {operationKey,text?,title?,tags?,aboutAgentIds?} → {ok:true,entry,replayed} |
| DELETE | /residents/:agentId/notebook/:entryId | {operationKey,expectedUpdatedAt} → {ok:true,deleted:true,entryId,replayed} |
| GET | /residents/:agentId/inventory | {ok:true,items} |
| POST | /residents/:agentId/inventory | {operationKey,item:{name,quantity,consumable,description?}} → {ok:true,item,replayed} |
| PUT | /residents/:agentId/inventory/:itemId | {operationKey,expectedUpdatedAt,name?,description?,quantity?,consumable?} → {ok:true,item,replayed} |
| DELETE | /residents/:agentId/inventory/:itemId | {operationKey,expectedUpdatedAt} → {ok:true,item,replayed} |
Notebook text is nonblank and at most 8,000; title at most 200; up to 20 unique tags of at most 64 each; up to 30 unique aboutAgentIds. An update needs at least one editable field. Omitted fields remain unchanged. Writes preserve original authorship/source and add revision/edit metadata with trusted operator attribution.
Reuse the same operationKey and input for a retry. Changed input with an old key conflicts. A replay returns the original result snapshot; read current state when you need the latest record. Inventory writes use trusted operator attribution. Added items are owned and held by the selected resident. Updates require at least one editable field and the exact updatedAt value last read in expectedUpdatedAt; stale edits return HTTP 409 with code: "inventory_item_conflict" and a readable error message. The target must be held by the selected resident. Name, description, quantity and consumable bounds match the item schema. An omitted field is retained. Ownership, holder, origin and annotations are preserved, with an operator-edit history event. A borrowed lot's quantity cannot change (borrowed_quantity_fixed). Resident and assigned-parent tools now also expose update/delete with trusted agent attribution and saved ownership checks; these HTTP routes remain operator-authenticated. Notebook deletion applies to any author, removes revisions, and rejects stale deletes with notebook_entry_conflict (409). Prior write/update retries for that note report deletion rather than returning deleted content.
Inventory removal uses the same exact last-read expectedUpdatedAt and stable retry key. This HTTP route is operator-authenticated and resident/holder-scoped. A stale token or already-zero item returns inventory_item_conflict (409); an active borrowed lot returns borrowed_quantity_fixed (409). Success sets quantity to zero, appends an operator-removed event and returns the retained item. Current inventory reads omit it, but origin, owner/holder, prior history and exchange records are not purged. The agent tool has a separate delete operation for resident self or assigned-parent scope. Retry the identical body/key after an uncertain result; a replay returns the original result rather than deleting again.
Visitor journal
GET /visit-log returns {ok:true,entries,hasMore,nextCursor} for operator browsing. Optional query parameters are resident agentId, visitorAgentId, decimal limit (1–200, default 50), and a returned cursor (at most 256 units). HTTP agent IDs use the resident ID format and 96-character limit. The resident filter accepts an active resident or an ID with completed deletion so preserved journals can still be read. Date, timezone, search and unknown query fields are rejected.
Agent entries contain id, resident agentId, trusted visitorAgentId, summary, optional unfinished, source, createdAt and updatedAt. They sort newest first by recording time with descending ID as tie-breaker; a cursor must belong to the filtered result. Restart without a cursor when filters change. This endpoint can browse all visitors, unlike the caller-scoped agent journal tool. POST /residents/:agentId/visit-log accepts {operationKey,visitedOn,summary} and returns {ok:true,entry,replayed}. Operator entries carry source.kind: "operator" and a calendar date (visitedOn, YYYY-MM-DD), not a visitorAgentId. Enter an actual calendar date and a nonblank summary up to 4,000 UTF-16 code units. The visited resident can read these notes on demand. There are no journal update/delete routes.
Autonomous visits
GET /social-visits/settings returns {ok:true,configuration}. PUT /social-visits/settings requires the complete object below and returns the same envelope:
{"enabled":false,"minRunMinutes":20,"chancePercent":25,"cooldownMinutes":240}
enabled is boolean. All three numbers are nonnegative safe integers; chancePercent is at most 100. Unknown or missing fields are rejected. Saving changes global configuration, not a resident profile, and does not itself trigger a visit. See eligibility, delivery and disabling.
Authenticated GET /social-visits/decisions returns {ok:true,cursor,initialized,historyStartCursor,decisionLimit,decisions,pending}. The bounded last-200 decisions retain run metadata, configuration, gate/coin reason and percentage draw, selected resident and dispatch/settlement state. Pending reservations independently retain defer/block reasons. This endpoint is read-only; it neither rerolls decisions nor queues visits. Reasons predating historyStartCursor are unavailable, not reconstructed.
Visit session and turn identity
The diagnostic pending record may include sessionIdempotencyKey, persisted before dispatch. New visits use the stable menagerie-visit-session:v1:<resident agent ID> session key, scoped by Core to the owning agent and mod. Each event still has a distinct menagerie-visit:<event cursor>:<resident agent ID> turn key. Legacy uncertain submissions retain their old event-derived session binding on retry. These are diagnostic values, not fields accepted by the visit-settings endpoint or a replay API. No session histories are merged, deleted or renamed.
Light Dreams
| Method | Path | Input / result |
|---|---|---|
| GET | /residents/:agentId/dreams/configuration | {ok:true,configuration} |
| PUT | /residents/:agentId/dreams/configuration | All five fields below; {ok:true,configuration} |
| POST | /residents/:agentId/dreams/run | Empty body/object → HTTP 202 {ok:true,run} |
{
"enabled": false,
"cron": "0 2 * * *",
"prompt": "Reflect on the supplied day in your own voice. Keep meaningful personal notes and leave a light Dream for the operator.",
"modelConnectionId": null,
"model": null
}
The model pair is both null to inherit, or an exact catalog pair. Prompt may be empty, maximum 16,000; cron is nonblank, maximum 256, parsed by Core. Run-now uses saved configuration and can create the default disabled job without enabling recurrence. The asynchronous receipt is not a model answer or proof of a saved reflection. See light Dreams for day evidence, timezone and explicit Archive writes.
Native turn integration hooks
| Method | Path | Input / result |
|---|---|---|
| POST | /residents/:agentId/chat | {sessionId,message,idempotencyKey} → HTTP 202 {ok:true,turn,replayed} |
| GET | /turns/:turnId | {ok:true,turn} for a mod-owned resident turn |
These remain integration hooks, not a second operator chat UI. message is nonblank, maximum 100,000; sessionId maximum 128; idempotencyKey maximum 256. Session/key must not have surrounding whitespace. Core can impose its own narrower native session validation. The menagerie-dream- session prefix is reserved. Read the turn receipt until terminal; a completed native result can include result.answerText. Reuse the submission key and unchanged input after an ambiguous result.
Archive
| Method | Path | Result |
|---|---|---|
| GET | /archive/participants | {ok:true,participants:[{agentId,name?}],complete:true}; accepts no query fields |
| GET | /archive/gifts | {ok:true,entries,hasMore,nextCursor} |
| GET | /archive/interactions | Same page envelope |
| GET | /archive/dreams | Same page envelope; explicit Menagerie reflection records |
Page query fields:
date:YYYY-MM-DDcivil day.timeZone: valid IANA timezone, maximum 100. With a date, selects that civil day including DST. Omitted means UTC. A timezone alone does not limit dates.search: literal case-insensitive substring, maximum 500 before trimming. Empty/whitespace adds no filter.agentId: participant ID, using the resident ID format/limit above.limit: decimal query string from 1 to 200; default 50.cursor: returned record ID; omit for the first page.
Filters run before pagination. Change any filter and start without a cursor. A cursor must belong to the filtered result. Gifts and Dreams sort by creation time descending; interactions by when, falling back to creation time; descending record ID breaks ties. The final page has nextCursor:null.
Search matches individual current record fields, including narrative, item descriptions, provenance, references, IDs, timestamps and current saved resident names. It does not search old revisions, unrelated notebooks or identity documents. It is not regex, fuzzy search, accent folding or a phrase assembled across fields. The participant catalog includes all saved residents and recorded exchange/interaction/Dream agents across every page/day, without looking up unrelated native profiles. Operator parties are not agent-filter entries.
Error handling
Use HTTP status and error together. Typical groups are validation 400, operator authentication 401, scope/ownership 403, missing record/model 404, changed retry input or lifecycle conflict 409, oversized reference image 413, and unavailable Core services/context 503. A successful queue receipt does not promise execution succeeded. Preserve retry input on uncertain writes, inspect current records after replay, and use the troubleshooting guide rather than resetting identities or mod state.
Reconcile an explicitly confirmed duplicate gift
POST /residents/:agentId/inventory/:itemId/reconcile-duplicate is operator-authenticated and requires:
{
"operationKey": "stable-correction-key",
"canonicalItemId": "original-item-id",
"expectedUpdatedAt": "duplicate-item-updatedAt",
"canonicalExpectedUpdatedAt": "original-item-updatedAt"
}
Success returns {ok:true,replayed,item,canonicalItem,entry,canonicalEntry}. :itemId selects the duplicate to retire. Read both current inventory records first. The operation keeps the canonical item and its original provenance, retires the duplicate without erasing history, supersedes its gift registry entry, and adds attributed cross-references. Ordinary gift/archive listings omit the superseded entry; raw state retains it for audit. No agent tool or parent permission grants this operator correction.
Only distinct positive, self-owned and self-held unsplit root holdings of this resident with exactly one matching gift receipt each qualify. Giver and recipient must be known and equal across both records; item and gift quantities must match. Prior edits, loans, transfers, use, crafting, consumption or previous reconciliation make the pair ineligible. Matching names alone are not evidence that two items are one gift. Stale tokens return inventory_item_conflict (409); other ineligible pairs return duplicate_gift_not_eligible (409). Reuse the exact input and operation key on retry. No fuzzy matching, pending inbox or approval workflow is introduced.