midas: host the kit under MIDAS as its web search/fetch provider
MIDAS loads plugins but has no Cordis runtime, so the kit had no way to register its tool or its web providers here. midas/kitd.mjs builds the smallest ctx the plugin asks for and republishes the tool and both providers over a loopback seam; midas/plugin.js is that seam's client and brings up the host on demand, keeping the browser warm across restarts. Headless Linux runs need two additions in index.js: --no-sandbox when running as uid 0, and a chromiumArgs setting for container-specific flags. Co-Authored-By: MIDAS <hello@trymidas.io>
This commit is contained in:
@@ -70,6 +70,38 @@ Browser discovery is cross-platform — Windows, Linux (apt **and** snap paths,
|
||||
|
||||
A proxy counts as *working* only when an echo comes back through it — no blind trust in proxy-list sites.
|
||||
|
||||
## Running under MIDAS
|
||||
|
||||
MIDAS loads plugins but has no Cordis runtime, so `midas/` supplies one:
|
||||
|
||||
- **`midas/kitd.mjs`** — the host. Builds the smallest `ctx` the plugin asks for
|
||||
(`tools.register`, `web.registerSearchProvider`, `web.registerFetchProvider`,
|
||||
`effect`), applies the kit with a plain-object config, and republishes the kit's
|
||||
tool and both web providers over a loopback HTTP seam on `127.0.0.1:7789`
|
||||
(`/health`, `/tool-def`, `/tool`, `/search`, `/fetch`, `/settings`, `/shutdown`).
|
||||
It runs as its own process on purpose: the launched browser is the expensive
|
||||
part, and a warm profile survives MIDAS restarting.
|
||||
- **`midas/kit.settings.json`** — host defaults (`browser`, `headless`, `port`,
|
||||
`searchEngine`, caps, `chromiumArgs`). Edit and restart the host to apply.
|
||||
- **`midas/plugin.js`** — the MIDAS plugin. Starts the host on demand, then registers
|
||||
`edge_kit` (the full action surface), `edge_kit_search` and `edge_kit_fetch`.
|
||||
MIDAS reserves the built-in `websearch` / `webfetch` ids, so a plugin tool cannot
|
||||
take those names; instead the plugin hooks `tool.execute.after` and upgrades a
|
||||
thin built-in `webfetch` result to the rendered page. Register it in
|
||||
`~/.config/midas/midas.json`:
|
||||
|
||||
```json
|
||||
{ "plugin": ["file:///root/gitea/8ball/edge-kit/midas/plugin.js"] }
|
||||
```
|
||||
|
||||
Env overrides: `EDGE_KIT_REPO` (checkout), `EDGE_KIT_HTTP` (seam URL),
|
||||
`EDGE_KIT_NODE` (node binary — `process.execPath` inside MIDAS is the MIDAS
|
||||
binary, so the plugin looks for a real node itself).
|
||||
|
||||
Headless Linux launches needed two additions to `index.js`, both harmless
|
||||
elsewhere: `--no-sandbox` is appended automatically when running as uid 0, and the
|
||||
new `chromiumArgs` setting appends whatever extra flags a container wants.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **`Maximum number of active sessions` (Firefox)** — a zombie Firefox is holding the BiDi session slot; terminate `firefox.exe` and relaunch.
|
||||
|
||||
Reference in New Issue
Block a user