Adds the nanobot agent adapter (packages/nanobot): magpie's model, Library MCP servers and workspace skills written into ~/.nanobot/config.json through a journaled, owner-tracked bridge, and restored on disconnect. fc46523d resolves symlinked parent directories (macOS /var, dotfile-managed ~/.nanobot or ~/.config) while still refusing a symlinked final file, and keeps the preset on host exit; only a disconnect restores. Run at fc46523d: `bun test` in packages/nanobot, 60 pass / 0 fail on mote (macOS, default TMPDIR under the /var link, which failed 18 of 22 at c6f8f639) and on the magpie-desktop WSL distro (Ubuntu 24.04). Not tried: a real nanobot binary driven through magpie.
24 lines
1.1 KiB
JavaScript
24 lines
1.1 KiB
JavaScript
import { resolvePaths, startRuntime } from "./runtime.mjs"
|
|
|
|
const instance = Symbol.for("magpie.nanobot.adapter.v1")
|
|
|
|
// Magpie treats every exported function in main as a plugin. Keep helpers in
|
|
// their own modules, and never terminate or take signals from its shared host.
|
|
export default async function NanobotAgent(input, options = {}) {
|
|
if (!globalThis[instance]) {
|
|
const runtime = startRuntime(resolvePaths(options), {
|
|
onStatus(status) {
|
|
const level = status.state === "conflict" ? "warn" : "info"
|
|
const message = `nanobot adapter: ${status.state}; MCP changes require a nanobot restart. Run magpie-nanobot status for details.`
|
|
try { void input?.client?.app?.log?.({ body: { service: "nanobot-agent", level, message } })?.catch?.(() => {}) } catch {}
|
|
},
|
|
})
|
|
globalThis[instance] = runtime
|
|
// Flush any pending disconnect; normal host exit keeps connected inputs.
|
|
process.once("exit", () => {
|
|
try { runtime.stop() } catch { console.error("nanobot final sync paused; retain the adapter recovery files and run magpie-nanobot status.") }
|
|
})
|
|
}
|
|
return {}
|
|
}
|