@p-sw/brainbox 0.1.2-alpha.2 → 0.1.2-alpha.3

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.
Files changed (2) hide show
  1. package/dist/index.js +108 -78
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1098,12 +1098,12 @@ class ZenMuxExecutor extends OpenAICompatibleExecutor {
1098
1098
  }
1099
1099
  }
1100
1100
 
1101
- // src/provider/providers/MiniMax.ts
1101
+ // src/provider/providers/minimax.ts
1102
1102
  class MiniMaxExecutor extends OpenAICompatibleExecutor {
1103
1103
  constructor(opts) {
1104
1104
  super({
1105
- providerName: "MiniMax",
1106
- baseURL: "https://api.MiniMax.chat/v1",
1105
+ providerName: "minimax",
1106
+ baseURL: "https://api.minimax.chat/v1",
1107
1107
  apiKey: opts.apiKey,
1108
1108
  conversationModel: opts.conversationModel,
1109
1109
  identityModel: opts.identityModel
@@ -2241,7 +2241,7 @@ register("stackit", StackitExecutor);
2241
2241
  register("gmi", GmiExecutor);
2242
2242
  register("zai", ZaiExecutor);
2243
2243
  register("zenmux", ZenMuxExecutor);
2244
- register("MiniMax", MiniMaxExecutor);
2244
+ register("minimax", MiniMaxExecutor);
2245
2245
  register("ionet", IoNetExecutor);
2246
2246
  register("baseten", BasetenExecutor);
2247
2247
  register("cortecs", CortecsExecutor);
@@ -3064,9 +3064,12 @@ ${personaSystemFixed}`;
3064
3064
  log7.debug(`Brain.create: brainbase saved (id=${brainId})`);
3065
3065
  return { brainId, brain: new Brain(db, space, brainbase, memory) };
3066
3066
  } catch (error) {
3067
- const reason = error instanceof Error ? error.message : String(error);
3068
- logger.error(`Failed to create brain "${displayName}": ${reason}`);
3069
- return null;
3067
+ let reason = error instanceof Error ? `${error.message} (${error.name})` : String(error);
3068
+ if (error instanceof BadRequestResponseError) {
3069
+ reason = `${reason} ${JSON.stringify(error.body)}`;
3070
+ }
3071
+ log7.debug(`Brain.create failed: ${reason}`);
3072
+ return { error: reason };
3070
3073
  }
3071
3074
  }
3072
3075
  static async delete(brainId) {
@@ -4116,7 +4119,8 @@ async function deactivateBrain(brainId) {
4116
4119
  async function createBrain(displayName, seed, options) {
4117
4120
  logger.debug(`createBrain: name="${displayName}" seed length=${seed.length} schedule=${options.schedule}`);
4118
4121
  const result = await Brain.create(displayName, seed);
4119
- if (!result) {
4122
+ if ("error" in result) {
4123
+ logger.error(`Failed to create brain "${displayName}": ${result.error}`);
4120
4124
  process.exitCode = 1;
4121
4125
  return;
4122
4126
  }
@@ -4968,6 +4972,19 @@ function Select(props) {
4968
4972
 
4969
4973
  // src/commands/onboard.tsx
4970
4974
  import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
4975
+ function ok(msg) {
4976
+ console.log(chalk3.green(`✔ ${msg}`));
4977
+ }
4978
+ function info(msg) {
4979
+ console.log(msg);
4980
+ }
4981
+ function show(active, node, status) {
4982
+ active.current.unmount();
4983
+ console.clear();
4984
+ if (status)
4985
+ ok(status);
4986
+ active.current = render3(node);
4987
+ }
4971
4988
  function ProviderApp({
4972
4989
  providers,
4973
4990
  onDone
@@ -5039,7 +5056,6 @@ function ProviderApp({
5039
5056
  const extras = PROVIDER_EXTRA_FIELDS[stage.provider] ?? [];
5040
5057
  if (extras.length === 0) {
5041
5058
  setProviderAuth(stage.provider, { apiKey });
5042
- logger.success(`Saved ${stage.provider} to auth.yaml`);
5043
5059
  onDone({ provider: stage.provider });
5044
5060
  return;
5045
5061
  }
@@ -5060,13 +5076,6 @@ function ProviderApp({
5060
5076
  }, undefined, true, undefined, this);
5061
5077
  }
5062
5078
  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
5079
  return /* @__PURE__ */ jsxDEV5(Box4, {
5071
5080
  flexDirection: "column",
5072
5081
  children: [
@@ -5092,6 +5101,11 @@ function ProviderApp({
5092
5101
  const values = { ...stage.values };
5093
5102
  if (value)
5094
5103
  values[nextField] = value;
5104
+ if (remaining.length === 0) {
5105
+ setProviderAuth(stage.provider, values);
5106
+ onDone({ provider: stage.provider });
5107
+ return;
5108
+ }
5095
5109
  setStage({
5096
5110
  kind: "extras",
5097
5111
  provider: stage.provider,
@@ -5149,8 +5163,7 @@ function ModelApp2({
5149
5163
  }
5150
5164
  setModelSlot("identity", value);
5151
5165
  setModelSlot("conversation", value);
5152
- logger.success(`Set identity + conversation model to ${value}`);
5153
- onDone();
5166
+ onDone(value);
5154
5167
  }
5155
5168
  }, undefined, false, undefined, this),
5156
5169
  error && /* @__PURE__ */ jsxDEV5(Text5, {
@@ -5186,7 +5199,6 @@ function SuperMemoryApp({
5186
5199
  return;
5187
5200
  }
5188
5201
  setSupermemoryKey(key);
5189
- logger.success("Saved supermemory key to brainbox.yaml");
5190
5202
  onDone();
5191
5203
  }
5192
5204
  }, undefined, false, undefined, this),
@@ -5202,6 +5214,7 @@ function BrainApp({
5202
5214
  }) {
5203
5215
  const [stage, setStage] = useState5({ kind: "name" });
5204
5216
  const [error, setError] = useState5(null);
5217
+ const [busy, setBusy] = useState5(false);
5205
5218
  if (stage.kind === "name") {
5206
5219
  return /* @__PURE__ */ jsxDEV5(Box4, {
5207
5220
  flexDirection: "column",
@@ -5253,12 +5266,14 @@ function BrainApp({
5253
5266
  dimColor: true,
5254
5267
  children: "One sentence about who they are. The model will expand it."
5255
5268
  }, undefined, false, undefined, this),
5256
- /* @__PURE__ */ jsxDEV5(TextInput, {
5269
+ busy ? /* @__PURE__ */ jsxDEV5(Text5, {
5270
+ dimColor: true,
5271
+ children: "Creating brain…"
5272
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV5(TextInput, {
5257
5273
  prompt: "seed> ",
5258
- onSubmit: async (raw) => {
5274
+ onSubmit: (raw) => {
5259
5275
  const seed = raw.trim();
5260
5276
  if (seed === "skip") {
5261
- logger.info("Skipped brain creation.");
5262
5277
  onDone({ brainId: "", displayName: stage.displayName });
5263
5278
  return;
5264
5279
  }
@@ -5266,13 +5281,19 @@ function BrainApp({
5266
5281
  setError("Seed cannot be empty (or type 'skip')");
5267
5282
  return;
5268
5283
  }
5269
- const result = await Brain.create(stage.displayName, seed);
5270
- if (!result) {
5271
- setError("Brain creation failed (check logs above, or type 'skip')");
5272
- return;
5273
- }
5274
- logger.success(`Created brain "${stage.displayName}" (${chalk3.cyan(result.brainId)})`);
5275
- onDone({ brainId: result.brainId, displayName: stage.displayName });
5284
+ setBusy(true);
5285
+ setError(null);
5286
+ Brain.create(stage.displayName, seed).then((result) => {
5287
+ setBusy(false);
5288
+ if ("error" in result) {
5289
+ setError(`Brain creation failed: ${result.error} (fix seed, or type 'skip')`);
5290
+ return;
5291
+ }
5292
+ onDone({
5293
+ brainId: result.brainId,
5294
+ displayName: stage.displayName
5295
+ });
5296
+ });
5276
5297
  }
5277
5298
  }, undefined, false, undefined, this),
5278
5299
  error && /* @__PURE__ */ jsxDEV5(Text5, {
@@ -5313,8 +5334,7 @@ function ChannelApp({
5313
5334
  items: ["discord", "telegram", "skip"],
5314
5335
  onSelect: (v) => {
5315
5336
  if (v === "skip") {
5316
- logger.info("Skipped channel setup.");
5317
- onDone();
5337
+ onDone("Skipped channel setup.");
5318
5338
  return;
5319
5339
  }
5320
5340
  setError(null);
@@ -5373,37 +5393,41 @@ function ChannelApp({
5373
5393
  }, undefined, true, undefined, this),
5374
5394
  /* @__PURE__ */ jsxDEV5(TextInput, {
5375
5395
  prompt: `${stage.kind_ === "discord" ? "channelId" : "chatId"}> `,
5376
- onSubmit: async (raw) => {
5396
+ onSubmit: (raw) => {
5377
5397
  const target = raw.trim();
5378
- const existing = await brainManager.loadBrain(brainId);
5379
- if (!existing) {
5380
- setError(`Brain ${brainId} no longer exists`);
5381
- return;
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");
5398
+ (async () => {
5399
+ const existing = await brainManager.loadBrain(brainId);
5400
+ if (!existing) {
5401
+ setError(`Brain ${brainId} no longer exists`);
5395
5402
  return;
5396
5403
  }
5397
- updated = {
5398
- ...existing,
5399
- channel: "telegram",
5400
- telegram: { token: stage.token, chatId },
5401
- activated: true
5402
- };
5403
- }
5404
- await brainManager.saveBrain(brainId, updated);
5405
- logger.success(`Bound ${displayName} → ${stage.kind_}${target ? ` (${target})` : " (pairing mode)"}`);
5406
- onDone();
5404
+ let updated;
5405
+ if (stage.kind_ === "discord") {
5406
+ updated = {
5407
+ ...existing,
5408
+ channel: "discord",
5409
+ discord: {
5410
+ token: stage.token,
5411
+ channelId: target || undefined
5412
+ },
5413
+ activated: true
5414
+ };
5415
+ } else {
5416
+ const chatId = target ? Number(target) : undefined;
5417
+ if (target && Number.isNaN(chatId)) {
5418
+ setError("chatId must be a number");
5419
+ return;
5420
+ }
5421
+ updated = {
5422
+ ...existing,
5423
+ channel: "telegram",
5424
+ telegram: { token: stage.token, chatId },
5425
+ activated: true
5426
+ };
5427
+ }
5428
+ await brainManager.saveBrain(brainId, updated);
5429
+ onDone(`Bound ${displayName} → ${stage.kind_}${target ? ` (${target})` : " (pairing mode)"}`);
5430
+ })();
5407
5431
  }
5408
5432
  }, undefined, false, undefined, this),
5409
5433
  error && /* @__PURE__ */ jsxDEV5(Text5, {
@@ -5414,46 +5438,52 @@ function ChannelApp({
5414
5438
  }, undefined, true, undefined, this);
5415
5439
  }
5416
5440
  async function runOnboard() {
5417
- logger.info(`Welcome — let's get ${chalk3.bold("brainbox")} ready.`);
5441
+ console.clear();
5442
+ info(`Welcome — let's get ${chalk3.bold("brainbox")} ready.`);
5418
5443
  const providers = listProviderNames().slice().sort();
5419
5444
  const { promise, resolve: resolve2 } = Promise.withResolvers();
5420
- let active = render3(/* @__PURE__ */ jsxDEV5(ProviderApp, {
5445
+ const active = { current: null };
5446
+ active.current = render3(/* @__PURE__ */ jsxDEV5(ProviderApp, {
5421
5447
  providers,
5422
5448
  onDone: (p) => {
5423
- active.unmount();
5424
- active = render3(/* @__PURE__ */ jsxDEV5(ModelApp2, {
5449
+ show(active, /* @__PURE__ */ jsxDEV5(ModelApp2, {
5425
5450
  provider: p.provider,
5426
- onDone: () => {
5427
- active.unmount();
5428
- active = render3(/* @__PURE__ */ jsxDEV5(SuperMemoryApp, {
5451
+ onDone: (model) => {
5452
+ show(active, /* @__PURE__ */ jsxDEV5(SuperMemoryApp, {
5429
5453
  onDone: () => {
5430
- active.unmount();
5431
- active = render3(/* @__PURE__ */ jsxDEV5(BrainApp, {
5454
+ show(active, /* @__PURE__ */ jsxDEV5(BrainApp, {
5432
5455
  onDone: (b) => {
5433
- active.unmount();
5434
5456
  if (!b.brainId) {
5457
+ active.current.unmount();
5458
+ console.clear();
5459
+ info("Skipped brain creation.");
5435
5460
  resolve2();
5436
5461
  return;
5437
5462
  }
5438
- active = render3(/* @__PURE__ */ jsxDEV5(ChannelApp, {
5463
+ show(active, /* @__PURE__ */ jsxDEV5(ChannelApp, {
5439
5464
  brainId: b.brainId,
5440
5465
  displayName: b.displayName,
5441
- onDone: () => {
5442
- active.unmount();
5466
+ onDone: (status) => {
5467
+ active.current.unmount();
5468
+ console.clear();
5469
+ if (status.startsWith("Skipped"))
5470
+ info(status);
5471
+ else
5472
+ ok(status);
5443
5473
  resolve2();
5444
5474
  }
5445
- }, undefined, false, undefined, this));
5475
+ }, undefined, false, undefined, this), `Created brain "${b.displayName}" (${chalk3.cyan(b.brainId)})`);
5446
5476
  }
5447
- }, undefined, false, undefined, this));
5477
+ }, undefined, false, undefined, this), "Saved supermemory key to brainbox.yaml");
5448
5478
  }
5449
- }, undefined, false, undefined, this));
5479
+ }, undefined, false, undefined, this), `Set identity + conversation model to ${model}`);
5450
5480
  }
5451
- }, undefined, false, undefined, this));
5481
+ }, undefined, false, undefined, this), `Saved ${p.provider} to auth.yaml`);
5452
5482
  }
5453
5483
  }, undefined, false, undefined, this));
5454
5484
  await promise;
5455
- logger.success("Onboarding complete.");
5456
- logger.info(`Run ${chalk3.cyan("brainbox daemon")} to bring it online.`);
5485
+ ok("Onboarding complete.");
5486
+ info(`Run ${chalk3.cyan("brainbox daemon")} to bring it online.`);
5457
5487
  }
5458
5488
  function register8(program) {
5459
5489
  return registerCommand(program, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p-sw/brainbox",
3
- "version": "0.1.2-alpha.2",
3
+ "version": "0.1.2-alpha.3",
4
4
  "module": "dist/index.js",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",