Skip to content

GeneralJerel/chiefclaw

Repository files navigation

ChiefClaw 🦞

AI Chief of Staff for Freelancers

ChiefClaw is an autonomous AI agent that runs the back-office operations of a freelancer's business — inbox, calendar, invoices, tasks, and daily briefings — so they can focus on the work that pays. Powered by OpenClaw and rendered through a generative UI built on CopilotKit and the AG-UI protocol.


The Problem

Freelancers are solo operators wearing too many hats. Between responding to client emails, scheduling meetings, chasing invoices, and keeping track of tasks — hours disappear every week on administrative overhead that doesn't pay.

The Solution

ChiefClaw gives every freelancer an AI agent that autonomously handles the operational layer of their business. When a client emails, the agent responds. When a meeting needs scheduling, the agent sends slots and sets the invite. Every morning, the agent writes a daily brief so the freelancer knows what's on their plate before their first coffee.


System Architecture

graph TB
    subgraph Browser["Browser (React 19 + Vite 7)"]
        CK["CopilotKit Provider"]
        Dashboard["Dashboard UI"]
        MockDB["Mock Database<br/>(in-memory NoSQL)"]
        EB["Event Bus<br/>(BroadcastChannel)"]
        
        CK -->|"useCopilotAction<br/>useCopilotReadable"| Dashboard
        Dashboard -->|"subscribe() / CRUD"| MockDB
        EB -->|"ui:switchView<br/>ui:selectEmail"| Dashboard
    end

    subgraph Vite["Vite Dev Server"]
        Proxy["Reverse Proxy<br/>/v1/clawg-ui → :18789"]
        InfoStub["Info Stub Middleware<br/>/v1/clawg-ui/info"]
    end

    subgraph OpenClaw["OpenClaw Gateway (localhost:18789)"]
        ClawGUI["ClawGUI Plugin<br/>(@contextableai/clawg-ui)"]
        Router["Task Router"]
        State["State Manager"]
        LLM["LLM Provider"]
        
        ClawGUI --> Router
        Router --> State
        Router --> LLM
    end

    CK -->|"POST /v1/clawg-ui<br/>Bearer token auth"| Proxy
    Proxy -->|"Forward"| ClawGUI
    ClawGUI -->|"SSE stream<br/>(AG-UI events)"| CK
Loading

Data Flow: Agent Tool Execution

sequenceDiagram
    participant User
    participant Chat as Chat Panel
    participant CK as CopilotKit
    participant Proxy as Vite Proxy
    participant CG as ClawGUI
    participant OC as OpenClaw Agent

    User->>Chat: "Add a task to follow up with Jessica"
    Chat->>CK: sendMessage({ role: user, content })
    CK->>Proxy: POST /v1/clawg-ui (tools + context + messages)
    Proxy->>CG: Forward with Bearer auth
    CG->>OC: Route to agent with MsgContext
    OC->>CG: Tool call: createtask(...)
    CG-->>CK: SSE: TOOL_CALL_START → ARGS → END
    CK->>Chat: Execute client handler
    Note over Chat: db.collection('tasks').add(...)
    Note over Chat: subscribe() fires → UI re-renders
    OC->>CG: Text: "Done — added follow-up task"
    CG-->>CK: SSE: TEXT_MESSAGE_START → CONTENT → END
    CK->>Chat: Render assistant message
Loading

Client-Side Tool Architecture

The agent controls the dashboard through 11 registered client tools. CopilotKit sends these tool definitions to ClawGUI with every request. When the agent calls a tool, ClawGUI streams the call back to the browser where CopilotKit executes the local handler.

graph LR
    subgraph Tools["Client Tools (useCopilotAction)"]
        direction TB
        Nav["Navigation"]
        Email["Email"]
        Cal["Calendar"]
        Task["Tasks"]
    end

    subgraph NavTools["switchworkspace<br/>selectemail"]
    end
    subgraph EmailTools["sendemail<br/>markemailread<br/>staremail"]
    end
    subgraph CalTools["createcalendarevent<br/>updatecalendarevent<br/>deletecalendarevent"]
    end
    subgraph TaskTools["createtask<br/>updatetask<br/>deletetask"]
    end

    Nav --> NavTools
    Email --> EmailTools
    Cal --> CalTools
    Task --> TaskTools

    NavTools -->|"eventBus.emit()"| UI["Dashboard Views"]
    EmailTools -->|"db.collection('inbox')"| DB["Mock DB"]
    CalTools -->|"db.collection('calendar')"| DB
    TaskTools -->|"db.collection('tasks')"| DB
    DB -->|"subscribe() callback"| UI
Loading

Reactive State Management

All six data collections use the same pattern: useState + db.subscribe() inside useEffect, with useMemo for derived display data. No global state library — React hooks only.

graph TD
    subgraph Collections["Mock DB Collections"]
        inbox["inbox"]
        calendar["calendar"]
        tasks["tasks"]
        clients["clients"]
        briefs["dailyBriefs"]
        invoices["invoices"]
    end

    subgraph Subscriptions["useState + subscribe()"]
        sInbox["setInboxEmails"]
        sCal["setCalendarEvents"]
        sTask["setTasks"]
        sClient["setClients"]
        sBrief["setBriefs"]
        sInv["setInvoices"]
    end

    subgraph Derived["useMemo — Derived Display Data"]
        mockEmails["mockEmails"]
        mockSchedule["mockSchedule"]
        todoItems["todoItems"]
        mockClients["mockClients"]
        dailyBrief["dailyBrief"]
        invoiceDetails["mockInvoiceDetails"]
    end

    inbox --> sInbox --> mockEmails
    calendar --> sCal --> mockSchedule
    tasks --> sTask --> todoItems
    clients --> sClient --> mockClients
    briefs --> sBrief --> dailyBrief
    invoices --> sInv --> invoiceDetails
