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:
2026-11-10 15:47:53 +00:00
parent bf30e64d59
commit 30346f026c
6 changed files with 474 additions and 0 deletions
+7
View File
@@ -97,6 +97,9 @@ export const Config = z && z.object({
fetchTextCap: z.number()
.description('Maximum characters of rendered page text returned by native web_fetch (it reads pages through your browser, so JavaScript sites work and bot walls pass).')
.step(1).min(1000).max(60000).default(20000).volatile(),
chromiumArgs: z.string()
.description('Extra flags appended to every Edge/Chrome launch, space-separated (e.g. "--disable-dev-shm-usage" in containers). Root sessions get --no-sandbox automatically.')
.volatile(),
});
let cfg = null; // bound by apply(); volatile fields are read through .get()
@@ -547,6 +550,10 @@ async function doLaunch(args) {
'--disable-renderer-backgrounding',
...(headless ? ['--headless=new'] : []),
...(proxyFlag ? [`--proxy-server=${proxyFlag}`] : ['--no-proxy-server']),
// Containers and the default WSL user run as root, where the setuid
// sandbox is unavailable and Chrome refuses to start without this.
...(typeof process.getuid === 'function' && process.getuid() === 0 ? ['--no-sandbox'] : []),
...String(cfgVal('chromiumArgs', '') || '').split(/\s+/).filter(Boolean),
'about:blank',
], { stdio: 'ignore', detached: false, env: childEnv });
if (!(await waitForPort(port, 25000))) {