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
+29-38Lines changed: 29 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -226,9 +226,9 @@ Note that `default` is only applied when creating a new config file or when a fi
226
226
227
227
## Building a Sandbox Runtime Plugin
228
228
229
-
Starting from the generic sandbox architecture, concrete runtimes such as `CUA`, `Shipyard`, `Shipyard Neo`, or `Boxlite` should be implemented as **separate plugins**, not hard-coded in AstrBot Core.
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
230
231
-
Recommended structure:
231
+
Start with this structure:
232
232
233
233
```text
234
234
data/plugins/<plugin_name>/
@@ -240,17 +240,17 @@ data/plugins/<plugin_name>/
240
240
tools/
241
241
```
242
242
243
-
Typical responsibilities are split like this:
243
+
Use the files like this:
244
244
245
-
-`main.py`: plugin entrypoint, provider registration, and optional extra tool registration.
-`tools/`: optional runtime-specific tools, such as screenshot, mouse, keyboard, browser, or lifecycle helpers.
249
-
-`_conf_schema.json`: provider-specific configuration shown in WebUI.
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
250
251
-
### 1. Register the sandbox provider
251
+
### 1. Register the provider
252
252
253
-
In your plugin entrypoint, register and unregister the provider through the generic sandbox APIs exposed by core:
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
254
255
255
```python
256
256
from astrbot.api.star import Context, Star, register
@@ -274,11 +274,11 @@ class DemoSandboxPlugin(Star):
Use a stable plugin name, directory name, and metadata `name`, ideally all aligned.
277
+
Use a stable name for the plugin directory, `metadata.yaml`, and `@register(...)`. Keeping them aligned makes the generated config file easy to find.
278
278
279
-
### 2. Implement the provider contract
279
+
### 2. Implement `provider.py`
280
280
281
-
Your provider should implement the generic sandbox protocol from core (`astrbot.core.computer.sandbox_provider.SandboxProvider`). In practice, that means defining:
281
+
AstrBot calls the provider whenever it needs to create, reuse, rename, or destroy a sandbox. Implement these fields and methods:
282
282
283
283
-`provider_id`
284
284
-`capabilities`
@@ -290,7 +290,7 @@ Your provider should implement the generic sandbox protocol from core (`astrbot.
### 3. Put runtime-specific config in `_conf_schema.json`
332
+
### 3. Add runtime config
333
333
334
-
Core only keeps the generic selector:
335
-
336
-
-`provider_settings.computer_use_runtime`
337
-
-`provider_settings.sandbox.booter`
338
-
339
-
All runtime-specific config belongs to the plugin schema, for example:
334
+
Create `_conf_schema.json` for values that users should edit in WebUI, such as API endpoints, access tokens, profiles, image names, or timeouts.
340
335
341
336
```json
342
337
{
@@ -355,33 +350,29 @@ All runtime-specific config belongs to the plugin schema, for example:
355
350
}
356
351
```
357
352
358
-
That schema will be stored under`data/config/<plugin_name>_config.json` and passed to the plugin constructor as `config`.
353
+
AstrBot stores the saved values in`data/config/<plugin_name>_config.json` and passes them to the plugin constructor as `config`.
359
354
360
-
If your provider needs session-level or legacy overrides from `provider_settings.sandbox`, read them in `build_create_config()` as overrides on top of the plugin config. Do not add runtime-specific fields to core config metadata.
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`.
361
356
362
-
### 4. Expose optional runtime tools through `tool_names`
357
+
### 4. Add optional tools
363
358
364
-
If your runtime adds extra tools beyond the generic shell/python/filesystem stack, register them in the plugin and list their names in `tool_names`.
359
+
If your runtime exposes extra abilities, register those tools in the plugin and list the tool names in `provider.tool_names`.
365
360
366
-
Typical examples:
361
+
Common examples:
367
362
368
363
- screenshot tools
369
364
- mouse / keyboard tools
370
365
- browser tools
371
366
- runtime-specific lifecycle helpers
372
367
373
-
Core uses `tool_names` to mount those tools automatically in sandbox mode, so avoid hard-coding provider names in core.
374
-
375
-
### 5. Keep runtime code out of core
376
-
377
-
When building a sandbox plugin:
368
+
AstrBot uses `tool_names` when mounting tools in sandbox mode. Make sure the names match the tools you register in `main.py`.
378
369
379
-
- Put concrete runtime SDK imports in the plugin repo.
380
-
- Put provider-specific defaults and config schema in the plugin repo.
381
-
- Put runtime-specific tools in the plugin repo.
382
-
- Keep AstrBot Core limited to generic sandbox registration, lifecycle, persistence, and dashboard/API surfaces.
370
+
### 5. Try it locally
383
371
384
-
If you are unsure whether something belongs in core or a plugin, the rule of thumb is:
372
+
After adding the plugin under `data/plugins/<plugin_name>/`, start AstrBot and check these items:
385
373
386
-
- generic behavior -> core
387
-
- concrete runtime behavior -> plugin
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.
0 commit comments