Compare commits

...

2 Commits

Author SHA1 Message Date
Nikhil Sonti
9df042e739 fix: address agent history docs review 2026-04-23 13:19:09 -07:00
Nikhil Sonti
80c8c790d6 docs: document agent command history integration 2026-04-23 13:07:35 -07:00

View File

@@ -9,6 +9,7 @@ The built-in browser extension that powers BrowserOS's AI interface — new tab
## Features
- **AI-Powered New Tab**: Custom new tab page with unified search across Google and AI assistants
- **Agent Command Center**: Alpha agent command surface in the app shell for launching and resuming OpenClaw agent conversations
- **Side Panel Chat**: Full-featured chat interface for interacting with BrowserOS
- **Multi-Provider Support**: Connect to various LLM providers (OpenAI, Anthropic, Azure, Bedrock, and more)
- **MCP Integration**: Model Context Protocol support for extending AI capabilities
@@ -26,6 +27,7 @@ entrypoints/
├── background.ts # Service worker for extension lifecycle
├── content.ts # Content script (Google pages)
├── glow.content/ # Visual glow effect for active AI operations
├── app/ # Full-page app shell, settings, and command center
├── newtab/ # Custom new tab page
├── sidepanel/ # AI chat side panel
├── onboarding/ # First-time user onboarding flow
@@ -58,6 +60,29 @@ Custom new tab replacement featuring:
- **Top Sites**: Quick access to frequently visited sites
- **Theme Toggle**: Light/dark mode support
### App Shell and Agent Command Center (`app/`)
Full-page extension app mounted at `app.html` with sidebar navigation, settings, onboarding redirects, and alpha-only OpenClaw agent surfaces.
Inside the `/home` route, the Agent Command Center replaces the default `NewTab` view when `ALPHA_FEATURES_SUPPORT` is enabled:
- `agent-command-layout.tsx` wraps the command-center routes and polls OpenClaw status and agent metadata through `useOpenClawStatus` and `useOpenClawAgents`.
- `/home` renders `AgentCommandHome`, which lists OpenClaw agents, selects an active agent, and routes prompt submissions to the selected conversation.
- `/home/agents/:agentId` renders `AgentCommandConversation`, which owns the focused chat view for one OpenClaw agent.
- `useAgentConversation.ts` sends messages through `chatWithAgent` to `/claw/agents/:agentId/chat`, consumes BrowserOS SSE chat events, and persists completed turns.
#### Command Center History Integration
Command-center conversations have two history layers:
- **Local UI cache**: `lib/agent-conversations/storage.ts` stores conversations in IndexedDB with keys shaped as `agent-conv:${agentId}:${sessionKey}`. `useAgentConversation.ts` loads the latest local conversation for an agent, keeps its `sessionKey`, saves completed turns, and sends text-only prior turns as the `history` payload for the next chat request.
- **OpenClaw session history**: BrowserOS Server exposes `GET /claw/session/:sessionKey/history`, which proxies OpenClaw's `/sessions/:sessionKey/history` endpoint. The default response is JSON `{ sessionKey, messages, cursor?, hasMore?, truncated? }`; `limit` and `cursor` query params are forwarded for pagination.
When the command center needs gateway-backed restore or live sync, use the same `sessionKey` carried by the local conversation:
- Fetch JSON history for initial restore or backfill.
- Request `Accept: text/event-stream` to stream named `history`, `message`, and `error` events for live tailing.
- Keep IndexedDB as a fast UI cache, but treat the OpenClaw history endpoint as the source for messages that were persisted by the gateway.
- Treat a `404` history response as a missing or expired OpenClaw session and start a fresh local conversation.
- Abort any history stream when navigating away or resetting the conversation.
### Side Panel (`sidepanel/`)
The main chat interface for BrowserOS: