@p-sw/brainbox 0.1.2-alpha.2 → 0.1.2-alpha.4
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/index.js +122 -78
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1098,12 +1098,25 @@ class ZenMuxExecutor extends OpenAICompatibleExecutor {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
1100
|
|
|
1101
|
-
// src/provider/providers/
|
|
1101
|
+
// src/provider/providers/minimax.ts
|
|
1102
1102
|
class MiniMaxExecutor extends OpenAICompatibleExecutor {
|
|
1103
1103
|
constructor(opts) {
|
|
1104
1104
|
super({
|
|
1105
|
-
providerName: "
|
|
1106
|
-
baseURL: "https://api.
|
|
1105
|
+
providerName: "minimax",
|
|
1106
|
+
baseURL: "https://api.minimax.io/v1",
|
|
1107
|
+
apiKey: opts.apiKey,
|
|
1108
|
+
conversationModel: opts.conversationModel,
|
|
1109
|
+
identityModel: opts.identityModel
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
// src/provider/providers/minimax_cn.ts
|
|
1115
|
+
class MiniMaxCnExecutor extends OpenAICompatibleExecutor {
|
|
1116
|
+
constructor(opts) {
|
|
1117
|
+
super({
|
|
1118
|
+
providerName: "minimax-cn",
|
|
1119
|
+
baseURL: "https://api.minimaxi.com/v1",
|
|
1107
1120
|
apiKey: opts.apiKey,
|
|
1108
1121
|
conversationModel: opts.conversationModel,
|
|
1109
1122
|
identityModel: opts.identityModel
|
|
@@ -2241,7 +2254,8 @@ register("stackit", StackitExecutor);
|
|
|
2241
2254
|
register("gmi", GmiExecutor);
|
|
2242
2255
|
register("zai", ZaiExecutor);
|
|
2243
2256
|
register("zenmux", ZenMuxExecutor);
|
|
2244
|
-
register("
|
|
2257
|
+
register("minimax", MiniMaxExecutor);
|
|
2258
|
+
register("minimax-cn", MiniMaxCnExecutor);
|
|
2245
2259
|
register("ionet", IoNetExecutor);
|
|
2246
2260
|
register("baseten", BasetenExecutor);
|
|
2247
2261
|
register("cortecs", CortecsExecutor);
|
|
@@ -3064,9 +3078,12 @@ ${personaSystemFixed}`;
|
|
|
3064
3078
|
log7.debug(`Brain.create: brainbase saved (id=${brainId})`);
|
|
3065
3079
|
return { brainId, brain: new Brain(db, space, brainbase, memory) };
|
|
3066
3080
|
} catch (error) {
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3081
|
+
let reason = error instanceof Error ? `${error.message} (${error.name})` : String(error);
|
|
3082
|
+
if (error instanceof BadRequestResponseError) {
|
|
3083
|
+
reason = `${reason} ${JSON.stringify(error.body)}`;
|
|
3084
|
+
}
|
|
3085
|
+
log7.debug(`Brain.create failed: ${reason}`);
|
|
3086
|
+
return { error: reason };
|
|
3070
3087
|
}
|
|
3071
3088
|
}
|
|
3072
3089
|
static async delete(brainId) {
|
|
@@ -4116,7 +4133,8 @@ async function deactivateBrain(brainId) {
|
|
|
4116
4133
|
async function createBrain(displayName, seed, options) {
|
|
4117
4134
|
logger.debug(`createBrain: name="${displayName}" seed length=${seed.length} schedule=${options.schedule}`);
|
|
4118
4135
|
const result = await Brain.create(displayName, seed);
|
|
4119
|
-
if (
|
|
4136
|
+
if ("error" in result) {
|
|
4137
|
+
logger.error(`Failed to create brain "${displayName}": ${result.error}`);
|
|
4120
4138
|
process.exitCode = 1;
|
|
4121
4139
|
return;
|
|
4122
4140
|
}
|
|
@@ -4968,6 +4986,19 @@ function Select(props) {
|
|
|
4968
4986
|
|
|
4969
4987
|
// src/commands/onboard.tsx
|
|
4970
4988
|
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
4989
|
+
function ok(msg) {
|
|
4990
|
+
console.log(chalk3.green(`✔ ${msg}`));
|
|
4991
|
+
}
|
|
4992
|
+
function info(msg) {
|
|
4993
|
+
console.log(msg);
|
|
4994
|
+
}
|
|
4995
|
+
function show(active, node, status) {
|
|
4996
|
+
active.current.unmount();
|
|
4997
|
+
console.clear();
|
|
4998
|
+
if (status)
|
|
4999
|
+
ok(status);
|
|
5000
|
+
active.current = render3(node);
|
|
5001
|
+
}
|
|
4971
5002
|
function ProviderApp({
|
|
4972
5003
|
providers,
|
|
4973
5004
|
onDone
|
|
@@ -5039,7 +5070,6 @@ function ProviderApp({
|
|
|
5039
5070
|
const extras = PROVIDER_EXTRA_FIELDS[stage.provider] ?? [];
|
|
5040
5071
|
if (extras.length === 0) {
|
|
5041
5072
|
setProviderAuth(stage.provider, { apiKey });
|
|
5042
|
-
logger.success(`Saved ${stage.provider} to auth.yaml`);
|
|
5043
5073
|
onDone({ provider: stage.provider });
|
|
5044
5074
|
return;
|
|
5045
5075
|
}
|
|
@@ -5060,13 +5090,6 @@ function ProviderApp({
|
|
|
5060
5090
|
}, undefined, true, undefined, this);
|
|
5061
5091
|
}
|
|
5062
5092
|
const nextField = stage.fields[0];
|
|
5063
|
-
if (!nextField) {
|
|
5064
|
-
setProviderAuth(stage.provider, stage.values);
|
|
5065
|
-
logger.success(`Saved ${stage.provider} to auth.yaml`);
|
|
5066
|
-
return /* @__PURE__ */ jsxDEV5(Text5, {
|
|
5067
|
-
children: "Continuing…"
|
|
5068
|
-
}, undefined, false, undefined, this);
|
|
5069
|
-
}
|
|
5070
5093
|
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
5071
5094
|
flexDirection: "column",
|
|
5072
5095
|
children: [
|
|
@@ -5092,6 +5115,11 @@ function ProviderApp({
|
|
|
5092
5115
|
const values = { ...stage.values };
|
|
5093
5116
|
if (value)
|
|
5094
5117
|
values[nextField] = value;
|
|
5118
|
+
if (remaining.length === 0) {
|
|
5119
|
+
setProviderAuth(stage.provider, values);
|
|
5120
|
+
onDone({ provider: stage.provider });
|
|
5121
|
+
return;
|
|
5122
|
+
}
|
|
5095
5123
|
setStage({
|
|
5096
5124
|
kind: "extras",
|
|
5097
5125
|
provider: stage.provider,
|
|
@@ -5149,8 +5177,7 @@ function ModelApp2({
|
|
|
5149
5177
|
}
|
|
5150
5178
|
setModelSlot("identity", value);
|
|
5151
5179
|
setModelSlot("conversation", value);
|
|
5152
|
-
|
|
5153
|
-
onDone();
|
|
5180
|
+
onDone(value);
|
|
5154
5181
|
}
|
|
5155
5182
|
}, undefined, false, undefined, this),
|
|
5156
5183
|
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
@@ -5186,7 +5213,6 @@ function SuperMemoryApp({
|
|
|
5186
5213
|
return;
|
|
5187
5214
|
}
|
|
5188
5215
|
setSupermemoryKey(key);
|
|
5189
|
-
logger.success("Saved supermemory key to brainbox.yaml");
|
|
5190
5216
|
onDone();
|
|
5191
5217
|
}
|
|
5192
5218
|
}, undefined, false, undefined, this),
|
|
@@ -5202,6 +5228,7 @@ function BrainApp({
|
|
|
5202
5228
|
}) {
|
|
5203
5229
|
const [stage, setStage] = useState5({ kind: "name" });
|
|
5204
5230
|
const [error, setError] = useState5(null);
|
|
5231
|
+
const [busy, setBusy] = useState5(false);
|
|
5205
5232
|
if (stage.kind === "name") {
|
|
5206
5233
|
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
5207
5234
|
flexDirection: "column",
|
|
@@ -5253,12 +5280,14 @@ function BrainApp({
|
|
|
5253
5280
|
dimColor: true,
|
|
5254
5281
|
children: "One sentence about who they are. The model will expand it."
|
|
5255
5282
|
}, undefined, false, undefined, this),
|
|
5256
|
-
/* @__PURE__ */ jsxDEV5(
|
|
5283
|
+
busy ? /* @__PURE__ */ jsxDEV5(Text5, {
|
|
5284
|
+
dimColor: true,
|
|
5285
|
+
children: "Creating brain…"
|
|
5286
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV5(TextInput, {
|
|
5257
5287
|
prompt: "seed> ",
|
|
5258
|
-
onSubmit:
|
|
5288
|
+
onSubmit: (raw) => {
|
|
5259
5289
|
const seed = raw.trim();
|
|
5260
5290
|
if (seed === "skip") {
|
|
5261
|
-
logger.info("Skipped brain creation.");
|
|
5262
5291
|
onDone({ brainId: "", displayName: stage.displayName });
|
|
5263
5292
|
return;
|
|
5264
5293
|
}
|
|
@@ -5266,13 +5295,19 @@ function BrainApp({
|
|
|
5266
5295
|
setError("Seed cannot be empty (or type 'skip')");
|
|
5267
5296
|
return;
|
|
5268
5297
|
}
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5298
|
+
setBusy(true);
|
|
5299
|
+
setError(null);
|
|
5300
|
+
Brain.create(stage.displayName, seed).then((result) => {
|
|
5301
|
+
setBusy(false);
|
|
5302
|
+
if ("error" in result) {
|
|
5303
|
+
setError(`Brain creation failed: ${result.error} (fix seed, or type 'skip')`);
|
|
5304
|
+
return;
|
|
5305
|
+
}
|
|
5306
|
+
onDone({
|
|
5307
|
+
brainId: result.brainId,
|
|
5308
|
+
displayName: stage.displayName
|
|
5309
|
+
});
|
|
5310
|
+
});
|
|
5276
5311
|
}
|
|
5277
5312
|
}, undefined, false, undefined, this),
|
|
5278
5313
|
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
@@ -5313,8 +5348,7 @@ function ChannelApp({
|
|
|
5313
5348
|
items: ["discord", "telegram", "skip"],
|
|
5314
5349
|
onSelect: (v) => {
|
|
5315
5350
|
if (v === "skip") {
|
|
5316
|
-
|
|
5317
|
-
onDone();
|
|
5351
|
+
onDone("Skipped channel setup.");
|
|
5318
5352
|
return;
|
|
5319
5353
|
}
|
|
5320
5354
|
setError(null);
|
|
@@ -5373,37 +5407,41 @@ function ChannelApp({
|
|
|
5373
5407
|
}, undefined, true, undefined, this),
|
|
5374
5408
|
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
5375
5409
|
prompt: `${stage.kind_ === "discord" ? "channelId" : "chatId"}> `,
|
|
5376
|
-
onSubmit:
|
|
5410
|
+
onSubmit: (raw) => {
|
|
5377
5411
|
const target = raw.trim();
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
}
|
|
5383
|
-
let updated;
|
|
5384
|
-
if (stage.kind_ === "discord") {
|
|
5385
|
-
updated = {
|
|
5386
|
-
...existing,
|
|
5387
|
-
channel: "discord",
|
|
5388
|
-
discord: { token: stage.token, channelId: target || undefined },
|
|
5389
|
-
activated: true
|
|
5390
|
-
};
|
|
5391
|
-
} else {
|
|
5392
|
-
const chatId = target ? Number(target) : undefined;
|
|
5393
|
-
if (target && Number.isNaN(chatId)) {
|
|
5394
|
-
setError("chatId must be a number");
|
|
5412
|
+
(async () => {
|
|
5413
|
+
const existing = await brainManager.loadBrain(brainId);
|
|
5414
|
+
if (!existing) {
|
|
5415
|
+
setError(`Brain ${brainId} no longer exists`);
|
|
5395
5416
|
return;
|
|
5396
5417
|
}
|
|
5397
|
-
updated
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5418
|
+
let updated;
|
|
5419
|
+
if (stage.kind_ === "discord") {
|
|
5420
|
+
updated = {
|
|
5421
|
+
...existing,
|
|
5422
|
+
channel: "discord",
|
|
5423
|
+
discord: {
|
|
5424
|
+
token: stage.token,
|
|
5425
|
+
channelId: target || undefined
|
|
5426
|
+
},
|
|
5427
|
+
activated: true
|
|
5428
|
+
};
|
|
5429
|
+
} else {
|
|
5430
|
+
const chatId = target ? Number(target) : undefined;
|
|
5431
|
+
if (target && Number.isNaN(chatId)) {
|
|
5432
|
+
setError("chatId must be a number");
|
|
5433
|
+
return;
|
|
5434
|
+
}
|
|
5435
|
+
updated = {
|
|
5436
|
+
...existing,
|
|
5437
|
+
channel: "telegram",
|
|
5438
|
+
telegram: { token: stage.token, chatId },
|
|
5439
|
+
activated: true
|
|
5440
|
+
};
|
|
5441
|
+
}
|
|
5442
|
+
await brainManager.saveBrain(brainId, updated);
|
|
5443
|
+
onDone(`Bound ${displayName} → ${stage.kind_}${target ? ` (${target})` : " (pairing mode)"}`);
|
|
5444
|
+
})();
|
|
5407
5445
|
}
|
|
5408
5446
|
}, undefined, false, undefined, this),
|
|
5409
5447
|
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
@@ -5414,46 +5452,52 @@ function ChannelApp({
|
|
|
5414
5452
|
}, undefined, true, undefined, this);
|
|
5415
5453
|
}
|
|
5416
5454
|
async function runOnboard() {
|
|
5417
|
-
|
|
5455
|
+
console.clear();
|
|
5456
|
+
info(`Welcome — let's get ${chalk3.bold("brainbox")} ready.`);
|
|
5418
5457
|
const providers = listProviderNames().slice().sort();
|
|
5419
5458
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
5420
|
-
|
|
5459
|
+
const active = { current: null };
|
|
5460
|
+
active.current = render3(/* @__PURE__ */ jsxDEV5(ProviderApp, {
|
|
5421
5461
|
providers,
|
|
5422
5462
|
onDone: (p) => {
|
|
5423
|
-
active
|
|
5424
|
-
active = render3(/* @__PURE__ */ jsxDEV5(ModelApp2, {
|
|
5463
|
+
show(active, /* @__PURE__ */ jsxDEV5(ModelApp2, {
|
|
5425
5464
|
provider: p.provider,
|
|
5426
|
-
onDone: () => {
|
|
5427
|
-
active
|
|
5428
|
-
active = render3(/* @__PURE__ */ jsxDEV5(SuperMemoryApp, {
|
|
5465
|
+
onDone: (model) => {
|
|
5466
|
+
show(active, /* @__PURE__ */ jsxDEV5(SuperMemoryApp, {
|
|
5429
5467
|
onDone: () => {
|
|
5430
|
-
active
|
|
5431
|
-
active = render3(/* @__PURE__ */ jsxDEV5(BrainApp, {
|
|
5468
|
+
show(active, /* @__PURE__ */ jsxDEV5(BrainApp, {
|
|
5432
5469
|
onDone: (b) => {
|
|
5433
|
-
active.unmount();
|
|
5434
5470
|
if (!b.brainId) {
|
|
5471
|
+
active.current.unmount();
|
|
5472
|
+
console.clear();
|
|
5473
|
+
info("Skipped brain creation.");
|
|
5435
5474
|
resolve2();
|
|
5436
5475
|
return;
|
|
5437
5476
|
}
|
|
5438
|
-
active
|
|
5477
|
+
show(active, /* @__PURE__ */ jsxDEV5(ChannelApp, {
|
|
5439
5478
|
brainId: b.brainId,
|
|
5440
5479
|
displayName: b.displayName,
|
|
5441
|
-
onDone: () => {
|
|
5442
|
-
active.unmount();
|
|
5480
|
+
onDone: (status) => {
|
|
5481
|
+
active.current.unmount();
|
|
5482
|
+
console.clear();
|
|
5483
|
+
if (status.startsWith("Skipped"))
|
|
5484
|
+
info(status);
|
|
5485
|
+
else
|
|
5486
|
+
ok(status);
|
|
5443
5487
|
resolve2();
|
|
5444
5488
|
}
|
|
5445
|
-
}, undefined, false, undefined, this));
|
|
5489
|
+
}, undefined, false, undefined, this), `Created brain "${b.displayName}" (${chalk3.cyan(b.brainId)})`);
|
|
5446
5490
|
}
|
|
5447
|
-
}, undefined, false, undefined, this));
|
|
5491
|
+
}, undefined, false, undefined, this), "Saved supermemory key to brainbox.yaml");
|
|
5448
5492
|
}
|
|
5449
|
-
}, undefined, false, undefined, this));
|
|
5493
|
+
}, undefined, false, undefined, this), `Set identity + conversation model to ${model}`);
|
|
5450
5494
|
}
|
|
5451
|
-
}, undefined, false, undefined, this));
|
|
5495
|
+
}, undefined, false, undefined, this), `Saved ${p.provider} to auth.yaml`);
|
|
5452
5496
|
}
|
|
5453
5497
|
}, undefined, false, undefined, this));
|
|
5454
5498
|
await promise;
|
|
5455
|
-
|
|
5456
|
-
|
|
5499
|
+
ok("Onboarding complete.");
|
|
5500
|
+
info(`Run ${chalk3.cyan("brainbox daemon")} to bring it online.`);
|
|
5457
5501
|
}
|
|
5458
5502
|
function register8(program) {
|
|
5459
5503
|
return registerCommand(program, {
|