UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

97 lines 4.57 kB
import * as playwright from 'playwright'; import type sharp from 'sharp'; import type { z } from 'zod/v4'; import type { GptClientPlugin } from '../clients/GptClientPlugin'; import type { PersistencePlugin } from '../persistence/PersistencePlugin'; import type { TargetRuntimePlugin } from '../targets/TargetRuntimePlugin'; import type { Tool } from '../tools/Tool'; /** The result of loading all plugins — no global state, just data. */ export type LoadedPlugins = { tools: Tool<z.ZodObject, z.ZodObject>[]; persistencePlugins: Map<string, PersistencePlugin>; gptClientPlugins: GptClientPlugin[]; targetRuntimePlugins: TargetRuntimePlugin[]; }; export type PluginDependencies = { donobu: typeof import('../main'); playwright: typeof playwright; /** * Optional — provided by the host when available. Plugins deployed as * standalone files in the app-data `plugins/` directory cannot resolve * `sharp` from their own location (no `node_modules` tree), so the host * lazily loads it and passes it here. */ sharp?: typeof sharp; }; /** * Loads Donobu plugins from two sources: * * 1. **App-data plugins directory** — the `plugins/` folder inside the * Donobu Studio data directory (e.g. `~/Library/Application Support/ * Donobu Studio/plugins/`). Plugins here are standalone `index.mjs` * files, typically installed via `install-donobu-plugin`. * * 2. **`node_modules`** — `@donobu/*` packages installed via npm that * declare `"donobu-plugin": true` in their `package.json`. This is * the primary discovery path for SDK users who `npm install` plugins * alongside the `donobu` package. * * When a plugin is found in both sources, the node_modules copy wins — * an explicit project-level dependency should override global Studio * state so tests run against the version the project declares. */ export declare class PluginLoader { private readonly pluginsPath; private readonly pluginDependencies; private readonly nodeModulesScopePath?; constructor(pluginsPath: string, pluginDependencies: PluginDependencies, nodeModulesScopePath?: string | undefined); /** * Creates a PluginLoader with optional configuration parameters. * If parameters are not provided, defaults will be used. */ static create(pluginsPath?: string, pluginDependencies?: PluginDependencies): Promise<PluginLoader>; /** * Discovers and loads all plugins from both the app-data directory and * `node_modules`. All plugin types are collected and returned. */ loadAllPlugins(): Promise<LoadedPlugins>; /** * Determine which file PluginLoader should dynamic-import for a plugin * living at `pkgDir`, using a three-tier cascade: * * 1. `exports["./plugin"].import` — preferred for dual-use packages * (those that also expose an SDK surface on the default entry). * Points at a bundle built from plugin hooks only, with no * value-level `donobu` imports, so it loads cleanly even from the * app-data plugins dir where no sibling `donobu` module exists. * Example: `@donobu/donobu-mobile`. * 2. `exports.import` — the old flat shape used by plugin-only * packages (no SDK surface, no value-level `donobu` imports). * Examples: `tools-captcha`, `tools-mfa`, `donobu-aws`, * `donobu-google`. * 3. `<pkgDir>/index.mjs` — convention fallback for hand-dropped * plugins that ship no `package.json` at all. * * `requirePackageJson` toggles whether the caller demands a * package.json with `"donobu-plugin": true` at the package root * (node_modules discovery) or is happy with any directory that has an * `index.mjs` (app-data discovery — supports hand-dropped legacy * plugins). */ private resolvePlugin; /** * Scan the app-data plugins directory for standalone plugin bundles. * Each plugin is a directory containing a `package.json` with * `"donobu-plugin": true`. Scoped packages (`@scope/name`) are supported * one level deep. */ private discoverDirectoryPlugins; /** * Scan `node_modules/@donobu/` for npm-installed packages that declare * `"donobu-plugin": true` in their `package.json`. Delegates the actual * entry-point resolution to `resolvePlugin` so app-data and * node_modules installs follow the same rules. */ private discoverNodeModulesPlugins; } //# sourceMappingURL=PluginLoader.d.ts.map