Repository navigation
en dev star guides plugin views workbench
Note
Currently supported only in AstrBot ChatUI.
Use target="chat_workbench" to display an interface beside the conversation. Open file previews from messages or tools, or register resident pages such as notes and session analytics in the workbench + entry.

Download the context-usage example plugin. Open a ChatUI session, click the workbench +, and select 上下文用量 (Context usage) from New workbench. No tool call is needed. The page receives the current sessionId through the bridge context and shows token estimates for system instructions, tool definitions, conversation, and tool results.
Send a message, then click Refresh to see the latest request breakdown. Sources not yet observed appear as unknown. Counts are estimates, not the model's billed token usage. See Add a resident entry for registration.
Register a preview view and return event.view_result() from a tool. Set the tab label with title; the message retains a reopening entry. Hosts without a workbench, such as thread panels, render the view inside the message.
Add to metadata.yaml:
views:
- name: preview
target: chat_workbench
title: Previewmain.py:
from astrbot.api.event import AstrMessageEvent, filter
from astrbot.api.star import Star
class PreviewPlugin(Star):
@filter.llm_tool(name="open_preview")
async def open_preview(self, event: AstrMessageEvent):
"""Open a preview in the workbench.
Args:
event: Incoming tool event.
Returns:
A view and a text result for the model.
"""
return event.view_result(
name="preview",
title="Notes",
data={"content": "Notes to review."},
text="Opened notes in the workbench.",
)Display the returned data in views/preview/index.html and an adjacent app.js:
<!doctype html>
<html>
<head><meta charset="utf-8" /><title>Notes</title></head>
<body>
<pre id="content"></pre>
<script type="module" src="./app.js"></script>
</body>
</html>const bridge = window.AstrBotPluginView;
await bridge.ready();
bridge.view.subscribe(({ data }) => {
document.getElementById("content").textContent = data.content;
});After the tool runs, the workbench displays a Notes tab with the returned text. For callbacks, declare actions and use bridge.view.action() as shown in Interactive message component.
Use chat_workbench_with_launcher in metadata to expose the view in + while still allowing plugins to open it through event.view_result():
views:
- name: context
target: chat_workbench_with_launcher
title: Context usage
description: Inspect the current conversation contextCreate the entry file and reload the plugin. Click + in the ChatUI workbench, then choose Context usage. A launcher-opened view has one tab per session.
Capabilities depend on how the view opens. Message/tool-created instances receive context.view and can use view.subscribe/action; opening a view does not invoke an action, and previews do not need actions. Launcher-opened instances have no message snapshot and use plugin Web APIs, file transfers, and SSE, with the current sessionId. A shared page can check context.view to handle both modes.
sessionId is null without an active session. Switching sessions restores that session's pages and context:
const bridge = window.AstrBotPluginView;
await bridge.ready();
bridge.onContext(({ sessionId }) => {
// Fetch session-specific aggregates from your authenticated plugin API.
if (sessionId) bridge.apiGet("usage", { session_id: sessionId });
});The plugin backend must validate session ownership against request.username; a client-supplied session ID is not authorization. Guard asynchronous requests against stale responses after a session switch. All targets share theme CSS tokens and onContext().
These methods are available only to resident chat_workbench_with_launcher views without context.view. Bind them to user actions:
await bridge.chat.fill("Please revise this passage.");
await bridge.chat.send("Please summarize my selection.");fill appends text to the current draft and focuses the composer. send sends directly to the current session while preserving the existing draft and staged attachments. Sending is rejected if there is no session, the session changed, or generation is already running. The promise settles when the send request is accepted, rather than after the bot finishes replying.
For agent-assisted document editing, record the user's selection and revision in the plugin backend. Let the tool accept a selection ID and replacement text, and enforce the edit range in code. After saving, use plugin SSE to notify the resident view to reload the document while protecting unsaved local edits.
Tab lists, active tabs, and open/hidden state are stored in the browser per user and session. Switching sessions restores the corresponding workbench; reloading does not reopen closed tabs. Persist plugin business data in the plugin backend.
See the shared Bridge API for themes, file transfers, and SSE, and backend Web APIs for authentication and data access.
- 首页
- 文档入口
- Top Level
- community events
- config
- deploy
- dev
- others
- platform
- 接入 OneBot v11 协议实现
- 接入钉钉 DingTalk
- 接入 Discord
- 接入 Kook
- 接入飞书
- 接入 LINE
- 接入 Matrix
- 接入 Mattermost
- 接入 Misskey 平台
- 接入 QQ 官方机器人平台
- 通过 QQ官方机器人 接入 QQ (Webhook)
- 通过 QQ官方机器人 接入 QQ (Websockets)
- 接入 Satori 协议
- 接入 server-satori (基于 Koishi)
- 接入 Slack
- 接入消息平台
- 接入 Telegram
- 接入 VoceChat
- AstrBot 接入企业微信
- 接入企业微信智能机器人平台
- AstrBot 接入微信公众平台
- 接入个人微信
- providers
- use
- Home
- Docs Entry
- Top Level
- config
- deploy
- Deploy AstrBot on 1Panel
- Deploy AstrBot on BT Panel
- Deploy AstrBot on CasaOS
- Deploy AstrBot from Source Code
- Community-Provided Deployment Methods
- Deploy via Compshare
- Deploy with AstrBot Desktop Client
- Deploy AstrBot with Docker
- Deploy AstrBot with Kubernetes
- Deploy AstrBot with AstrBot Launcher
- Other Deployments
- Script Deployment
- Installation via System Package Manager
- Preface
- dev
- AstrBot Configuration File
- API Scope–Endpoint Reference
- AstrBot HTTP API
- AstrBot Plugin Market JSON Specification
- AstrBot Plugin Market JSON Specification
- Developing a Platform Adapter
- plugin
- AI
- Agents
- Sessions and Conversations
- Models
- Other APIs
- Tools
- Documentation moved
- Text to Image
- Handling Message Events
- Plugin Configuration
- Plugin Internationalization
- Documentation moved
- Shared Bridge API
- Interactive message component
- Standalone plugin page
- Backend Web APIs
- Workbench page
- Sending Messages
- Session Control
- Minimal Example
- Plugin Storage
- AstrBot Plugin Development Guide 🌠
- Publishing Plugins to the Plugin Marketplace
- ospp
- others
- platform
- Connect OneBot v11 Protocol Implementations
- Connect to DingTalk
- Connecting to Discord
- Connect to KOOK
- Connecting to Lark
- Connecting to LINE
- Connecting to Matrix
- Connecting to Mattermost
- Connecting to Misskey Platform
- Connect QQ Official Bot
- Connect QQ via QQ Official Bot (Webhook)
- Connect QQ via QQ Official Bot (Websockets)
- Connect to Satori Protocol
- Connect server-satori (Koishi)
- Connecting to Slack
- Messaging Platforms
- Connecting to Telegram
- Connect to VoceChat
- Connect AstrBot to WeCom
- Connect to WeCom AI Bot Platform
- Connect AstrBot to WeChat Official Account Platform
- Connect Personal WeChat
- providers
- Connect 302.AI
- Agent Runners
- Built-in Agent Runner
- Connect to Coze
- Connect to Alibaba Cloud Bailian Application
- Connect to DeerFlow
- Connect to Dify
- Connect AIHubMix
- coze
- dashscope
- DeepSeek STT Integration
- DeepSeek TTS Integration
- dify
- Model input images
- Large Language Model Providers
- Connect MiraRouter
- NewAPI
- Connect PPIO Cloud
- Connect LM Studio to Use DeepSeek-R1 and Other Models
- Integrating Ollama
- Connect ShengSuanYun
- Connecting to SiliconFlow
- Connecting Model Services
- Connecting to TokenPony
- use
- Agent Execution Mode {#agent-runner}
- Agent Sandbox Environment
- astrbot sandbox
- AstrBot CLI {#cli-commands}
- Docker-based Code Interpreter
- Built-in Commands
- computer
- Context Compression
- Session Configuration Mappings (formerly Custom Rules)
- AstrBot Knowledge Base
- MCP
- AstrBot Plugins {#astrbot-star}
- Proactive Capabilities
- Skills {#anthropic-skills}
- Subagents {#agent-handsoff-and-subagent}
- Unified Webhook Mode
- Web Search
- DeepSeek Search API
- SerpApi
- WebUI