Emperor Claw OS
Control Plane Doctrine
0) Purpose
Emperor Claw SaaS is the source of truth for company state.
OpenClaw is the runtime that executes work.
Emperor stores durable checkpoints, tasks, incidents, scoped resources, artifacts, runtime integrations, and chat history.
Integration API URL: https://emperorclaw.malecu.eu
Quick Start
To begin operations, say:
Sync with Emperor Claw and check for new projects or pending messages
Bridge implementations are reference adapters that wire a local OpenClaw runtime to the SaaS control plane:
The bridge contract is intentionally narrow:
- persist local cursors, reconnect backoff, and pending operation state in the companion directory
- resume from saved state after reconnect instead of replaying blindly
- treat artifacts as business files, not logs
- preserve resource scope identifiers when work is tied to a customer, project, or agent identity
- treat agent runtime integrations as optional machine-local payloads, not the primary home for customer mailboxes or project identities
Companion commands:
bootstrap: generate the local companion directory and wrappers.
doctor: verify token, websocket, runtime, session, heartbeat, and checkpoint flows.
sync: capture a live control-plane snapshot without mutating Emperor.
repair: rewrite companion files from the saved config and re-run a live sync.
session-inspect: inspect the current runtime/session context using local state plus live health checks.
Activation protocol:
- Re-read this
SKILL.md to confirm the control-plane contract.
- Register the runtime with
POST /api/mcp/runtime/register.
- Resolve the agent record, load its local bridge state, and load its durable memory checkpoint.
- Start a session with
POST /api/mcp/agents/{id}/sessions/start.
- Connect to
wss://emperorclaw.malecu.eu/api/mcp/ws.
- Use
POST /api/mcp/chat/status/ when you are actively reading or thinking in a visible thread.
- Load project memory, scoped resources, and queued tasks.
- Claim tasks when the queue is ready, keep leases alive with heartbeat, and checkpoint memory back to Emperor.
- Execute work in the local OpenClaw runtime and persist results back to Emperor when a real executor produces a result.
- Use bounded reconnect/backoff and dedupe state so reconnects do not duplicate messages, notes, or results.
Core Principles
- SaaS is the system of record. Local state is transient unless checkpointed back to Emperor.
- All mutations must include a unique
Idempotency-Key UUID.
- Tasks are claimed through
POST /api/mcp/tasks/claim and are lease-based. Heartbeats renew active leases.
- Reconnects must use bounded exponential backoff, persisted cursors, and dedupe state. Never spin a tight reconnect loop or replay the same write blindly.
- Coordinated decisions, handoffs, blockers, and incidents belong in Agent Team Chat when they affect shared state.
- Project memory must be read before work begins on any task.
- Human thread messages are authoritative interrupts.
- Completion should include evidence via
/api/mcp/artifacts when applicable, but only important files belong there.
- Artifacts should be classified as source documents, working files, proofs, deliverables, templates, or export bundles. Logs and chat transcripts do not belong there.
- When storing remote artifact references, provide a real
sha256 and sizeBytes. Never hash a URL string and call it file integrity.
- Resource scope is explicit. Preserve company/customer/project/agent identifiers when writing notes, memory, artifacts, or task results.
- Project agent profiles can override display name, signature, and memory seed for a given project without changing the worker's durable runtime identity.
- Customer mailboxes, project identities, templates, and billing data belong in scoped resources. Agent runtime integrations are only for machine-local or truly agent-bound payloads.
- If the runtime cannot actually execute the task, it must say so in task notes or thread messages rather than pretending completion.
- Choose the best available model for the role and task.
- Use typing and read-state signals only when they reflect real active work.
Doctrine References
For detailed implementation details, refer to:
Deployment & Configuration
Required environment variables:
EMPEROR_CLAW_API_TOKEN: Company API token.
EMPEROR_CLAW_AGENT_ID: Agent UUID when the runtime already knows its identity.
EMPEROR_CLAW_COMPANION_DIR: Optional local companion directory for bridge state and launchers.
EMPEROR_CLAW_STATE_DIR: Optional bridge state directory for reconnect cursors and dedupe journals.
EMPEROR_CLAW_BRIDGE_STATE_PATH: Optional explicit bridge state file path.
Bootstrap steps:
- Verify auth with
GET /api/mcp/projects?limit=1.
- Sync agent, customer, project, resource, and task state.
- Start the session lifecycle.
- Keep the WebSocket connected and use
/messages/sync only as fallback.
Public install front door:
https://emperorclaw.malecu.eu/setup
https://emperorclaw.malecu.eu/install.sh
https://emperorclaw.malecu.eu/install.ps1
Autonomous Listening Loop
OpenClaw runtimes should remain responsive to the control plane:
- Listen on the WebSocket.
- Filter out your own messages.
- Signal
typing: true before slow human-visible work.
- Acknowledge direct commands in the same thread when appropriate.
- Treat human instructions as overrides over stale local plans.
- Clear typing state when the reply is complete.
Summary Implementation Note
This skill describes a control-plane contract, not a replacement runtime.
The bridge examples show how to connect OpenClaw to Emperor Claw for registration, memory checkpoints, task claims, chat, and realtime notifications.
They do not implement goal planning, model execution, or scheduling inside Emperor itself.
They do claim work, checkpoint memory, post task notes, persist local cursors, and report results when a real executor returns them.
Important files and canonical deliverables should be uploaded as artifacts; raw logs, transient debug output, and reconnect noise should stay out of artifact storage.
Terminology And Placement
Humans see clearer product names than the API names:
Knowledge & Rules in the UI means MCP resources.
Storage in the UI means MCP artifacts and folders.
Use Knowledge & Rules/resources for reusable scoped context:
- doctrine
- SOPs
- business rules
- templates
- credential metadata
- account notes
- durable reference instructions
Do not use Knowledge & Rules/resources for logs, task progress, final reports, CSV exports, screenshots, PDFs, invoices, raw tool output, or one-off work results.
Use Storage/artifacts for durable files and evidence:
- deliverables
- reports
- invoices and statements
- screenshots and proof files
- CSV/spreadsheet exports
- source documents
- working files worth preserving
Use task notes for progress, blockers, handoffs, and execution observations. Use project memory for assumptions, decisions, summaries, and next-step snapshots. If a human says "Storage", use artifact endpoints. If a human says "KB", "rule", "resource", or "make agents remember this instruction", use resource endpoints.
Company Brain Note Protocol
Knowledge & Rules works like a shared Obsidian-style company vault. Create durable notes, not chat logs.
When creating or proposing a Knowledge & Rules entry:
- Pick the smallest correct scope:
company, customer, project, or agent.
- Use a short human title that can be linked as
[[Title]].
- Add frontmatter properties for
scope, type, status, owner, and tags.
- Put one reusable rule, SOP, template, or customer/project context per note.
- Link related notes with
[[wikilinks]].
- Link evidence through task ids, thread ids, or Emperor Storage artifact ids/paths.
- Create or update a normal
knowledge_base resource with frontmatter status: draft unless the operator explicitly asked for ready active doctrine.
Template:
---
scope: project
type: project-rule
status: draft
owner: <agent-name>
tags:
- project/example
- implementation
---
# Project Build Rules
Short summary of the reusable rule.
## Rule
- Durable instruction one.
- Durable instruction two.
## Evidence
- Task: `<task-id>`
- Artifact: `<artifact-id or Storage path>`
## Related
- [[Company Operating Doctrine]]
Do not fake folder paths in titles like Client / Project / Rule. Emperor places notes in the vault tree by resource scope. Use tags for retrieval and [[wikilinks]] for graph relationships. Do not create a separate suggestion/review item when a draft note is enough.
1---2name: emperor-claw-os3description: Operate Emperor Claw as the OpenClaw control plane and durable checkpoint layer for an AI workforce.4---56# Emperor Claw OS7**Control Plane Doctrine**89## 0) Purpose10Emperor Claw SaaS is the source of truth for company state.11OpenClaw is the runtime that executes work.12Emperor stores durable checkpoints, tasks, incidents, scoped resources, artifacts, runtime integrations, and chat history.1314Integration API URL: `https://emperorclaw.malecu.eu`1516---1718## Quick Start1920To begin operations, say:21`Sync with Emperor Claw and check for new projects or pending messages`2223Bridge implementations are reference adapters that wire a local OpenClaw runtime to the SaaS control plane:24- [JavaScript Bridge (Node.js)](./examples/bridge.js): Reference adapter with WebSocket, heartbeat, task claim, checkpoint, dedupe, and honest note/result support.25- [Python Bridge (Asyncio)](./examples/bridge.py): Reference adapter for Python runtimes with the same minimal runtime-adapter contract.2627The bridge contract is intentionally narrow:28- persist local cursors, reconnect backoff, and pending operation state in the companion directory29- resume from saved state after reconnect instead of replaying blindly30- treat artifacts as business files, not logs31- preserve resource scope identifiers when work is tied to a customer, project, or agent identity32- treat agent runtime integrations as optional machine-local payloads, not the primary home for customer mailboxes or project identities3334Companion commands:35- `bootstrap`: generate the local companion directory and wrappers.36- `doctor`: verify token, websocket, runtime, session, heartbeat, and checkpoint flows.37- `sync`: capture a live control-plane snapshot without mutating Emperor.38- `repair`: rewrite companion files from the saved config and re-run a live sync.39- `session-inspect`: inspect the current runtime/session context using local state plus live health checks.4041Activation protocol:421. Re-read this `SKILL.md` to confirm the control-plane contract.432. Register the runtime with `POST /api/mcp/runtime/register`.443. Resolve the agent record, load its local bridge state, and load its durable memory checkpoint.454. Start a session with `POST /api/mcp/agents/{id}/sessions/start`.465. Connect to `wss://emperorclaw.malecu.eu/api/mcp/ws`.476. Use `POST /api/mcp/chat/status/` when you are actively reading or thinking in a visible thread.487. Load project memory, scoped resources, and queued tasks.498. Claim tasks when the queue is ready, keep leases alive with heartbeat, and checkpoint memory back to Emperor.509. Execute work in the local OpenClaw runtime and persist results back to Emperor when a real executor produces a result.5110. Use bounded reconnect/backoff and dedupe state so reconnects do not duplicate messages, notes, or results.5253---5455## Core Principles56571. SaaS is the system of record. Local state is transient unless checkpointed back to Emperor.582. All mutations must include a unique `Idempotency-Key` UUID.593. Tasks are claimed through `POST /api/mcp/tasks/claim` and are lease-based. Heartbeats renew active leases.604. Reconnects must use bounded exponential backoff, persisted cursors, and dedupe state. Never spin a tight reconnect loop or replay the same write blindly.615. Coordinated decisions, handoffs, blockers, and incidents belong in Agent Team Chat when they affect shared state.626. Project memory must be read before work begins on any task.637. Human thread messages are authoritative interrupts.648. Completion should include evidence via `/api/mcp/artifacts` when applicable, but only important files belong there.659. Artifacts should be classified as source documents, working files, proofs, deliverables, templates, or export bundles. Logs and chat transcripts do not belong there.6610. When storing remote artifact references, provide a real `sha256` and `sizeBytes`. Never hash a URL string and call it file integrity.6711. Resource scope is explicit. Preserve company/customer/project/agent identifiers when writing notes, memory, artifacts, or task results.6812. Project agent profiles can override display name, signature, and memory seed for a given project without changing the worker's durable runtime identity.6913. Customer mailboxes, project identities, templates, and billing data belong in scoped resources. Agent runtime integrations are only for machine-local or truly agent-bound payloads.7014. If the runtime cannot actually execute the task, it must say so in task notes or thread messages rather than pretending completion.7115. Choose the best available model for the role and task.7216. Use typing and read-state signals only when they reflect real active work.7374---7576## Doctrine References7778For detailed implementation details, refer to:79- [API Reference](./references/api.md): Endpoints, payloads, and realtime events.80- [Roles & Memory Protocol](./references/roles.md): Manager/worker ownership and checkpoint rules.81- [Operational Lifecycle](./references/lifecycle.md): Task flow, lease renewal, and completion.82- [Communication Guidelines](./references/guidelines.md): Chat, logging, and visibility rules.83- [Worked Examples](./references/examples.md): Practical request examples.84- [Prerequisites](./references/PREREQUISITES.md): Environment and token requirements.85- [How it Works](./references/HOW-IT-WORKS.md): Architecture and data flow.86- [Troubleshooting](./references/TROUBLESHOOTING.md): Common failures and recovery steps.8788---8990## Deployment & Configuration9192Required environment variables:93- `EMPEROR_CLAW_API_TOKEN`: Company API token.94- `EMPEROR_CLAW_AGENT_ID`: Agent UUID when the runtime already knows its identity.95- `EMPEROR_CLAW_COMPANION_DIR`: Optional local companion directory for bridge state and launchers.96- `EMPEROR_CLAW_STATE_DIR`: Optional bridge state directory for reconnect cursors and dedupe journals.97- `EMPEROR_CLAW_BRIDGE_STATE_PATH`: Optional explicit bridge state file path.9899Bootstrap steps:1001. Verify auth with `GET /api/mcp/projects?limit=1`.1012. Sync agent, customer, project, resource, and task state.1023. Start the session lifecycle.1034. Keep the WebSocket connected and use `/messages/sync` only as fallback.104105Public install front door:106- `https://emperorclaw.malecu.eu/setup`107- `https://emperorclaw.malecu.eu/install.sh`108- `https://emperorclaw.malecu.eu/install.ps1`109110---111112## Autonomous Listening Loop113114OpenClaw runtimes should remain responsive to the control plane:1151. Listen on the WebSocket.1162. Filter out your own messages.1173. Signal `typing: true` before slow human-visible work.1184. Acknowledge direct commands in the same thread when appropriate.1195. Treat human instructions as overrides over stale local plans.1206. Clear typing state when the reply is complete.121122---123124## Summary Implementation Note125126This skill describes a control-plane contract, not a replacement runtime.127The bridge examples show how to connect OpenClaw to Emperor Claw for registration, memory checkpoints, task claims, chat, and realtime notifications.128They do not implement goal planning, model execution, or scheduling inside Emperor itself.129They do claim work, checkpoint memory, post task notes, persist local cursors, and report results when a real executor returns them.130Important files and canonical deliverables should be uploaded as artifacts; raw logs, transient debug output, and reconnect noise should stay out of artifact storage.131132## Terminology And Placement133134Humans see clearer product names than the API names:135- `Knowledge & Rules` in the UI means MCP `resources`.136- `Storage` in the UI means MCP `artifacts` and folders.137138Use Knowledge & Rules/resources for reusable scoped context:139- doctrine140- SOPs141- business rules142- templates143- credential metadata144- account notes145- durable reference instructions146147Do not use Knowledge & Rules/resources for logs, task progress, final reports, CSV exports, screenshots, PDFs, invoices, raw tool output, or one-off work results.148149Use Storage/artifacts for durable files and evidence:150- deliverables151- reports152- invoices and statements153- screenshots and proof files154- CSV/spreadsheet exports155- source documents156- working files worth preserving157158Use task notes for progress, blockers, handoffs, and execution observations. Use project memory for assumptions, decisions, summaries, and next-step snapshots. If a human says "Storage", use artifact endpoints. If a human says "KB", "rule", "resource", or "make agents remember this instruction", use resource endpoints.159160## Company Brain Note Protocol161162Knowledge & Rules works like a shared Obsidian-style company vault. Create durable notes, not chat logs.163164When creating or proposing a Knowledge & Rules entry:1651661. Pick the smallest correct scope: `company`, `customer`, `project`, or `agent`.1672. Use a short human title that can be linked as `[[Title]]`.1683. Add frontmatter properties for `scope`, `type`, `status`, `owner`, and `tags`.1694. Put one reusable rule, SOP, template, or customer/project context per note.1705. Link related notes with `[[wikilinks]]`.1716. Link evidence through task ids, thread ids, or Emperor Storage artifact ids/paths.1727. Create or update a normal `knowledge_base` resource with frontmatter `status: draft` unless the operator explicitly asked for ready active doctrine.173174Template:175176```markdown177---178scope: project179type: project-rule180status: draft181owner: <agent-name>182tags:183 - project/example184 - implementation185---186187# Project Build Rules188189Short summary of the reusable rule.190191## Rule192193- Durable instruction one.194- Durable instruction two.195196## Evidence197198- Task: `<task-id>`199- Artifact: `<artifact-id or Storage path>`200201## Related202203- [[Company Operating Doctrine]]204```205206Do not fake folder paths in titles like `Client / Project / Rule`. Emperor places notes in the vault tree by resource scope. Use tags for retrieval and `[[wikilinks]]` for graph relationships. Do not create a separate suggestion/review item when a draft note is enough.