Loading

Any mutation (from agent tool calls, scenario events, or user interaction) triggers notify() → subscriber callbacks → React re-render. The agent, the demo scenario, and the user all share the same reactivity pipeline.


Authentication & Device Pairing

sequenceDiagram
    participant FE as ChiefClaw Frontend
    participant CG as ClawGUI (port 18789)
    participant GW as OpenClaw Gateway

    FE->>CG: POST /v1/clawg-ui (no auth)
    CG-->>FE: 403 { pairingCode, token }
    Note over FE: User copies pairingCode
    FE->>GW: openclaw pairing approve clawg-ui <code>
    GW->>CG: Device approved
    FE->>CG: POST /v1/clawg-ui (Bearer token)
    CG-->>FE: 200 SSE stream
Loading

Tokens are HMAC-signed with constant-time comparison. The device token is stored in VITE_OPENCLAW_DEVICE_TOKEN or entered manually in the Dashboard connect screen.


Tech Stack

Technology Version Purpose
React 19.2 UI framework
Vite 7.3 Build tool + dev server + reverse proxy
React Router DOM 7.13 Client-side routing (BrowserRouter)
CopilotKit 1.51 Agent UI integration (useCopilotAction, useCopilotReadable, useCopilotChatInternal)
AG-UI Protocol SSE event streaming between agent and frontend
OpenClaw + ClawGUI Agent gateway + channel plugin (AG-UI bridge)
Lucide React 0.575 Icons
date-fns 4.1 Date formatting

Technical Decisions

Decision Choice Rationale
State management React hooks only Sufficient for single-page dashboard; no cross-route state needed
Data layer In-memory mock DB Firebase-style NoSQL with CRUD, query, subscribe — swappable for real backend
Routing React Router DOM Simpler setup than TanStack for 4 routes
Styling Custom CSS Component-scoped .css files, no utility framework
Agent connection Vite proxy + info stub Avoids CORS; middleware stubs /info endpoint CopilotKit expects
Tool name casing All lowercase OpenClaw agent lowercases tool names; ClawGUI matching is case-insensitive
Cross-tab sync BroadcastChannel API Scenario tab drives Dashboard tab without shared state library

Project Structure

├── src/
│   ├── App.jsx                 # Router + CopilotKit provider + auth gating
│   ├── main.jsx                # Entry point
│   ├── pages/
│   │   ├── Dashboard.jsx       # Main workspace (chat + 6 views + 11 agent tools)
│   │   ├── Home.jsx            # Landing page
│   │   ├── Scenario.jsx        # Demo walkthrough (drives Dashboard via eventBus)
│   │   └── Setup.jsx           # Onboarding wizard
│   └── components/
│       ├── ErrorBoundary.jsx   # Catches OpenClaw connection failures
│       ├── Hero.jsx            # Landing hero section
│       ├── Features.jsx        # Feature cards
│       ├── Architecture.jsx    # Architecture diagram component
│       ├── TargetUser.jsx      # Target user section
│       ├── AgentMockup.jsx     # Agent UI mockup
│       └── Footer.jsx
├── mock-data/
│   ├── db.js                   # NoSQL engine (collections, CRUD, subscribe)
│   ├── seed.js                 # Seed data (6 collections + freelancer profile)
│   ├── index.js                # DB init + convenience helpers
│   ├── eventBus.js             # BroadcastChannel cross-tab pub/sub
│   └── scenario/               # Step-by-step demo scenario data
├── docs/
│   ├── product/                # Product docs (profile, user flows, features)
│   ├── engineering/            # Technical docs (DB schema, OpenClaw connection)
│   ├── ai/                     # AI engineering docs
│   └── openclaw/               # OpenClaw integration docs (6 files)
├── vite.config.js              # Vite + proxy + info stub middleware
└── package.json

Core Features

Feature What the Agent Does
Inbox Management Reads emails from context, drafts replies, sends on behalf of the freelancer
Calendar Management Creates, updates, and deletes calendar events; proposes meeting slots
Invoice Tracking Reads invoice status from context, flags overdue payments
Task Management Full CRUD — creates, reads, updates, and deletes tasks; marks complete
Daily Brief Morning summary with stats, priority items, and AI notes
Dashboard Navigation Switches workspace views on command (switchworkspace tool)

Connecting to OpenClaw

  1. Install the plugin:

    openclaw plugins install @contextableai/clawg-ui
  2. Run the gateway:

    openclaw gateway run
  3. Pair your device:

    curl -X POST http://localhost:18789/v1/clawg-ui \
      -H "Content-Type: application/json" -d '{}'

    Copy the pairingCode from the 403 response, then:

    openclaw pairing approve clawg-ui <pairingCode>
  4. Connect in ChiefClaw: paste the device token into the Dashboard connect screen, or set VITE_OPENCLAW_DEVICE_TOKEN in .env.local.

Full guide: docs/engineering/4_OPENCLAW_CONNECTION.md


Getting Started

npm install
npm run dev

Open http://localhost:5173/dashboard and connect to your local OpenClaw gateway.


Status

Phase Status Deliverables
Phase 1 — Frontend & UX Complete Dashboard, mock data, demo scenario, CopilotKit setup
Phase 2 — Agent Integration Complete All views reactive; 11 client tools; full read/write agent control via ClawGUI
Phase 3 — Real APIs Not started Gmail, Google Calendar, Stripe integrations
Phase 4 — Polish & Launch Not started Trust settings, deployment, monitoring

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors