@songsid/agend 2.0.11-beta.34 → 2.0.11-beta.36
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/fleet-manager.js +17 -17
- package/dist/fleet-manager.js.map +1 -1
- package/dist/instance-lifecycle.js +8 -7
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +46 -4
- package/dist/locale.js.map +1 -1
- package/package.json +1 -1
package/dist/fleet-manager.js
CHANGED
|
@@ -494,11 +494,11 @@ export class FleetManager {
|
|
|
494
494
|
this.logger.info({ count: webhookConfigs.length }, "Webhook emitter initialized");
|
|
495
495
|
}
|
|
496
496
|
this.costGuard.on("warn", safeHandler((instance, totalCents, limitCents) => {
|
|
497
|
-
this.notifyInstanceTopic(instance,
|
|
497
|
+
this.notifyInstanceTopic(instance, t("cost.approaching", instance, formatCents(totalCents), formatCents(limitCents), Math.round(totalCents / limitCents * 100)));
|
|
498
498
|
this.webhookEmitter?.emit("cost_warning", instance, { cost_cents: totalCents, limit_cents: limitCents });
|
|
499
499
|
}, this.logger, "costGuard.warn"));
|
|
500
500
|
this.costGuard.on("limit", safeHandler(async (instance, totalCents, limitCents) => {
|
|
501
|
-
this.notifyInstanceTopic(instance,
|
|
501
|
+
this.notifyInstanceTopic(instance, t("cost.limit_reached", instance, formatCents(limitCents)));
|
|
502
502
|
this.eventLog?.insert(instance, "instance_paused", { reason: "cost_limit", cost_cents: totalCents });
|
|
503
503
|
this.webhookEmitter?.emit("cost_limit", instance, { cost_cents: totalCents, limit_cents: limitCents });
|
|
504
504
|
await this.stopInstance(instance);
|
|
@@ -651,7 +651,7 @@ export class FleetManager {
|
|
|
651
651
|
if (this.adapter && topicId) {
|
|
652
652
|
const chatId = this.adapter.getChatId?.() ?? "";
|
|
653
653
|
if (chatId) {
|
|
654
|
-
this.adapter.sendText(chatId,
|
|
654
|
+
this.adapter.sendText(chatId, t("general.start_failed", name, errorMsg), { threadId: topicId }).catch(() => { });
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
657
|
}
|
|
@@ -746,8 +746,8 @@ export class FleetManager {
|
|
|
746
746
|
const agendVersion = _require("../package.json").version ?? "unknown";
|
|
747
747
|
if (this.adapter && fleet.channel?.group_id) {
|
|
748
748
|
const text = failedNames.length === 0
|
|
749
|
-
?
|
|
750
|
-
:
|
|
749
|
+
? t("fleet.ready", started, total, agendVersion)
|
|
750
|
+
: t("fleet.ready_with_failed", started, total, agendVersion, failedNames.join(", "));
|
|
751
751
|
this.adapter.sendText(String(fleet.channel.group_id), text, {
|
|
752
752
|
threadId: generalThreadId != null ? String(generalThreadId) : undefined,
|
|
753
753
|
}).catch(e => this.logger.warn({ err: e }, "Failed to send fleet start notification"));
|
|
@@ -1107,7 +1107,7 @@ export class FleetManager {
|
|
|
1107
1107
|
this.restartAdapter(this.adapter, "primary").catch(() => { });
|
|
1108
1108
|
});
|
|
1109
1109
|
this.adapter.on("new_group_detected", safeHandler((data) => {
|
|
1110
|
-
const adminMsg =
|
|
1110
|
+
const adminMsg = t("alert.bot_added", data.groupTitle, data.groupId, data.source);
|
|
1111
1111
|
const generalId = this.findGeneralInstance();
|
|
1112
1112
|
if (generalId)
|
|
1113
1113
|
this.notifyInstanceTopic(generalId, adminMsg);
|
|
@@ -1368,7 +1368,7 @@ export class FleetManager {
|
|
|
1368
1368
|
}
|
|
1369
1369
|
}, this.logger, `adapter[${adapterId}].started`));
|
|
1370
1370
|
adapter.on("new_group_detected", safeHandler((data) => {
|
|
1371
|
-
const adminMsg =
|
|
1371
|
+
const adminMsg = t("alert.bot_added", data.groupTitle, data.groupId, data.source);
|
|
1372
1372
|
const generalId = this.findGeneralInstance(adapterId);
|
|
1373
1373
|
if (generalId)
|
|
1374
1374
|
this.notifyInstanceTopic(generalId, adminMsg);
|
|
@@ -1686,7 +1686,7 @@ export class FleetManager {
|
|
|
1686
1686
|
if (!this.classicChannels.isUserAllowed(msg.userId)) {
|
|
1687
1687
|
const generalId = this.findGeneralInstance(msg.adapterId);
|
|
1688
1688
|
if (generalId) {
|
|
1689
|
-
this.notifyInstanceTopic(generalId,
|
|
1689
|
+
this.notifyInstanceTopic(generalId, t("alert.unauth_user_private", msg.username, msg.userId, msg.source));
|
|
1690
1690
|
}
|
|
1691
1691
|
await msgAdapter?.sendText(chatId, t("classic.not_allowed_user"));
|
|
1692
1692
|
return;
|
|
@@ -1696,7 +1696,7 @@ export class FleetManager {
|
|
|
1696
1696
|
if (!this.classicChannels.isGroupAllowed(chatId)) {
|
|
1697
1697
|
// Notify admin about new group wanting access
|
|
1698
1698
|
const groupTitle = msg.chatTitle || chatId;
|
|
1699
|
-
const adminMsg =
|
|
1699
|
+
const adminMsg = t("alert.new_group", groupTitle, chatId, msg.username, msg.userId, msg.source);
|
|
1700
1700
|
const generalId = this.findGeneralInstance(msg.adapterId);
|
|
1701
1701
|
if (generalId) {
|
|
1702
1702
|
this.notifyInstanceTopic(generalId, adminMsg);
|
|
@@ -1708,7 +1708,7 @@ export class FleetManager {
|
|
|
1708
1708
|
await msgAdapter?.sendText(chatId, t("classic.admin_only_start"));
|
|
1709
1709
|
const generalId = this.findGeneralInstance(msg.adapterId);
|
|
1710
1710
|
if (generalId) {
|
|
1711
|
-
this.notifyInstanceTopic(generalId,
|
|
1711
|
+
this.notifyInstanceTopic(generalId, t("alert.start_not_admin", msg.username, msg.userId, msg.source, chatId));
|
|
1712
1712
|
}
|
|
1713
1713
|
return;
|
|
1714
1714
|
}
|
|
@@ -1725,7 +1725,7 @@ export class FleetManager {
|
|
|
1725
1725
|
await msgAdapter?.sendText(chatId, t("classic.admin_only_stop"));
|
|
1726
1726
|
const generalId = this.findGeneralInstance(msg.adapterId);
|
|
1727
1727
|
if (generalId) {
|
|
1728
|
-
this.notifyInstanceTopic(generalId,
|
|
1728
|
+
this.notifyInstanceTopic(generalId, t("alert.stop_not_admin", msg.username, msg.userId, msg.source, chatId));
|
|
1729
1729
|
}
|
|
1730
1730
|
return;
|
|
1731
1731
|
}
|
|
@@ -2118,7 +2118,7 @@ export class FleetManager {
|
|
|
2118
2118
|
five_hour_pct: rl.five_hour_pct,
|
|
2119
2119
|
});
|
|
2120
2120
|
this.webhookEmitter?.emit("schedule_deferred", target, { schedule_id: id, label, five_hour_pct: rl.five_hour_pct });
|
|
2121
|
-
this.notifyInstanceTopic(target,
|
|
2121
|
+
this.notifyInstanceTopic(target, t("schedule.deferred", label ?? id, rl.five_hour_pct));
|
|
2122
2122
|
this.logger.info({ target, scheduleId: id, rateLimitPct: rl.five_hour_pct }, "Schedule deferred due to rate limit");
|
|
2123
2123
|
return;
|
|
2124
2124
|
}
|
|
@@ -3628,7 +3628,7 @@ When users create specialized instances, suggest these configurations:
|
|
|
3628
3628
|
if (guildId && !this.classicChannels.isGuildAllowed(guildId)) {
|
|
3629
3629
|
const generalId = this.findGeneralInstance();
|
|
3630
3630
|
if (generalId) {
|
|
3631
|
-
this.notifyInstanceTopic(generalId,
|
|
3631
|
+
this.notifyInstanceTopic(generalId, t("alert.unauth_guild", guildId, userId));
|
|
3632
3632
|
}
|
|
3633
3633
|
return t("classic.not_authorized_guild");
|
|
3634
3634
|
}
|
|
@@ -3809,7 +3809,7 @@ When users create specialized instances, suggest these configurations:
|
|
|
3809
3809
|
this.logger.info(`Full restart: waiting for ${instanceNames.length} instances to idle...`);
|
|
3810
3810
|
const groupId = this.fleetConfig?.channel?.group_id;
|
|
3811
3811
|
if (groupId && this.adapter) {
|
|
3812
|
-
await this.adapter.sendText(String(groupId),
|
|
3812
|
+
await this.adapter.sendText(String(groupId), t("restart.full_initiated"))
|
|
3813
3813
|
.catch(e => this.logger.warn({ err: e }, "Failed to post full restart notification"));
|
|
3814
3814
|
}
|
|
3815
3815
|
// Wait for idle with 5-minute timeout
|
|
@@ -3920,7 +3920,7 @@ When users create specialized instances, suggest these configurations:
|
|
|
3920
3920
|
const generalThreadId = generalName ? this.fleetConfig?.instances[generalName]?.topic_id : undefined;
|
|
3921
3921
|
const notifyOpts = { threadId: generalThreadId != null ? String(generalThreadId) : undefined };
|
|
3922
3922
|
if (groupId && this.adapter) {
|
|
3923
|
-
await this.adapter.sendText(String(groupId),
|
|
3923
|
+
await this.adapter.sendText(String(groupId), t("restart.graceful_initiated"), notifyOpts)
|
|
3924
3924
|
.catch(e => this.logger.warn({ err: e }, "Failed to post restart notification"));
|
|
3925
3925
|
}
|
|
3926
3926
|
const IDLE_TIMEOUT_MS = 5 * 60 * 1000;
|
|
@@ -4011,8 +4011,8 @@ When users create specialized instances, suggest these configurations:
|
|
|
4011
4011
|
const _require2 = createRequire(import.meta.url);
|
|
4012
4012
|
const agendVersion2 = _require2("../package.json").version ?? "unknown";
|
|
4013
4013
|
const restartText = failedNames.length === 0
|
|
4014
|
-
?
|
|
4015
|
-
:
|
|
4014
|
+
? t("fleet.ready", started, total, agendVersion2)
|
|
4015
|
+
: t("fleet.ready_with_failed", started, total, agendVersion2, failedNames.join(", "));
|
|
4016
4016
|
await this.adapter.sendText(String(groupId), restartText, notifyOpts)
|
|
4017
4017
|
.catch(e => this.logger.warn({ err: e }, "Failed to post restart completion notification"));
|
|
4018
4018
|
// Notify each instance's channel — staggered to avoid rate limit storm
|