feat: lib-agent-dock-ui — global assistant dock
@crema/agent-dock-ui — a floating Sparkles FAB that opens a right-side slide-over chat with an agents-platform agent. Extracted from skyai-finance (the canonical dock) and made app-agnostic. The shell, threading, compose box, and rich-block rendering (via @crema/agent-ui's MessageBody) live here; the app injects identity (resolveAgents), context (getPageContext → structured PageContext), and transport (auth closed over inside it — the dock never sees a token). Self-contained: raw slide-over + buttons styled with theme tokens, no app-local shadcn dependency. Page context travels as a structured field, never concatenated into the message. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
47
README.md
Normal file
47
README.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# lib-agent-dock-ui
|
||||
|
||||
`@crema/agent-dock-ui` — the global **assistant dock**: a floating
|
||||
Sparkles FAB that opens a right-side slide-over chat with an
|
||||
agents-platform agent.
|
||||
|
||||
The dock runs **in-process** in the host app (it needs DOM access for
|
||||
rich-block rendering and the action bus), so it ships as a lib, not an
|
||||
iframe or a CDN widget. The shell, threading, compose box, and rich-block
|
||||
rendering live here; the app injects:
|
||||
|
||||
- **identity** — `resolveAgents()` returns the agent(s) the user can talk
|
||||
to. One → no picker; many → a dropdown.
|
||||
- **context** — `getPageContext()` returns a structured `PageContext`
|
||||
(`{route, resource?, label?}`). It travels to the platform as its own
|
||||
field, never concatenated into the message, so page content can't
|
||||
masquerade as a user instruction.
|
||||
- **transport** — `AgentDockTransport.chat()`. Auth is closed over inside
|
||||
the transport (the app builds it from its `@crema/arcadia-agents-client`
|
||||
instance); the dock never sees a token.
|
||||
|
||||
## Usage
|
||||
|
||||
```tsx
|
||||
import { AgentDock } from "@crema/agent-dock-ui"
|
||||
import { chat, listAgents } from "~/lib/api/arcadia"
|
||||
|
||||
<AgentDock
|
||||
transport={{ chat }}
|
||||
resolveAgents={() => listAgents(tenantId, { archived: "false" })}
|
||||
defaultAgentId={profile.defaultAgentId}
|
||||
getPageContext={() => ({ route: location.pathname })}
|
||||
onExpand={({ agentId }) => navigate(`/agents/${agentId}/chat`)}
|
||||
hidden={isChatRoute}
|
||||
/>
|
||||
```
|
||||
|
||||
Mount once, near the app root. `hidden` is app-computed per-route
|
||||
suppression. `onExpand` is optional — omit it to hide the ⤢ button.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `@crema/agent-ui` — `MessageBody` (rich-block rendering)
|
||||
- `react`, `lucide-react`
|
||||
|
||||
Theme contract: consumes the `--chat-user-bg/-fg` and
|
||||
`--chat-assistant-bg/-fg/-border` tokens (every Crema theme defines them).
|
||||
Reference in New Issue
Block a user