You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/dev/star/guides/plugin-config.md
-153Lines changed: 0 additions & 153 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -223,156 +223,3 @@ class ConfigPlugin(Star):
223
223
When you update the Schema across different versions, AstrBot will recursively inspect the configuration items in the Schema, automatically adding default values for missing items and removing those that no longer exist.
224
224
225
225
Note that `default` is only applied when creating a new config file or when a field is missing from an existing config. If a field already exists in `data/config/<plugin_name>_config.json`, changing the Schema `default` later will not overwrite that saved value. This is intentional so plugin upgrades do not silently replace user-edited settings.
226
-
227
-
## Building a Sandbox Runtime Plugin
228
-
229
-
A sandbox runtime plugin teaches AstrBot how to start and connect to a sandbox service. The plugin usually contains a provider, a booter/client, a config schema, and optional tools for features such as screenshots or browser control.
230
-
231
-
Start with this structure:
232
-
233
-
```text
234
-
data/plugins/<plugin_name>/
235
-
main.py
236
-
metadata.yaml
237
-
_conf_schema.json
238
-
provider.py
239
-
booters/
240
-
tools/
241
-
```
242
-
243
-
Use the files like this:
244
-
245
-
-`main.py`: register the provider, and register any extra tools.
246
-
-`provider.py`: adapt your runtime to AstrBot's sandbox provider methods.
247
-
-`booters/`: put the client code that starts, connects to, and shuts down the sandbox.
248
-
-`tools/`: add optional runtime tools such as screenshot, mouse, keyboard, browser, or lifecycle helpers.
249
-
-`_conf_schema.json`: define the settings shown in WebUI.
250
-
251
-
### 1. Register the provider
252
-
253
-
In `main.py`, create your provider and register it when the plugin loads. Pass the plugin config into the provider so `provider.py` can read values from `_conf_schema.json`.
254
-
255
-
```python
256
-
from astrbot.api.star import Context, Star, register
257
-
from astrbot.core.computer.computer_client import (
Create `_conf_schema.json` for values that users should edit in WebUI, such as API endpoints, access tokens, profiles, image names, or timeouts.
335
-
336
-
```json
337
-
{
338
-
"demo_endpoint": {
339
-
"description": "Demo API Endpoint",
340
-
"type": "string",
341
-
"default": "",
342
-
"hint": "API endpoint for the demo sandbox service."
343
-
},
344
-
"demo_ttl": {
345
-
"description": "Sandbox TTL",
346
-
"type": "int",
347
-
"default": 3600,
348
-
"hint": "Sandbox lifetime in seconds."
349
-
}
350
-
}
351
-
```
352
-
353
-
AstrBot stores the saved values in `data/config/<plugin_name>_config.json` and passes them to the plugin constructor as `config`.
354
-
355
-
If your provider still supports older values under `provider_settings.sandbox`, read them in `build_create_config()` as overrides on top of the plugin config. New provider settings should normally live in `_conf_schema.json`.
356
-
357
-
### 4. Add optional tools
358
-
359
-
If your runtime exposes extra abilities, register those tools in the plugin and list the tool names in `provider.tool_names`.
360
-
361
-
Common examples:
362
-
363
-
- screenshot tools
364
-
- mouse / keyboard tools
365
-
- browser tools
366
-
- runtime-specific lifecycle helpers
367
-
368
-
AstrBot uses `tool_names` when mounting tools in sandbox mode. Make sure the names match the tools you register in `main.py`.
369
-
370
-
### 5. Try it locally
371
-
372
-
After adding the plugin under `data/plugins/<plugin_name>/`, start AstrBot and check these items:
373
-
374
-
- The plugin loads without import errors.
375
-
- The WebUI config page shows fields from `_conf_schema.json`.
376
-
- The sandbox runtime selector includes your `provider_id`.
377
-
- Creating a sandbox calls `create_booter()`.
378
-
- Stopping or unloading the plugin calls `terminate()` and unregisters the provider.
A sandbox runtime plugin teaches AstrBot how to start and connect to a sandbox service. The plugin usually contains a provider, a booter/client, a config schema, and optional tools for features such as screenshots or browser control.
4
+
5
+
Start with this structure:
6
+
7
+
```text
8
+
data/plugins/<plugin_name>/
9
+
main.py
10
+
metadata.yaml
11
+
_conf_schema.json
12
+
provider.py
13
+
booters/
14
+
tools/
15
+
```
16
+
17
+
Use the files like this:
18
+
19
+
-`main.py`: register the provider, and register any extra tools.
20
+
-`provider.py`: adapt your runtime to AstrBot's sandbox provider methods.
21
+
-`booters/`: put the client code that starts, connects to, and shuts down the sandbox.
22
+
-`tools/`: add optional runtime tools such as screenshot, mouse, keyboard, browser, or lifecycle helpers.
23
+
-`_conf_schema.json`: define the settings shown in WebUI. See [Plugin Configuration](./plugin-config.md) for the schema format.
24
+
25
+
## 1. Register the provider
26
+
27
+
In `main.py`, create your provider and register it when the plugin loads. Pass the plugin config into the provider so `provider.py` can read values from `_conf_schema.json`.
28
+
29
+
```python
30
+
from astrbot.api.star import Context, Star, register
31
+
from astrbot.core.computer.computer_client import (
Create `_conf_schema.json` for values that users should edit in WebUI, such as API endpoints, access tokens, profiles, image names, or timeouts.
109
+
110
+
```json
111
+
{
112
+
"demo_endpoint": {
113
+
"description": "Demo API Endpoint",
114
+
"type": "string",
115
+
"default": "",
116
+
"hint": "API endpoint for the demo sandbox service."
117
+
},
118
+
"demo_ttl": {
119
+
"description": "Sandbox TTL",
120
+
"type": "int",
121
+
"default": 3600,
122
+
"hint": "Sandbox lifetime in seconds."
123
+
}
124
+
}
125
+
```
126
+
127
+
AstrBot stores the saved values in `data/config/<plugin_name>_config.json` and passes them to the plugin constructor as `config`.
128
+
129
+
If your provider still supports older values under `provider_settings.sandbox`, read them in `build_create_config()` as overrides on top of the plugin config. New provider settings should normally live in `_conf_schema.json`.
130
+
131
+
## 4. Add optional tools
132
+
133
+
If your runtime exposes extra abilities, register those tools in the plugin and list the tool names in `provider.tool_names`.
134
+
135
+
Common examples:
136
+
137
+
- screenshot tools
138
+
- mouse / keyboard tools
139
+
- browser tools
140
+
- runtime-specific lifecycle helpers
141
+
142
+
AstrBot uses `tool_names` when mounting tools in sandbox mode. Make sure the names match the tools you register in `main.py`.
143
+
144
+
## 5. Try it locally
145
+
146
+
After adding the plugin under `data/plugins/<plugin_name>/`, start AstrBot and check these items:
147
+
148
+
- The plugin loads without import errors.
149
+
- The WebUI config page shows fields from `_conf_schema.json`.
150
+
- The sandbox runtime selector includes your `provider_id`.
151
+
- Creating a sandbox calls `create_booter()`.
152
+
- Stopping or unloading the plugin calls `terminate()` and unregisters the provider.
0 commit comments