switchroom 0.14.85 → 0.14.87
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/auth-broker/index.js +9 -9
- package/dist/cli/autoaccept-poll.js +1 -1
- package/dist/cli/switchroom.js +551 -75
- package/package.json +1 -1
- package/telegram-plugin/dist/gateway/gateway.js +17 -8
- package/telegram-plugin/gateway/exhaust-until.ts +45 -0
- package/telegram-plugin/gateway/gateway.ts +18 -10
- package/telegram-plugin/tests/exhaust-until.test.ts +86 -0
|
@@ -13941,24 +13941,24 @@ class AuthBroker {
|
|
|
13941
13941
|
}
|
|
13942
13942
|
servingAccount(identity2) {
|
|
13943
13943
|
const account = this.callerAccount(identity2);
|
|
13944
|
-
if (identity2.kind
|
|
13944
|
+
if (identity2.kind === "operator")
|
|
13945
13945
|
return account;
|
|
13946
|
-
return this.
|
|
13946
|
+
return this.accountWithFailover(account);
|
|
13947
13947
|
}
|
|
13948
13948
|
isAccountExhausted(account) {
|
|
13949
13949
|
const q = this.quota[account];
|
|
13950
13950
|
return q !== undefined && q.exhausted_until > this.now();
|
|
13951
13951
|
}
|
|
13952
|
-
|
|
13953
|
-
if (!
|
|
13954
|
-
return
|
|
13952
|
+
accountWithFailover(account) {
|
|
13953
|
+
if (!account || !this.isAccountExhausted(account))
|
|
13954
|
+
return account ?? null;
|
|
13955
13955
|
for (const cand of this.config.auth?.fallback_order ?? []) {
|
|
13956
|
-
if (cand ===
|
|
13956
|
+
if (cand === account || this.isAccountExhausted(cand))
|
|
13957
13957
|
continue;
|
|
13958
13958
|
if (readAccountCredentials(cand, this.home))
|
|
13959
13959
|
return cand;
|
|
13960
13960
|
}
|
|
13961
|
-
return
|
|
13961
|
+
return account;
|
|
13962
13962
|
}
|
|
13963
13963
|
async opGetCredentials(socket, id, identity2) {
|
|
13964
13964
|
const account = this.servingAccount(identity2);
|
|
@@ -14600,7 +14600,7 @@ class AuthBroker {
|
|
|
14600
14600
|
const auth = this.config.auth ?? {};
|
|
14601
14601
|
const fanned = [];
|
|
14602
14602
|
for (const [name, agent] of Object.entries(this.config.agents ?? {})) {
|
|
14603
|
-
const effective = agent.auth?.override ?? auth.active;
|
|
14603
|
+
const effective = this.accountWithFailover(agent.auth?.override ?? auth.active);
|
|
14604
14604
|
if (effective === label) {
|
|
14605
14605
|
if (this.fanoutForAgent(name))
|
|
14606
14606
|
fanned.push(name);
|
|
@@ -14645,7 +14645,7 @@ class AuthBroker {
|
|
|
14645
14645
|
const agent = (this.config.agents ?? {})[name];
|
|
14646
14646
|
if (!agent)
|
|
14647
14647
|
return false;
|
|
14648
|
-
const effective = agent.auth?.override ?? auth.active;
|
|
14648
|
+
const effective = this.accountWithFailover(agent.auth?.override ?? auth.active);
|
|
14649
14649
|
if (!effective)
|
|
14650
14650
|
return false;
|
|
14651
14651
|
return this.mirrorAccountToAgent(effective, name);
|
|
@@ -176,7 +176,7 @@ function sendKeys2(agentName, keys) {
|
|
|
176
176
|
|
|
177
177
|
// src/agents/wedge-watchdog.ts
|
|
178
178
|
var WEDGE_FOOTER_SIGNATURE = /(?=[\s\S]*[Ee]sc(?:ape)?[^\n]*cancel)(?=[\s\S]*(?:to select|to navigate|\u2191\/\u2193))/;
|
|
179
|
-
var RATE_LIMIT_MENU_SIGNATURE = /(?=[\s\S]
|
|
179
|
+
var RATE_LIMIT_MENU_SIGNATURE = /(?=[\s\S]*Stop and wait for)(?=[\s\S]*(?:usage credits|Upgrade your plan|\/rate-limit-options))/;
|
|
180
180
|
var MONTHS = {
|
|
181
181
|
jan: 0,
|
|
182
182
|
feb: 1,
|