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.
29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
import path from "node:path"
|
|
import { pathsFor, reconcile, inspect } from "./bridge.mjs"
|
|
import { resolvePaths } from "./runtime.mjs"
|
|
|
|
const args = process.argv.slice(2)
|
|
const action = args.shift() || "status"
|
|
const options = {}
|
|
let invalid = false
|
|
while (args.length) {
|
|
const flag = args.shift()
|
|
if (!["--config", "--state-dir"].includes(flag) || !args.length) { invalid = true; break }
|
|
options[flag === "--config" ? "configPath" : "stateDir"] = path.resolve(args.shift())
|
|
}
|
|
if (invalid || !["status", "sync", "restore"].includes(action)) {
|
|
console.error("Usage: magpie-nanobot <status|sync|restore> [--config <absolute config.json>] [--state-dir <adapter directory>]")
|
|
process.exitCode = 2
|
|
} else {
|
|
try {
|
|
const p = options.stateDir ? pathsFor(options) : resolvePaths(options)
|
|
const result = action === "status" ? inspect(p) : reconcile(p, action === "restore" ? { restore: true, pause: true } : {})
|
|
console.log(JSON.stringify(result, null, 2))
|
|
if (result.state === "conflict") process.exitCode = 1
|
|
} catch {
|
|
console.error("nanobot adapter could not complete the operation. Check target path, JSON syntax, file permissions and recovery records. Configuration contents and keys are omitted.")
|
|
process.exitCode = 1
|
|
}
|
|
}
|