nimblebrain 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nimblebrain.js +65 -29
- package/package.json +1 -1
package/dist/nimblebrain.js
CHANGED
|
@@ -222,7 +222,6 @@ var ERRORS = {
|
|
|
222
222
|
NOT_INSTALLED: "Run `npx nimblebrain` to install it.",
|
|
223
223
|
NOT_OURS: "Another install holds this name or its data. Remove it yourself, or choose a --home whose folder has another name.",
|
|
224
224
|
NETWORK: "Check the network connection, then run the same command again.",
|
|
225
|
-
MODEL_KEY_MISSING: "Run `npx nimblebrain key` in your own terminal to enter a model key.",
|
|
226
225
|
HEALTH_TIMEOUT: "Run `npx nimblebrain logs` and look at the last error line.",
|
|
227
226
|
AGENT_UNSUPPORTED: "Pass --agent claude-code, cursor, codex or none.",
|
|
228
227
|
START_FAILED: "Run `npx nimblebrain logs` and look at the last error line, then run this again.",
|
|
@@ -248,6 +247,17 @@ var ERRORS = {
|
|
|
248
247
|
REQUEST_FAILED: "Run `npx nimblebrain logs` and look at the last error line, then run this again."
|
|
249
248
|
};
|
|
250
249
|
var FIX_VARIANTS = {
|
|
250
|
+
DOCKER_MISSING: {
|
|
251
|
+
mac_brew: "Install Docker Desktop with `brew install --cask docker`, open it once from Applications, then run this again.",
|
|
252
|
+
mac: "Install Docker Desktop (https://docs.docker.com/desktop/setup/install/mac-install/), open it once, then run this again."
|
|
253
|
+
},
|
|
254
|
+
COMPOSE_MISSING: {
|
|
255
|
+
brew: "Install Compose with `brew install docker-compose`, then run this again."
|
|
256
|
+
},
|
|
257
|
+
LOW_MEMORY: {
|
|
258
|
+
colima: "Restart Colima with more memory: `colima stop && colima start --memory 4`, then run this again.",
|
|
259
|
+
docker_desktop: "In Docker Desktop, open Settings > Resources, set Memory to at least 2 GB, apply, then run this again."
|
|
260
|
+
},
|
|
251
261
|
LOCAL_MODEL_UNREACHABLE: {
|
|
252
262
|
brew_install: "Install Ollama with `brew install ollama`, then run this again; it offers to start Ollama for you.",
|
|
253
263
|
app: "Open the Ollama app, then run this again.",
|
|
@@ -719,9 +729,34 @@ function composeEnv(deps, vars) {
|
|
|
719
729
|
}
|
|
720
730
|
return env;
|
|
721
731
|
}
|
|
732
|
+
var PLUGIN = { cmd: "docker", args: ["compose"] };
|
|
733
|
+
var found = new WeakMap;
|
|
734
|
+
function findCompose(deps) {
|
|
735
|
+
let lookup = found.get(deps);
|
|
736
|
+
if (!lookup) {
|
|
737
|
+
lookup = lookUpCompose(deps);
|
|
738
|
+
found.set(deps, lookup);
|
|
739
|
+
}
|
|
740
|
+
return lookup;
|
|
741
|
+
}
|
|
742
|
+
async function lookUpCompose(deps) {
|
|
743
|
+
for (const program of [PLUGIN, { cmd: "docker-compose", args: [] }]) {
|
|
744
|
+
const res = await deps.exec(program.cmd, [...program.args, "version", "--short"]);
|
|
745
|
+
if (res.code === 0 && majorOf(res.stdout) >= 2)
|
|
746
|
+
return { ...program, version: res.stdout.trim() };
|
|
747
|
+
}
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
function majorOf(version) {
|
|
751
|
+
return Number.parseInt(version.trim().replace(/^v/, ""), 10);
|
|
752
|
+
}
|
|
753
|
+
async function composeExec(deps, args, opts) {
|
|
754
|
+
const program = await findCompose(deps) ?? PLUGIN;
|
|
755
|
+
return deps.exec(program.cmd, [...program.args, ...args], opts);
|
|
756
|
+
}
|
|
722
757
|
async function compose(deps, home, args, timeoutMs = 120000) {
|
|
723
758
|
const vars = keyVars(await deps.readText(paths(home).compose) ?? "");
|
|
724
|
-
return deps
|
|
759
|
+
return composeExec(deps, args, {
|
|
725
760
|
cwd: home,
|
|
726
761
|
env: composeEnv(deps, vars),
|
|
727
762
|
timeoutMs
|
|
@@ -777,14 +812,14 @@ var INSTANCE_JSON = `${JSON.stringify({ auth: { adapter: "dev" } }, null, 2)}
|
|
|
777
812
|
|
|
778
813
|
// src/doctor.ts
|
|
779
814
|
var SUPPORTED_ARCH = ["x86_64", "amd64", "aarch64", "arm64"];
|
|
780
|
-
var MIN_MEMORY =
|
|
815
|
+
var MIN_MEMORY = 1.75 * 1024 ** 3;
|
|
781
816
|
async function doctor(deps, port, portInUseByUs = false) {
|
|
782
817
|
const log = recorder();
|
|
783
818
|
await checkDocker(deps, log);
|
|
784
819
|
const facts = await checkDaemon(deps, log);
|
|
785
820
|
await checkCompose(deps, log);
|
|
786
821
|
checkArch(facts.arch, log);
|
|
787
|
-
checkMemory(facts
|
|
822
|
+
checkMemory(facts, log);
|
|
788
823
|
await checkPort(deps, port, portInUseByUs, log);
|
|
789
824
|
return { ok: true, checks: log.checks, arch: facts.arch };
|
|
790
825
|
}
|
|
@@ -795,16 +830,18 @@ function recorder() {
|
|
|
795
830
|
pass: (check, detail) => {
|
|
796
831
|
checks.push({ check, ok: true, detail });
|
|
797
832
|
},
|
|
798
|
-
fail: (check, code, detail) => {
|
|
833
|
+
fail: (check, code, detail, variant) => {
|
|
799
834
|
checks.push({ check, ok: false, detail });
|
|
800
|
-
throw new CliError(code, detail, { check, checks });
|
|
835
|
+
throw new CliError(code, detail, { check, checks }, variant);
|
|
801
836
|
}
|
|
802
837
|
};
|
|
803
838
|
}
|
|
804
839
|
async function checkDocker(deps, log) {
|
|
805
840
|
const version = await deps.exec("docker", ["--version"]);
|
|
806
|
-
if (version.missing)
|
|
807
|
-
|
|
841
|
+
if (version.missing) {
|
|
842
|
+
const variant = deps.platform !== "darwin" ? undefined : await deps.which("brew") ? "mac_brew" : "mac";
|
|
843
|
+
log.fail("docker", "DOCKER_MISSING", "Docker is not installed.", variant);
|
|
844
|
+
}
|
|
808
845
|
log.pass("docker", version.stdout.trim());
|
|
809
846
|
}
|
|
810
847
|
async function checkDaemon(deps, log) {
|
|
@@ -820,12 +857,12 @@ ${info.stdout}`)) {
|
|
|
820
857
|
return parseInfo(info.stdout);
|
|
821
858
|
}
|
|
822
859
|
async function checkCompose(deps, log) {
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
log.fail("compose", "COMPOSE_MISSING", "Docker Compose v2 is not available.");
|
|
860
|
+
const program = await findCompose(deps);
|
|
861
|
+
if (!program) {
|
|
862
|
+
const variant = deps.platform === "darwin" && await deps.which("brew") ? "brew" : undefined;
|
|
863
|
+
log.fail("compose", "COMPOSE_MISSING", "Docker Compose v2 is not available.", variant);
|
|
827
864
|
}
|
|
828
|
-
log.pass("compose",
|
|
865
|
+
log.pass("compose", program.cmd === "docker" ? program.version : `${program.version} (${program.cmd})`);
|
|
829
866
|
}
|
|
830
867
|
function checkArch(arch, log) {
|
|
831
868
|
if (!SUPPORTED_ARCH.includes(arch)) {
|
|
@@ -833,9 +870,9 @@ function checkArch(arch, log) {
|
|
|
833
870
|
}
|
|
834
871
|
log.pass("arch", arch);
|
|
835
872
|
}
|
|
836
|
-
function checkMemory(memory, log) {
|
|
873
|
+
function checkMemory({ memory, kind }, log) {
|
|
837
874
|
if (memory > 0 && memory < MIN_MEMORY) {
|
|
838
|
-
log.fail("memory", "LOW_MEMORY", `Docker has ${gib(memory)} of memory; NimbleBrain needs 2 GB
|
|
875
|
+
log.fail("memory", "LOW_MEMORY", `Docker has ${gib(memory)} of memory; NimbleBrain needs 2 GB.`, kind);
|
|
839
876
|
}
|
|
840
877
|
log.pass("memory", memory > 0 ? gib(memory) : "unknown");
|
|
841
878
|
}
|
|
@@ -851,7 +888,8 @@ function parseInfo(stdout) {
|
|
|
851
888
|
const info = JSON.parse(stdout);
|
|
852
889
|
return {
|
|
853
890
|
arch: typeof info.Architecture === "string" ? info.Architecture : "",
|
|
854
|
-
memory: typeof info.MemTotal === "number" ? info.MemTotal : 0
|
|
891
|
+
memory: typeof info.MemTotal === "number" ? info.MemTotal : 0,
|
|
892
|
+
kind: info.OperatingSystem === "Docker Desktop" ? "docker_desktop" : info.Name === "colima" ? "colima" : undefined
|
|
855
893
|
};
|
|
856
894
|
} catch {
|
|
857
895
|
return { arch: "", memory: 0 };
|
|
@@ -1278,7 +1316,7 @@ async function setRuntimeTelemetry(deps, url, consent) {
|
|
|
1278
1316
|
// package.json
|
|
1279
1317
|
var package_default = {
|
|
1280
1318
|
name: "nimblebrain",
|
|
1281
|
-
version: "0.
|
|
1319
|
+
version: "0.7.0",
|
|
1282
1320
|
description: "Install, run and connect NimbleBrain, the open-source runtime for agents and MCP apps, on this machine.",
|
|
1283
1321
|
license: "Apache-2.0",
|
|
1284
1322
|
type: "module",
|
|
@@ -1362,6 +1400,9 @@ async function readWorkspaces(deps, url) {
|
|
|
1362
1400
|
const body = boot.body;
|
|
1363
1401
|
return (body.workspaces ?? []).filter((w) => typeof w.id === "string" && typeof w.name === "string").map((w) => ({ id: w.id, name: w.name, mcp: `${url}/mcp/${w.id}` }));
|
|
1364
1402
|
}
|
|
1403
|
+
function hasModelIn(r) {
|
|
1404
|
+
return r.model_key === "set" || r.local_model !== null;
|
|
1405
|
+
}
|
|
1365
1406
|
|
|
1366
1407
|
// src/open.ts
|
|
1367
1408
|
function browserCommand(deps, url) {
|
|
@@ -1491,15 +1532,13 @@ async function openWhenDone(ctx, result) {
|
|
|
1491
1532
|
const { deps, flags } = ctx;
|
|
1492
1533
|
if (!deps.interactive || flags.json || flags.noOpen)
|
|
1493
1534
|
return result;
|
|
1494
|
-
if (result.health !== "ok")
|
|
1535
|
+
if (result.health !== "ok" || !hasModelIn(result))
|
|
1495
1536
|
return result;
|
|
1496
1537
|
return { ...result, opened: await openBrowser(deps, result.url) };
|
|
1497
1538
|
}
|
|
1498
1539
|
async function settleFailure(rec, home, consent, err) {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
rec.record(check ? "cli.doctor_failed" : "cli.init_failed", { error: err.code, check });
|
|
1502
|
-
}
|
|
1540
|
+
const check = typeof err.detail.check === "string" ? err.detail.check : undefined;
|
|
1541
|
+
rec.record(check ? "cli.doctor_failed" : "cli.init_failed", { error: err.code, check });
|
|
1503
1542
|
await rec.settle(home, consent);
|
|
1504
1543
|
}
|
|
1505
1544
|
async function chooseConsent(ctx) {
|
|
@@ -1555,11 +1594,6 @@ async function install(ctx, consent, rec, begun) {
|
|
|
1555
1594
|
agent: state.agent ?? null
|
|
1556
1595
|
});
|
|
1557
1596
|
await rec.settle(home, consent);
|
|
1558
|
-
if (result.model_key === "missing" && !result.local_model) {
|
|
1559
|
-
throw new CliError("MODEL_KEY_MISSING", "NimbleBrain is running; chat needs a model key.", {
|
|
1560
|
-
...result
|
|
1561
|
-
});
|
|
1562
|
-
}
|
|
1563
1597
|
return { ...result };
|
|
1564
1598
|
});
|
|
1565
1599
|
}
|
|
@@ -1826,7 +1860,7 @@ async function guardOurs(deps, home) {
|
|
|
1826
1860
|
throw new CliError("NOT_OURS", `${file} already exists and this CLI did not write it.`);
|
|
1827
1861
|
}
|
|
1828
1862
|
}
|
|
1829
|
-
const projects = await deps
|
|
1863
|
+
const projects = await composeExec(deps, ["ls", "-a", "--format", "json"]);
|
|
1830
1864
|
const taken = projects.code === 0 && listsProject(projects.stdout, project);
|
|
1831
1865
|
const volumes = await deps.exec("docker", [
|
|
1832
1866
|
"volume",
|
|
@@ -2202,7 +2236,9 @@ function statusLines(r, cli, command) {
|
|
|
2202
2236
|
lines.push(` servers on this machine: not reachable until ${cli} update`);
|
|
2203
2237
|
lines.push(telemetryLine(r.telemetry));
|
|
2204
2238
|
lines.push(` CLI ${r.cli_version}`);
|
|
2205
|
-
if (command === "init" && !r.already && r.health === "ok") {
|
|
2239
|
+
if (command === "init" && !r.already && r.health === "ok" && !hasModelIn(r)) {
|
|
2240
|
+
lines.push("", `Next: give NimbleBrain a model so it can chat. Run ${cli} key in your own terminal to enter a model key, or ${cli} local-model to run one on this machine with Ollama.`);
|
|
2241
|
+
} else if (command === "init" && !r.already && r.health === "ok") {
|
|
2206
2242
|
const ask = agent ? `, or ask ${AGENT_NAMES[agent] ?? agent} what NimbleBrain can do` : "";
|
|
2207
2243
|
const use = r.opened ? `use NimbleBrain in your browser at ${r.url}` : `open ${r.url}`;
|
|
2208
2244
|
lines.push("", `Next: ${use}${ask}. Stop it with ${cli} down.`);
|
package/package.json
CHANGED