nimblebrain 0.1.0 → 0.1.1
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 +75 -25
- package/package.json +1 -1
package/dist/nimblebrain.js
CHANGED
|
@@ -763,7 +763,7 @@ async function setRuntimeTelemetry(deps, url, consent) {
|
|
|
763
763
|
// package.json
|
|
764
764
|
var package_default = {
|
|
765
765
|
name: "nimblebrain",
|
|
766
|
-
version: "0.1.
|
|
766
|
+
version: "0.1.1",
|
|
767
767
|
description: "Install, run and connect NimbleBrain, the open-source runtime for agents and MCP apps, on this machine.",
|
|
768
768
|
license: "Apache-2.0",
|
|
769
769
|
type: "module",
|
|
@@ -843,42 +843,48 @@ async function init(ctx) {
|
|
|
843
843
|
const { deps, flags, home } = ctx;
|
|
844
844
|
if (await readInstall(deps, home))
|
|
845
845
|
return { ...await status(deps, home), already: true };
|
|
846
|
-
const
|
|
846
|
+
const answer = { consent: await chooseConsent(ctx, false) };
|
|
847
847
|
const rec = recorder2(deps, ctx.version, await reportId(deps, home));
|
|
848
848
|
const begun = Date.now();
|
|
849
849
|
rec.record("cli.init_started", { agent: flags.agent ?? null, interactive: deps.interactive });
|
|
850
850
|
try {
|
|
851
|
-
return await install(ctx,
|
|
851
|
+
return await install(ctx, answer, rec, begun);
|
|
852
852
|
} catch (err) {
|
|
853
853
|
if (!(err instanceof CliError))
|
|
854
854
|
throw err;
|
|
855
|
-
if (err.code !== "
|
|
856
|
-
|
|
857
|
-
rec.record(check ? "cli.doctor_failed" : "cli.init_failed", { error: err.code, check });
|
|
858
|
-
}
|
|
859
|
-
await rec.settle(home, consent);
|
|
855
|
+
if (err.code !== "CANCELLED" || answer.consent !== "undecided")
|
|
856
|
+
await settleFailure(rec, home, answer.consent, err);
|
|
860
857
|
throw new CliError(err.code, err.message, {
|
|
861
858
|
...err.detail,
|
|
862
|
-
telemetry: field(consent, lockedHere(deps))
|
|
859
|
+
telemetry: field(answer.consent, lockedHere(deps))
|
|
863
860
|
});
|
|
864
861
|
}
|
|
865
862
|
}
|
|
866
|
-
async function
|
|
863
|
+
async function settleFailure(rec, home, consent, err) {
|
|
864
|
+
if (err.code !== "MODEL_KEY_MISSING") {
|
|
865
|
+
const check = typeof err.detail.check === "string" ? err.detail.check : undefined;
|
|
866
|
+
rec.record(check ? "cli.doctor_failed" : "cli.init_failed", { error: err.code, check });
|
|
867
|
+
}
|
|
868
|
+
await rec.settle(home, consent);
|
|
869
|
+
}
|
|
870
|
+
async function chooseConsent(ctx, ask) {
|
|
867
871
|
if (lockedHere(ctx.deps))
|
|
868
872
|
return "off";
|
|
869
873
|
if (ctx.flags.telemetry)
|
|
870
874
|
return ctx.flags.telemetry;
|
|
871
|
-
if (!asks(ctx))
|
|
875
|
+
if (!ask || !asks(ctx))
|
|
872
876
|
return "undecided";
|
|
873
877
|
return parseAnswer(await ctx.deps.prompt(`${QUESTION} [y/N] `));
|
|
874
878
|
}
|
|
875
|
-
async function install(ctx,
|
|
879
|
+
async function install(ctx, answer, rec, begun) {
|
|
876
880
|
const { deps, flags, home } = ctx;
|
|
877
881
|
await doctor(deps, flags.port);
|
|
878
882
|
await guardOurs(deps, home);
|
|
879
883
|
const tag = await runtimeTag(deps, flags.runtime);
|
|
880
884
|
const composeText = await fetchCompose(deps, tag);
|
|
881
885
|
await confirmStart(ctx, tag);
|
|
886
|
+
answer.consent = await chooseConsent(ctx, true);
|
|
887
|
+
const { consent } = answer;
|
|
882
888
|
await writeInstallFiles(deps, home, tag, flags.port, composeText, envValues(deps, rec.id, consent, asksConsent(composeText)));
|
|
883
889
|
if (!hasKey(await deps.readText(paths(home).env) ?? "", keyVars(composeText)) && asks(ctx))
|
|
884
890
|
await enterKey(ctx, false);
|
|
@@ -1032,6 +1038,7 @@ async function enterKey(ctx, restart) {
|
|
|
1032
1038
|
const offered = providers(await deps.readText(paths(home).compose) ?? "");
|
|
1033
1039
|
const names = Object.keys(offered);
|
|
1034
1040
|
let provider = flags.provider;
|
|
1041
|
+
deps.say("NimbleBrain's own agents run on a model key you give it, billed by that provider.");
|
|
1035
1042
|
if (!provider) {
|
|
1036
1043
|
const answer = await deps.prompt(`Model provider (${names.join(", ")}) [anthropic]: `);
|
|
1037
1044
|
provider = answer || "anthropic";
|
|
@@ -1051,7 +1058,8 @@ async function enterKey(ctx, restart) {
|
|
|
1051
1058
|
return { ok: true, provider, model_key: "set" };
|
|
1052
1059
|
}
|
|
1053
1060
|
async function chooseAgent(deps) {
|
|
1054
|
-
|
|
1061
|
+
deps.say("A coding agent you connect can use NimbleBrain's tools. NimbleBrain's own agents still run on the model key above.");
|
|
1062
|
+
const answer = await deps.prompt(`Connect a coding agent? (${AGENTS.join(", ")}) [none]: `);
|
|
1055
1063
|
return AGENTS.includes(answer) ? answer : "none";
|
|
1056
1064
|
}
|
|
1057
1065
|
async function start(deps, home, port) {
|
|
@@ -1177,7 +1185,7 @@ async function run(argv, deps) {
|
|
|
1177
1185
|
if (!["init", "telemetry", "uninstall", "doctor"].includes(command)) {
|
|
1178
1186
|
await settleWaiting(deps, home, VERSION2);
|
|
1179
1187
|
}
|
|
1180
|
-
return render(result, flags.json);
|
|
1188
|
+
return render(result, flags.json, command);
|
|
1181
1189
|
}
|
|
1182
1190
|
async function isHealthy(deps, port) {
|
|
1183
1191
|
const res = await deps.getJson(`http://127.0.0.1:${port}/v1/health`);
|
|
@@ -1188,7 +1196,7 @@ function toFailure(err) {
|
|
|
1188
1196
|
return failure(err);
|
|
1189
1197
|
return failure(new CliError("USAGE", err instanceof Error ? err.message : String(err)));
|
|
1190
1198
|
}
|
|
1191
|
-
function render(result, json) {
|
|
1199
|
+
function render(result, json, command) {
|
|
1192
1200
|
const code = exitCodeFor(result);
|
|
1193
1201
|
if (json)
|
|
1194
1202
|
return { stdout: `${JSON.stringify(result)}
|
|
@@ -1197,23 +1205,65 @@ function render(result, json) {
|
|
|
1197
1205
|
return { stdout: `error: ${result.message}
|
|
1198
1206
|
fix: ${result.fix}
|
|
1199
1207
|
`, code };
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
function human(result) {
|
|
1203
|
-
const lines = Object.entries(result).filter(([key]) => key !== "ok").flatMap(([key, value]) => field2(key, value));
|
|
1204
|
-
return `${lines.join(`
|
|
1208
|
+
const lines = isStatus(result) ? statusLines(result, command) : genericLines(result);
|
|
1209
|
+
return { stdout: `${lines.join(`
|
|
1205
1210
|
`)}
|
|
1206
|
-
|
|
1211
|
+
`, code };
|
|
1212
|
+
}
|
|
1213
|
+
function isStatus(result) {
|
|
1214
|
+
return "health" in result && "url" in result && "workspaces" in result;
|
|
1215
|
+
}
|
|
1216
|
+
var AGENT_NAMES = {
|
|
1217
|
+
"claude-code": "Claude Code",
|
|
1218
|
+
cursor: "Cursor",
|
|
1219
|
+
codex: "Codex"
|
|
1220
|
+
};
|
|
1221
|
+
function statusLines(r, command) {
|
|
1222
|
+
const lines = [
|
|
1223
|
+
...changeLines(r),
|
|
1224
|
+
` NimbleBrain ${r.version.startsWith("v") ? r.version : `v${r.version}`}: ${r.health === "ok" ? "running" : "stopped"} at ${r.url}`,
|
|
1225
|
+
...r.workspaces.map((w) => ` workspace ${w.name}: ${w.mcp}`),
|
|
1226
|
+
` model key: ${r.model_key === "set" ? "set (NimbleBrain's own agents use it)" : "missing (run npx nimblebrain key)"}`
|
|
1227
|
+
];
|
|
1228
|
+
const agent = r.agent.connected;
|
|
1229
|
+
if (agent) {
|
|
1230
|
+
const name = AGENT_NAMES[agent] ?? agent;
|
|
1231
|
+
lines.push(` ${name} can use NimbleBrain's tools (it loads them when its next session starts)`);
|
|
1232
|
+
if (!r.agent.skill)
|
|
1233
|
+
lines.push(` skill: not installed; add it with npx skills add nimblebraininc/skills --skill nimblebrain`);
|
|
1234
|
+
} else if (r.manual) {
|
|
1235
|
+
lines.push(` agent: not connected; add it by hand: ${r.manual}`);
|
|
1236
|
+
}
|
|
1237
|
+
lines.push(telemetryLine(r.telemetry));
|
|
1238
|
+
lines.push(` CLI ${r.cli_version}`);
|
|
1239
|
+
if (command === "init" && !r.already && r.health === "ok") {
|
|
1240
|
+
const ask = agent ? `, or ask ${AGENT_NAMES[agent] ?? agent} what NimbleBrain can do` : "";
|
|
1241
|
+
lines.push("", `Next: open ${r.url}${ask}. Stop it with npx nimblebrain down.`);
|
|
1242
|
+
}
|
|
1243
|
+
return lines;
|
|
1244
|
+
}
|
|
1245
|
+
function changeLines(r) {
|
|
1246
|
+
if (r.already)
|
|
1247
|
+
return [" already installed"];
|
|
1248
|
+
return r.from ? [` updated from ${r.from}`] : [];
|
|
1249
|
+
}
|
|
1250
|
+
function telemetryLine(t) {
|
|
1251
|
+
const how = t.locked ? ` (${t.locked})` : t.set ? ` (answer with ${t.set})` : "";
|
|
1252
|
+
return ` telemetry: ${t.state}${how}`;
|
|
1253
|
+
}
|
|
1254
|
+
function genericLines(result) {
|
|
1255
|
+
return Object.entries(result).filter(([key]) => key !== "ok").flatMap(([key, value]) => field2(key, value));
|
|
1207
1256
|
}
|
|
1208
1257
|
function field2(key, value) {
|
|
1258
|
+
if (value === undefined || value === null)
|
|
1259
|
+
return [];
|
|
1209
1260
|
if (key === "checks" && Array.isArray(value)) {
|
|
1210
1261
|
return value.map((c) => ` ${c.ok ? "✓" : "✗"} ${c.check}: ${c.detail}`);
|
|
1211
1262
|
}
|
|
1212
|
-
if (
|
|
1213
|
-
return value.
|
|
1263
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
1264
|
+
return Object.entries(value).flatMap(([k, v]) => field2(`${key} ${k}`, v));
|
|
1214
1265
|
}
|
|
1215
|
-
|
|
1216
|
-
return [` ${key}: ${text}`];
|
|
1266
|
+
return [` ${key}: ${Array.isArray(value) ? value.join(", ") : String(value)}`];
|
|
1217
1267
|
}
|
|
1218
1268
|
function interrupted(argv, exitCode) {
|
|
1219
1269
|
const err = new CliError("INTERRUPTED", `The CLI stopped before it answered (exit code ${exitCode}).`, { exit_code: exitCode });
|
package/package.json
CHANGED