@p-sw/brainbox 0.1.2-alpha.5 → 0.1.2-alpha.7
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 +31 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -295,7 +295,7 @@ function removeProviderAuth(provider) {
|
|
|
295
295
|
// src/config/index.ts
|
|
296
296
|
var config = {
|
|
297
297
|
get debug() {
|
|
298
|
-
return readRootFile().debug;
|
|
298
|
+
return process.env.DEBUG_MODE ? process.env.DEBUG_MODE.toLowerCase() === "true" : readRootFile().debug;
|
|
299
299
|
},
|
|
300
300
|
brainboxRoot,
|
|
301
301
|
get supermemoryApiKey() {
|
|
@@ -2567,13 +2567,13 @@ class Brain {
|
|
|
2567
2567
|
db;
|
|
2568
2568
|
space;
|
|
2569
2569
|
brainbase;
|
|
2570
|
-
memory;
|
|
2571
2570
|
availabilityCache = new Map;
|
|
2572
|
-
|
|
2571
|
+
memory;
|
|
2572
|
+
constructor(db, space, brainbase, memory) {
|
|
2573
2573
|
this.db = db;
|
|
2574
2574
|
this.space = space;
|
|
2575
2575
|
this.brainbase = brainbase;
|
|
2576
|
-
this.memory = memory;
|
|
2576
|
+
this.memory = memory ?? new Memory(this.db, this.space);
|
|
2577
2577
|
log7.debug(`Brain constructed: id=${brainbase.brainId} name=${brainbase.displayName} space=${space.name}`);
|
|
2578
2578
|
}
|
|
2579
2579
|
async createDailySchedule(datetime) {
|
|
@@ -3356,7 +3356,7 @@ class BaseChannel {
|
|
|
3356
3356
|
}, callback);
|
|
3357
3357
|
}
|
|
3358
3358
|
getRegisteredCrons() {
|
|
3359
|
-
return scheduledJobs.filter((c) => c.name && c.name.startsWith(this.resolveCronPrefix()))
|
|
3359
|
+
return scheduledJobs.filter((c) => c.name && c.name.startsWith(this.resolveCronPrefix()));
|
|
3360
3360
|
}
|
|
3361
3361
|
pauseCron(key) {
|
|
3362
3362
|
const job = scheduledJobs.find((c) => c.name === this.resolveCronName(key));
|
|
@@ -3447,6 +3447,13 @@ class BaseChannel {
|
|
|
3447
3447
|
this.isChattingDebounce = null;
|
|
3448
3448
|
}, IS_CHATTING_DEBOUNCE_MS);
|
|
3449
3449
|
}
|
|
3450
|
+
async initAvailability() {
|
|
3451
|
+
const current = await this.brain.getAvailability();
|
|
3452
|
+
this.previousAvailability = current.status;
|
|
3453
|
+
logger.debug(`initAvailability: ${current.status}`);
|
|
3454
|
+
await this.setAvailability(current.status);
|
|
3455
|
+
this.ensureAvailabilityWatcher();
|
|
3456
|
+
}
|
|
3450
3457
|
ensureAvailabilityWatcher() {
|
|
3451
3458
|
if (this.isCronStarted(AVAILABILITY_WATCHER_KEY))
|
|
3452
3459
|
return;
|
|
@@ -3456,6 +3463,9 @@ class BaseChannel {
|
|
|
3456
3463
|
const prev = this.previousAvailability;
|
|
3457
3464
|
this.previousAvailability = current.status;
|
|
3458
3465
|
logger.debug(`availabilityWatcher: ${prev ?? "(initial)"} → ${current.status}`);
|
|
3466
|
+
if (prev !== current.status) {
|
|
3467
|
+
await this.setAvailability(current.status);
|
|
3468
|
+
}
|
|
3459
3469
|
if (prev !== null && prev !== "online" && current.status === "online") {
|
|
3460
3470
|
await this.flushDeferred();
|
|
3461
3471
|
}
|
|
@@ -3516,8 +3526,8 @@ class BaseChannel {
|
|
|
3516
3526
|
logger.debug(`shutdown: done`);
|
|
3517
3527
|
}
|
|
3518
3528
|
stopOwnCrons() {
|
|
3519
|
-
for (const
|
|
3520
|
-
|
|
3529
|
+
for (const cron of this.getRegisteredCrons()) {
|
|
3530
|
+
cron.stop();
|
|
3521
3531
|
}
|
|
3522
3532
|
}
|
|
3523
3533
|
clearTimers() {
|
|
@@ -3627,6 +3637,7 @@ class DiscordChannel extends BaseChannel {
|
|
|
3627
3637
|
logger.debug(`DiscordClientReady: resolving configured channel ${channelId}`);
|
|
3628
3638
|
this.resolveConfiguredChannel(channelId);
|
|
3629
3639
|
}
|
|
3640
|
+
this.initAvailability();
|
|
3630
3641
|
});
|
|
3631
3642
|
this.client.on(Events.MessageCreate, (msg) => {
|
|
3632
3643
|
if (msg.author.bot)
|
|
@@ -3795,6 +3806,7 @@ class TelegramChannel extends BaseChannel {
|
|
|
3795
3806
|
this.registerActive();
|
|
3796
3807
|
this.bot.onStart(({ info }) => {
|
|
3797
3808
|
logger.success(`Telegram ready as @${info.username}`);
|
|
3809
|
+
this.initAvailability();
|
|
3798
3810
|
});
|
|
3799
3811
|
this.bot.on("message", (ctx) => {
|
|
3800
3812
|
if (ctx.from?.isBot())
|
|
@@ -4342,6 +4354,9 @@ function RawInput({
|
|
|
4342
4354
|
onSubmit
|
|
4343
4355
|
}) {
|
|
4344
4356
|
const [value, setValue] = useState(initialValue);
|
|
4357
|
+
useEffect(() => {
|
|
4358
|
+
setValue(initialValue);
|
|
4359
|
+
}, [prompt, initialValue]);
|
|
4345
4360
|
useInput((input, key) => {
|
|
4346
4361
|
if (key.return) {
|
|
4347
4362
|
onSubmit(value);
|
|
@@ -5199,7 +5214,7 @@ function ModelApp2({
|
|
|
5199
5214
|
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5200
5215
|
dimColor: true,
|
|
5201
5216
|
children: [
|
|
5202
|
-
"
|
|
5217
|
+
"model name, or ",
|
|
5203
5218
|
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5204
5219
|
color: "cyan",
|
|
5205
5220
|
children: [
|
|
@@ -5207,7 +5222,7 @@ function ModelApp2({
|
|
|
5207
5222
|
"/"
|
|
5208
5223
|
]
|
|
5209
5224
|
}, undefined, true, undefined, this),
|
|
5210
|
-
"model
|
|
5225
|
+
"model — fine-tune later with ",
|
|
5211
5226
|
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5212
5227
|
color: "cyan",
|
|
5213
5228
|
children: "brainbox model"
|
|
@@ -5222,13 +5237,15 @@ function ModelApp2({
|
|
|
5222
5237
|
setError("Model cannot be empty");
|
|
5223
5238
|
return;
|
|
5224
5239
|
}
|
|
5225
|
-
|
|
5226
|
-
|
|
5240
|
+
const prefix = `${provider}/`;
|
|
5241
|
+
const full = value.startsWith(prefix) ? value : `${prefix}${value}`;
|
|
5242
|
+
if (full === prefix) {
|
|
5243
|
+
setError("Model cannot be empty");
|
|
5227
5244
|
return;
|
|
5228
5245
|
}
|
|
5229
|
-
setModelSlot("identity",
|
|
5230
|
-
setModelSlot("conversation",
|
|
5231
|
-
onDone(
|
|
5246
|
+
setModelSlot("identity", full);
|
|
5247
|
+
setModelSlot("conversation", full);
|
|
5248
|
+
onDone(full);
|
|
5232
5249
|
}
|
|
5233
5250
|
}, undefined, false, undefined, this),
|
|
5234
5251
|
error && /* @__PURE__ */ jsxDEV5(Text5, {
|