create-donobu-plugin 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# create-donobu-plugin
|
|
2
|
+
|
|
3
|
+
`create-donobu-plugin` is the official scaffolding CLI for Donobu Studio plugins. It generates a TypeScript workspace wired to Donobu’s plugin API, pins dependencies to whatever versions your local Studio installation already uses, and ships with helper utilities so you can focus on describing new tools instead of wiring.
|
|
4
|
+
|
|
5
|
+
## How Donobu loads plugins
|
|
6
|
+
|
|
7
|
+
- Donobu watches a plugins directory inside its working data folder (macOS: `~/Library/Application Support/Donobu Studio/plugins`, Windows: `%APPDATA%/Donobu Studio/plugins`, Linux: `~/.config/Donobu Studio/plugins`).
|
|
8
|
+
- Each plugin ships a bundled `dist/index.mjs` that exports one async function named `loadCustomTools(dependencies)`. When Donobu starts it imports every plugin bundle and calls that function to collect tools.
|
|
9
|
+
- `npm exec install-donobu-plugin` builds your project and copies the resulting `dist/` folder into `<workingDir>/plugins/<plugin-name>`, so restarting Donobu is enough to pick up changes.
|
|
10
|
+
|
|
11
|
+
Keep those three rules in mind and your plugin will load reliably.
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Node.js 18+ and npm 8+
|
|
16
|
+
- A local Donobu Studio installation (desktop or backend) so the installer has somewhere to copy the plugin bundle
|
|
17
|
+
- Playwright browsers installed (Donobu will prompt you if they are missing)
|
|
18
|
+
- Write access to the Donobu Studio working directory
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx create-donobu-plugin my-support-tools
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Provide the plugin name as the first argument. Names may include lowercase letters, numbers, hyphens, and underscores. The CLI prints usage information if the argument is missing or invalid.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
1. Scaffold a plugin: `npx create-donobu-plugin my-support-tools`
|
|
31
|
+
2. `cd my-support-tools && npm install`
|
|
32
|
+
3. Implement your tools in `src/index.ts`
|
|
33
|
+
4. `npm run build`
|
|
34
|
+
5. `npm exec install-donobu-plugin`
|
|
35
|
+
6. Restart Donobu Studio and verify the tools appear in the UI/logs
|
|
36
|
+
|
|
37
|
+
## Generated project layout
|
|
38
|
+
|
|
39
|
+
| Item | Description |
|
|
40
|
+
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `package.json` | Private ESM package whose `main`/`types` fields point to `dist/`. Dev dependencies are aligned with the local Donobu install so you don’t chase version drift. |
|
|
42
|
+
| `tsconfig.json` | NodeNext compiler settings that emit JS + declarations into `dist/`. |
|
|
43
|
+
| `esbuild.config.mjs` | Bundles the compiled JS into `dist/index.mjs`, keeping Donobu and Playwright as external dependencies. |
|
|
44
|
+
| `src/index.ts` | Entry point that must export `loadCustomTools(dependencies)` and return an array of tools. |
|
|
45
|
+
| `src/createTool.ts` | Helper around `dependencies.donobu.Tool` that reduces boilerplate when defining tools. |
|
|
46
|
+
| `src/PluginDependencies.ts` | Strongly typed view of the objects Donobu injects into your plugin (`donobu` and `playwright`). |
|
|
47
|
+
| `README.md` | Template instructions for the team that owns the generated plugin. |
|
|
48
|
+
|
|
49
|
+
Because the scaffold reuses the Donobu versions already on disk, regenerating the project after a Donobu upgrade is the fastest way to stay in lockstep.
|
|
50
|
+
|
|
51
|
+
## Authoring tools
|
|
52
|
+
|
|
53
|
+
Every plugin exports `loadCustomTools(dependencies)` and returns an array of `Tool` instances. You can instantiate `dependencies.donobu.Tool` directly or use the provided helper:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
// src/index.ts
|
|
57
|
+
import { z } from 'zod/v4';
|
|
58
|
+
import { createTool } from './createTool.js';
|
|
59
|
+
import type { PluginDependencies } from './PluginDependencies.js';
|
|
60
|
+
|
|
61
|
+
export async function loadCustomTools(deps: PluginDependencies) {
|
|
62
|
+
const pingSchema = z.object({
|
|
63
|
+
url: z.string().url(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const pingTool = createTool(deps, {
|
|
67
|
+
name: 'pingEndpoint',
|
|
68
|
+
description: 'Fetches a URL within the Donobu-controlled browser context.',
|
|
69
|
+
requiresGpt: false,
|
|
70
|
+
schema: pingSchema,
|
|
71
|
+
async call(ctx, { url }) {
|
|
72
|
+
const page = await ctx.browserContext.newPage();
|
|
73
|
+
const response = await page.goto(url);
|
|
74
|
+
return {
|
|
75
|
+
isSuccessful: !!response,
|
|
76
|
+
forLlm: `Fetched ${url} with status ${response?.status()}`,
|
|
77
|
+
metadata: { status: response?.status() },
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return [pingTool];
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Guidelines:
|
|
87
|
+
|
|
88
|
+
- Define Zod schemas for every tool so inputs from humans or the LLM are validated before your code runs.
|
|
89
|
+
- Use `callFromGpt` if the GPT path needs different behavior; otherwise the helper routes GPT calls through `call`.
|
|
90
|
+
- Request `requiresGpt: true` only when the tool cannot run without LLM assistance.
|
|
91
|
+
|
|
92
|
+
## Working with injected dependencies
|
|
93
|
+
|
|
94
|
+
- `dependencies.donobu` exposes the public SDK: the base `Tool` class, `PlaywrightUtils`, logging helpers, type definitions, etc.
|
|
95
|
+
- `dependencies.playwright` points to the same Playwright build Donobu uses, so your plugin and the core runtime stay aligned.
|
|
96
|
+
- Feel free to add your own dependencies; `esbuild` bundles everything except the packages listed in `external`.
|
|
97
|
+
|
|
98
|
+
## Build and install
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run build
|
|
102
|
+
npm exec install-donobu-plugin
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`npm run build` cleans `dist/`, reinstalls dependencies (to ensure version parity), runs TypeScript, and bundles the result. `npm exec install-donobu-plugin` validates the current folder, infers the plugin name (prefers `package.json`, falls back to the git repo name or `$USER`), and copies `dist/` into the Donobu plugins directory. Restart Donobu after every install so the new bundle is loaded.
|
|
106
|
+
|
|
107
|
+
## Recommended development loop
|
|
108
|
+
|
|
109
|
+
1. Make changes in `src/`
|
|
110
|
+
2. `npm run build && npm exec install-donobu-plugin`
|
|
111
|
+
3. Restart Donobu Studio or the backend process
|
|
112
|
+
4. Trigger your tool from the UI or API to verify behavior
|
|
113
|
+
|
|
114
|
+
Because the default build script runs `npm install`, consider splitting the script into `build` and `bundle` variants if you need faster inner-loop iterations.
|
|
115
|
+
|
|
116
|
+
## Troubleshooting
|
|
117
|
+
|
|
118
|
+
- **Plugin not appearing:** Ensure `npm exec install-donobu-plugin` ran successfully and that `dist/index.mjs` exists. Restart Donobu and watch the logs for plugin loading messages.
|
|
119
|
+
- **Schema errors:** Zod throws runtime errors when inputs don’t match your schema. Log the error message to quickly see which field failed.
|
|
120
|
+
- **Version mismatch:** If Donobu upgrades Playwright or its SDK, re-run the scaffold (or update the plugin’s dev dependencies) so you stay compatible.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-donobu-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create a new Donobu plugin",
|
|
6
6
|
"author": "Donobu",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"index.js"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"donobu": "^
|
|
16
|
+
"donobu": "^3.3.0"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"donobu",
|