dsh-any-deepseek 0.0.37 โ 0.0.39
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/lib/adapter.d.ts +10 -1
- package/lib/client.js +36 -4
- package/lib/failover.d.ts +221 -2
- package/lib/http.d.ts +18 -0
- package/lib/index.js +387 -28
- package/lib/route.d.ts +19 -0
- package/package.json +1 -1
package/lib/adapter.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ import { type Api, type AssistantMessage, type AssistantMessageEvent, type Conte
|
|
|
30
30
|
import { openAICompletionsApi } from '@earendil-works/pi-ai/api/openai-completions.lazy';
|
|
31
31
|
import { type ChannelModality } from './presets.js';
|
|
32
32
|
import type { ResolvedChannel } from './channels.js';
|
|
33
|
-
import { SupplyStatus } from './failover.js';
|
|
33
|
+
import { SupplyStatus, type QuotaCooldown } from './failover.js';
|
|
34
34
|
import type { LedgerEntry } from './usage-ledger.js';
|
|
35
35
|
/** The single provider route this plugin owns. */
|
|
36
36
|
export declare const PROVIDER_ID = "any-deepseek";
|
|
@@ -137,6 +137,15 @@ export interface AdapterDeps {
|
|
|
137
137
|
members: readonly string[];
|
|
138
138
|
status: SupplyStatus;
|
|
139
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Which members are temporarily skipped, because they answered "out of credit" recently.
|
|
142
|
+
*
|
|
143
|
+
* ๐ด Owner decision 2026-11-19 (`QUOTA_COOLDOWN_MS`, 30 minutes). Without it every request paid
|
|
144
|
+
* two serial quota round-trips before reaching a healthy member. โ ๏ธ This is an ORDERING input
|
|
145
|
+
* only โ it moves members to the back of one request's walk and never removes one, and it expires
|
|
146
|
+
* on its own, so the configured priority is still what decides who serves.
|
|
147
|
+
*/
|
|
148
|
+
cooldown: QuotaCooldown;
|
|
140
149
|
/**
|
|
141
150
|
* Resolve a credential REFERENCE name to its value; undefined when unconfigured.
|
|
142
151
|
*
|
package/lib/client.js
CHANGED
|
@@ -54,7 +54,13 @@ window.__ModuleLoader__.load({
|
|
|
54
54
|
return channel === void 0 ? "ไพๅบ็ป" : `ไพๅบ็ป ยท ${channel.label}`;
|
|
55
55
|
}
|
|
56
56
|
const channel = response.channels.find((candidate) => candidate.id === id);
|
|
57
|
-
|
|
57
|
+
if (channel === void 0) return "ๆชๆพๅฐ";
|
|
58
|
+
if (response.supply?.viaFallback === true) {
|
|
59
|
+
const member = response.supply.serving;
|
|
60
|
+
const servingChannel = response.channels.find((candidate) => candidate.id === member);
|
|
61
|
+
return servingChannel === void 0 ? "ไพๅบ็ป๏ผ่ชๅจ๏ผ" : `ไพๅบ็ป๏ผ่ชๅจ๏ผยท ${servingChannel.label}`;
|
|
62
|
+
}
|
|
63
|
+
return channel.label;
|
|
58
64
|
}
|
|
59
65
|
/**
|
|
60
66
|
* Load per-channel balances.
|
|
@@ -365,7 +371,7 @@ window.__ModuleLoader__.load({
|
|
|
365
371
|
}
|
|
366
372
|
//#endregion
|
|
367
373
|
//#region \0ad-css:src/client/SettingsPage
|
|
368
|
-
const css$1 = "/* Panel styles.\n *\n * ๐ด There are NO `--dsw-alias-*` design tokens on this host (measured 2026-10-21: the document\n * declares 29 custom properties and not one is a colour). This file used to reference a dozen of\n * them, every one falling back to a hardcoded LIGHT value (`rgba(0,0,0,0.12)` and friends) โ so\n * on the dark theme the borders and dividers were effectively invisible.\n *\n * โ Derive everything from `currentColor`, which the host sets per theme. `color-mix` gives the\n * low-contrast borders and fills that a token would have provided, and it follows the theme\n * automatically instead of assuming one palette.\n */\n\n.ad-page {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 4px 2px 12px;\n}\n\n/* One place to change the two theme-derived values the whole panel uses. */\n.ad-page {\n --ad-line: color-mix(in srgb, currentColor 18%, transparent);\n --ad-line-strong: color-mix(in srgb, currentColor 32%, transparent);\n --ad-fill-subtle: color-mix(in srgb, currentColor 7%, transparent);\n /*\n * ๐ด The ACTIVE channel is green (owner request 2026-10-25: ใๆฟๆดป็ๆ ทๅผ็จ็ปฟ่ฒใ).\n *\n * It used to be derived from `currentColor`, which made the live row look like every other\n * \"slightly emphasised\" row โ the same neutral tint as a hover or a selected input. Green says\n * \"this one is ON\" in a way a grey tint cannot, and it matches the key-configured dot and the\n * ๅฏ้ฅๅทฒ้
็ฝฎ text that were already green, so the panel now uses one colour for one meaning:\n * green = working / live. Red stays reserved for destructive and for failures.\n *\n * Kept as one token so the mark (border + bar + fill + badge) can never drift apart between\n * the four places it is applied.\n */\n --ad-active: #2f855a;\n --ad-active-fill: color-mix(in srgb, var(--ad-active) 12%, transparent);\n --ad-danger: #e5534b;\n}\n\n.ad-head {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.ad-title {\n margin: 0;\n font-size: 15px;\n font-weight: 600;\n}\n\n.ad-intro {\n margin: 0;\n font-size: 12px;\n line-height: 1.6;\n opacity: 0.72;\n}\n\n.ad-error {\n border: 1px solid var(--ad-danger);\n border-radius: 6px;\n padding: 8px 10px;\n font-size: 12px;\n}\n\n.ad-section {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.ad-sectionTitle {\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n opacity: 0.6;\n}\n\n.ad-rows {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n/*\n * ๐ด Compact rows (owner request 2026-10-24: ใๆฏไธชๆธ ้้ซๅบฆๅธๆๅฐไธไบ๏ผ็ดงๅไบใ).\n *\n * The row used to be a four-line stack โ title / modelยทapiยทbaseURL / key line / balance โ and\n * with five channels that is most of the panel spent on air. The fix is layout, not information:\n * everything stays on screen, but the secondary facts move BESIDE the name instead of under it.\n *\n * What changed and why:\n * ยท padding 10pxโ7px and gap 6pxโ4px: the row now reads as one line of text plus a hairline of\n * metadata, instead of a card with its own interior spacing;\n * ยท `ad-rowMain` became a ROW (was a column): the title line and the meta line share one axis,\n * so the row is two text lines tall at most, not four;\n * ยท the meta line keeps `flex-wrap` โ on a narrow panel it may wrap, and that is the correct\n * trade: a row that stays readable beats one that clips the endpoint URL.\n */\n.ad-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n border: 1px solid var(--ad-line);\n border-radius: 8px;\n padding: 7px 10px;\n /*\n * The left edge is reserved on EVERY row so the current one does not shift its content when\n * selected โ a row that reindents on click makes the list feel like it moved.\n */\n border-left: 3px solid transparent;\n}\n\n/*\n * ๐ด The narrow-viewport layout: the action buttons get their own line.\n *\n * Measured on the owner's phone (2026-11-06 screenshot): 390px viewport, ~340px of content. Four\n * buttons at min-width 56px + 8px gaps need ~272px; together with a name column that cannot be\n * narrower than one word, they do not fit side by side. Below ~520px they now wrap below the\n * name instead of squeezing it into a vertical strip.\n *\n * Chosen as a media query rather than left to flex alone: without an explicit basis the group\n * wraps only when its CONTENT overflows, which leaves the name column at min-content width for a\n * long stretch before that happens โ the exact state the screenshot was taken in.\n */\n@media (max-width: 520px) {\n .ad-rowActions {\n flex-basis: 100%;\n }\n .ad-btn {\n flex: 1 1 auto;\n min-width: 0;\n }\n}\n\n/*\n * ๐ด The current channel is marked in GREEN (owner 2026-10-25: ใๆฟๆดป็ๆ ทๅผ็จ็ปฟ่ฒใ).\n *\n * Previously the marks were derived from `currentColor` โ a neutral bar, a stronger border and a\n * grey tint. All three were so low-contrast that the live row read as \"merely hovered\", which is\n * exactly what the owner was reacting to.\n *\n * Green is also the coherent choice: the key dot and ๅฏ้ฅๅทฒ้
็ฝฎ text were already green, so the\n * panel now uses ONE colour for ONE meaning (green = working / live), and red stays reserved for\n * destructive actions and failures.\n *\n * Four marks read from the same token so they cannot drift apart: left bar, border, fill, badge.\n */\n.ad-row-current {\n border-color: var(--ad-active);\n border-left-color: var(--ad-active);\n background: var(--ad-active-fill);\n}\n\n/* The ๅฝๅ badge is the textual confirmation, for when colour alone is not enough (colour-blind\n readers, screenshots, forced-colours mode). */\n.ad-row-current .ad-badge {\n border-color: var(--ad-active);\n color: var(--ad-active);\n opacity: 1;\n font-weight: 600;\n}\n\n/* The live row's NAME goes green too: the name is where the eye lands first, so marking only the\n border leaves the reader to connect two separate cues. */\n.ad-row-current .ad-rowTitle {\n color: var(--ad-active);\n}\n\n/*\n * The row's content is a COLUMN of at most two lines: (1) name + status, (2) everything else.\n * It was a four-line stack before the compactness pass โ see the note on `.ad-row`.\n */\n.ad-rowMain {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n flex: 1 1 auto;\n}\n\n.ad-rowTitleLine {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n font-weight: 500;\n min-width: 0;\n}\n\n.ad-rowTitle {\n white-space: nowrap;\n}\n\n.ad-badge {\n font-size: 10px;\n padding: 1px 6px;\n border-radius: 999px;\n border: 1px solid currentColor;\n opacity: 0.8;\n}\n\n.ad-warn {\n color: #b7791f;\n cursor: help;\n}\n\n/*\n * The live-state line under a channel's name: probe verdict and/or balance, nothing else.\n *\n * ๐ด It shrank twice at the owner's request, and the history matters:\n * 2026-10-24 ใ็ดงๅไบใ โ four stacked lines (endpoint identity / key state / verdict / balance)\n * became one wrapping line;\n * 2026-10-25 ใ่ฟ้จๅไธ่ฆไบใ โ endpoint identity and key state were removed outright. What\n * remains is only what changes at runtime: did the probe pass, what is\n * the balance. Those two cannot be derived from anything else on screen,\n * which is why they survived while model/api/baseURL did not.\n *\n * The element is rendered ONLY when one of them exists, so an unprobed, unpriced channel shows a\n * single-line row with no orphan gap.\n */\n.ad-rowDetail {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n column-gap: 6px;\n row-gap: 2px;\n font-size: 11px;\n opacity: 0.66;\n min-width: 0;\n}\n\n.ad-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n word-break: break-all;\n}\n\n.ad-sep {\n opacity: 0.5;\n}\n\n/*\n * ๐ด Every control that acts on a channel lives here โ and it MUST be allowed to shrink/wrap.\n *\n * This block is what made the panel unusable on a phone (owner 2026-11-06, screenshot from a\n * 390px-wide viewport). The row itself was already `flex-wrap: wrap`, so the actions SHOULD have\n * dropped to their own line; `flex-shrink: 0` here kept the group at its full intrinsic width\n * (~4 buttons โ 272px) inside a ~340px content box, and `.ad-rowMain` โ which then had only about\n * 60px left โ collapsed to its min-content width, printing `deepseek-v4.1-flash` and the balance\n * one fragment per line. Every control stayed on screen; none of them was readable.\n *\n * Three properties, each doing a different job:\n * ยท flex-basis 100% + the wrap rule below โ the group takes its own line on narrow screens;\n * ยท flex-wrap + no flex-shrink:0 โ it may wrap again rather than overflow if the width shrinks\n * further, and on a wide panel it stays on the title line exactly as before;\n * ยท it keeps `margin-left: auto` so that, once wrapped, the buttons stay right-aligned under the\n * row instead of drifting back under the name.\n */\n.ad-rowActions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n margin-left: auto;\n min-width: 0;\n}\n\n/*\n * โโ the supply group row (owner 2026-11-12) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n *\n * ๐ด The group is a MEMBER OF THE CHANNEL RADIO GROUP that happens to be a container, and the\n * styling has to say both things at once:\n *\n * ยท it must read as a CHOICE (the same radio, the same current-row marks) โ owner's requirement\n * was ใ็ป็จๆทไพๅบ็ปๆฏไธ็ง้ๆฉ็ๆ่งใ, and the browser's radio semantics then guarantee the\n * thing he actually asked for: selecting the group unselects every channel below it;\n * ยท it must also read as a CONTAINER, because its members are edited and ordered here.\n *\n * Hence: same border/background language as `.ad-row`, but stacked (the member editor sits under\n * the title line) and with a muted \"explainer\" line so an unused feature still explains itself.\n */\n.ad-groupRow {\n /* A container, not a one-line row: the picker stays on top, the editor stacks beneath it. */\n flex-wrap: wrap;\n align-items: flex-start;\n}\n\n/* The member editor spans the full width under the picker, so member rows never wrap awkwardly. */\n.ad-groupEditor {\n flex-basis: 100%;\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding-top: 6px;\n margin-top: 2px;\n border-top: 1px dashed var(--ad-line);\n}\n\n.ad-groupCount {\n font-size: 11px;\n opacity: 0.6;\n}\n\n/* The live reading and the last switch are state, not decoration โ they get the full-opacity\n treatment the balance row reserves for facts the reader cannot derive. */\n.ad-groupLive,\n.ad-groupSwitch {\n opacity: 1;\n font-size: 11px;\n}\n\n/* ๐ด ใๅ
จ็ปๅไธๅฏ็จใ must look like the failure it is, not like a status line. The balance table\n made the same distinction: a fact the reader must act on cannot share the muted styling of a\n fact they can ignore. */\n.ad-groupLiveBad {\n color: #c53030;\n}\n\n.ad-groupSwitch {\n color: #b7791f;\n}\n\n.ad-groupDangling {\n color: #c53030;\n opacity: 1;\n font-size: 11px;\n}\n\n.ad-groupMembers {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/*\n * One member line: rank ยท name ยท โ โ ็งปๅบ.\n *\n * `min-width: 0` + `flex: 1` on the name is the same lesson as `.ad-rowMain`: without it a long\n * label refuses to shrink and pushes the buttons out of the panel (decision 82).\n */\n.ad-groupMember {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 8px;\n border: 1px solid var(--ad-line);\n border-radius: 6px;\n border-left: 3px solid transparent;\n font-size: 12px;\n}\n\n/* The member currently serving gets the same green left bar as the live channel row, so \"which\n one is talking to the relay\" is one colour in one place. */\n.ad-groupMemberLive {\n border-left-color: var(--ad-active);\n}\n\n.ad-groupRank {\n flex: none;\n width: 18px;\n text-align: center;\n opacity: 0.55;\n font-variant-numeric: tabular-nums;\n}\n\n.ad-groupName {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ad-groupAdd {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-wrap: wrap;\n}\n\n/* The select shares the panel's input look; it must be allowed to shrink on a narrow screen. */\n.ad-groupAdd .ad-input {\n flex: 1 1 120px;\n min-width: 0;\n}\n\n/*\n * Buttons: sized to be hit, not guessed at.\n *\n * The previous 4px/10px padding made a 22px-tall target, which is below the comfortable\n * threshold and made the row actions (ๆต่ฏ / ็งป้ค) look like text rather than controls. 6px/12px\n * with a minimum width gives each one a real box while keeping the row compact โ a row action is\n * secondary, so it should be easy to hit and easy to ignore.\n */\n.ad-btn {\n font-size: 11px;\n font-family: inherit;\n line-height: 1.5;\n padding: 5px 12px;\n min-width: 56px;\n min-height: 26px;\n border-radius: 6px;\n border: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n cursor: pointer;\n transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;\n}\n\n.ad-btn:hover:not(:disabled) {\n border-color: var(--ad-line-strong);\n background: var(--ad-fill-subtle);\n}\n\n.ad-btn:disabled {\n opacity: 0.45;\n cursor: default;\n}\n\n.ad-btn-quiet {\n opacity: 0.85;\n}\n\n.ad-probe {\n font-size: 11px;\n padding-top: 2px;\n}\n\n.ad-probe-ok {\n color: #2f855a;\n}\n\n.ad-probe-bad {\n color: #c53030;\n word-break: break-word;\n}\n\n.ad-hint,\n.ad-empty,\n.ad-note {\n margin: 0;\n font-size: 11px;\n line-height: 1.6;\n opacity: 0.66;\n}\n\n.ad-dot {\n width: 8px;\n height: 8px;\n border-radius: 50%;\n flex-shrink: 0;\n display: inline-block;\n}\n\n.ad-dot-on {\n background: #2f855a;\n}\n\n.ad-dot-off {\n border: 1px solid currentColor;\n opacity: 0.5;\n}\n\n.ad-dot-unknown {\n background: linear-gradient(90deg, currentColor 50%, transparent 50%);\n opacity: 0.5;\n}\n\n/* The channel row is a radio \"pick\" zone: the whole left side is clickable, and the radio sits\n at the start of the line so \"which one is live\" is readable down a single column. */\n.ad-rowPick {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n flex: 1;\n min-width: 0;\n cursor: pointer;\n}\n\n.ad-rowPick input[type='radio'] {\n flex: none;\n /* Optically centred against the first text line rather than the row box. */\n margin-top: 3px;\n accent-color: var(--ad-line-strong);\n cursor: pointer;\n}\n\n/* The switch is gone: selection is the only axis (see `channels.ts`). Keeping the rules would\n invite someone to bring the second axis back. */\n\n/* โโ top-level tabs (ๆธ ้ / ็จ้) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n/*\n * The panel answers two questions asked at different moments: \"which relay serves me and does\n * its key work\" and \"what has each relay cost\". They used to be stacked on one scroll, so\n * reading the cost table meant scrolling past every channel row. As tabs, each answer gets the\n * whole panel and the reader never scrolls to reach the second one.\n *\n * The selected tab is marked by a bottom rule plus full opacity โ not by colour alone, because\n * this host ships no colour tokens and a colour-only cue would vary with the theme.\n */\n.ad-tabs {\n display: flex;\n gap: 4px;\n border-bottom: 1px solid var(--ad-line);\n}\n\n.ad-tab {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n /* Comfortable click target: 28px tall is enough to hit without aiming, and still compact\n enough that two tabs do not dominate the panel. */\n padding: 6px 14px;\n font-size: 12px;\n font-family: inherit;\n border: none;\n border-bottom: 2px solid transparent;\n /* Pulled down over the container's rule so the selected tab's underline replaces it. */\n margin-bottom: -1px;\n background: transparent;\n color: inherit;\n opacity: 0.62;\n cursor: pointer;\n}\n\n.ad-tab:hover {\n opacity: 0.85;\n}\n\n.ad-tab-on {\n opacity: 1;\n font-weight: 600;\n border-bottom-color: currentColor;\n}\n\n/* A count on the channel tab, so \"how many do I have\" is answered without opening it. */\n.ad-tabCount {\n font-size: 10px;\n font-weight: 500;\n min-width: 16px;\n padding: 0 4px;\n border-radius: 999px;\n text-align: center;\n background: var(--ad-fill-subtle);\n opacity: 0.8;\n}\n\n/* โโ segmented control (ๆๆธ ้ / ๆๅคฉ / ๅทๆฐ) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n/*\n * A segmented control rather than free-floating pill buttons: these three share one meaning\n * (\"how the table below is grouped, and re-read it\"), so they are drawn as one object. The\n * borders collapse to avoid double lines between neighbours.\n */\n.ad-segmented {\n display: inline-flex;\n align-items: stretch;\n border: 1px solid var(--ad-line);\n border-radius: 7px;\n overflow: hidden;\n}\n\n.ad-seg {\n padding: 4px 11px;\n font-size: 11px;\n font-family: inherit;\n border: none;\n border-right: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n opacity: 0.7;\n cursor: pointer;\n}\n\n.ad-seg:last-child {\n border-right: none;\n}\n\n.ad-seg:hover:not(:disabled) {\n opacity: 1;\n background: var(--ad-fill-subtle);\n}\n\n.ad-seg-on {\n opacity: 1;\n font-weight: 600;\n background: var(--ad-fill-subtle);\n}\n\n/* Refresh is an action, not a grouping โ a gap separates it from the choice it refreshes. */\n.ad-seg-refresh {\n border-left: 1px solid var(--ad-line);\n}\n\n.ad-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11px;\n}\n\n.ad-table th,\n.ad-table td {\n padding: 5px 8px;\n border-bottom: 1px solid var(--ad-line);\n text-align: left;\n}\n\n.ad-table th {\n font-weight: 500;\n opacity: 0.6;\n}\n\n.ad-num {\n text-align: right;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n\n.ad-total td {\n font-weight: 600;\n border-bottom: none;\n}\n\n/* โโ add-channel form โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n.ad-addForm {\n display: flex;\n flex-direction: column;\n gap: 14px;\n border: 1px dashed var(--ad-line);\n border-radius: 8px;\n padding: 14px;\n}\n\n.ad-field {\n display: flex;\n flex-direction: column;\n gap: 5px;\n font-size: 11px;\n}\n\n/* The label row: the field name, plus a required/optional marker that says which is which. */\n.ad-field > span:first-child {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n font-weight: 500;\n opacity: 0.9;\n}\n\n/*\n * ๅฟ
้ / ๅฏ็ฉบ as a small marker rather than a sentence.\n *\n * The add form used to leave the reader guessing which fields could be skipped โ and the one\n * field that could not be skipped (the key) looked exactly like the two that could. The marker\n * is text, not colour, so it survives both themes and any colour-blindness.\n */\n.ad-req,\n.ad-opt {\n font-style: normal;\n font-size: 10px;\n font-weight: 400;\n padding: 1px 5px;\n border-radius: 4px;\n opacity: 0.7;\n}\n\n.ad-req {\n border: 1px solid var(--ad-line-strong);\n}\n\n.ad-opt {\n border: 1px dotted var(--ad-line);\n}\n\n/* Why this field exists, in one line โ printed under the control, not hidden in a tooltip. */\n.ad-fieldHelp {\n font-size: 11px;\n line-height: 1.55;\n opacity: 0.6;\n}\n\n.ad-input {\n font-size: 12px;\n font-family: inherit;\n /* 6px/9px keeps the control the same height as a `.ad-btn` (26px), so a field and its button\n on one line align without a per-case override. */\n padding: 5px 9px;\n min-height: 26px;\n border-radius: 6px;\n border: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n}\n\n.ad-input:focus-visible {\n outline: 2px solid var(--ad-line-strong);\n outline-offset: 1px;\n border-color: var(--ad-line-strong);\n}\n\n/*\n * ๐ด A native `<select>` cannot be themed by leaving the background transparent.\n *\n * The popup list is drawn by the browser, not by the closed control's box: the options inherit\n * nothing from it, so `background: transparent` made them render in the platform default (light)\n * palette against this dark theme โ reported by the owner and measured on the real host.\n *\n * ๐ด SECOND correction (measured 2026-10-21): this file used `var(--dsw-alias-color-*, #fallback)`\n * throughout, and **none of those variables exist**. The host declares only 29 custom properties\n * in total and not one is a colour token, so every `var()` here was falling back โ and a fallback\n * that happens to be set inside a shorthand can be silently dropped (the select's background\n * computed to `rgba(0,0,0,0)`, i.e. still transparent, which is exactly the bug).\n *\n * โ Use only values this file controls, derived from `currentColor` (the host sets a light text\n * colour on both themes) plus explicit translucent layers. No host token is assumed.\n */\nselect.ad-input {\n /* Tells the engine which palette to use for the popup. This part DID work. */\n color-scheme: dark light;\n /*\n * Paint the closed box with a layer that follows the surrounding text colour, so it matches\n * whichever theme is active instead of hardcoding a dark value into a light theme.\n */\n background-color: color-mix(in srgb, currentColor 8%, transparent);\n color: inherit;\n cursor: pointer;\n padding-right: 22px;\n /* Room for the chevron drawn below, so text never runs under it. */\n appearance: none;\n background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),\n linear-gradient(135deg, currentColor 50%, transparent 50%);\n background-position: calc(100% - 12px) calc(50% + 1px), calc(100% - 8px) calc(50% + 1px);\n background-size: 4px 4px, 4px 4px;\n background-repeat: no-repeat;\n}\n\nselect.ad-input:hover:not(:disabled) {\n background-color: color-mix(in srgb, currentColor 14%, transparent);\n}\n\nselect.ad-input:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n\n/*\n * The popup itself follows `color-scheme`; these keep the option rows explicit for engines that\n * honour per-option colours. `color-scheme: dark` above is what actually stops the light-on-dark\n * list, because the popup is native chrome rather than a styled element.\n */\nselect.ad-input option {\n background-color: Canvas;\n color: CanvasText;\n}\n\n.ad-fieldError {\n margin: 0;\n font-size: 11px;\n color: #c53030;\n}\n\n/* โโ balance โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n/*\n * Remaining balance.\n *\n * A fact about this channel, not a control. The subtle fill marks it as a measurement rather than\n * a warning: the words themselves say whether it is fine (\"72.50 USD\") or not (\"๏ผไฝ้ขไธ่ถณ๏ผ\").\n */\n.ad-balance {\n font-variant-numeric: tabular-nums;\n font-size: 11px;\n padding: 1px 6px;\n border-radius: 4px;\n background: var(--ad-fill-subtle);\n}\n\n/* A section heading with one action on its right (currently: ๆฅ่ฏขไฝ้ข). */\n.ad-sectionBar {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px;\n}\n\n/* The reference name, not a secret: monospace so it lines up and misreads as a name, not a value. */\n.ad-keyName {\n font-size: 10px;\n padding: 1px 5px;\n border-radius: 4px;\n background: var(--ad-fill-subtle);\n opacity: 0.8;\n}\n\n/* A text-shaped action. Styled as a link because it opens an inline editor, not a dialog. */\n.ad-link {\n font-size: 11px;\n padding: 0;\n border: none;\n background: none;\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n opacity: 0.75;\n cursor: pointer;\n}\n\n.ad-link:hover {\n opacity: 1;\n}\n\n/* The inline key editor: one masked field and one button, on the same line as the fact above. */\n.ad-keyForm {\n display: flex;\n align-items: center;\n gap: 6px;\n padding-top: 4px;\n}\n\n.ad-keyForm .ad-input {\n flex: 1;\n min-width: 0;\n}\n\n/* A destructive action is quiet until hovered: it should be findable, not inviting. */\n.ad-btn-danger {\n opacity: 0.6;\n}\n\n.ad-btn-danger:hover:not(:disabled) {\n opacity: 1;\n border-color: var(--ad-danger);\n color: var(--ad-danger);\n}\n\n/*\n * The one hint that must not be skimmed past: where the key ends up.\n *\n * It carries a left rule and slightly higher opacity than an ordinary hint, because a reader who\n * skips it has been told something false by omission โ the key IS in the profile document.\n */\n.ad-hint-warn {\n padding: 8px 10px;\n border-left: 3px solid var(--ad-line-strong);\n background: var(--ad-fill-subtle);\n border-radius: 0 6px 6px 0;\n opacity: 0.82;\n}\n\n/*\n * The table can be wider than a narrow settings pane (ten columns of numbers). Scrolling it\n * inside its own box keeps the tab strip and the channel list reachable, instead of pushing the\n * whole panel sideways.\n */\n.ad-tableWrap {\n overflow-x: auto;\n /* A hint that there is more to the right, without a scrollbar competing with the borders. */\n scrollbar-width: thin;\n}\n\n.ad-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11px;\n}\n\n/* The first column is a name, not a number: keep it from being squeezed by the numeric columns. */\n.ad-table th:first-child,\n.ad-table td:first-child {\n white-space: nowrap;\n padding-right: 14px;\n}\n\n/* โโ footer โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n/*\n * States what this thing is (MIT, open, improvable) and where it lives. A user deciding whether\n * to fork it or add a relay should not have to search for the source.\n */\n.ad-foot {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: 8px;\n padding-top: 10px;\n border-top: 1px solid var(--ad-line);\n font-size: 11px;\n opacity: 0.6;\n}\n\n.ad-footLink {\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-size: 10px;\n}\n\n.ad-footLink:hover {\n opacity: 0.9;\n}\n";
|
|
374
|
+
const css$1 = "/* Panel styles.\n *\n * ๐ด There are NO `--dsw-alias-*` design tokens on this host (measured 2026-10-21: the document\n * declares 29 custom properties and not one is a colour). This file used to reference a dozen of\n * them, every one falling back to a hardcoded LIGHT value (`rgba(0,0,0,0.12)` and friends) โ so\n * on the dark theme the borders and dividers were effectively invisible.\n *\n * โ Derive everything from `currentColor`, which the host sets per theme. `color-mix` gives the\n * low-contrast borders and fills that a token would have provided, and it follows the theme\n * automatically instead of assuming one palette.\n */\n\n.ad-page {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 4px 2px 12px;\n}\n\n/* One place to change the two theme-derived values the whole panel uses. */\n.ad-page {\n --ad-line: color-mix(in srgb, currentColor 18%, transparent);\n --ad-line-strong: color-mix(in srgb, currentColor 32%, transparent);\n --ad-fill-subtle: color-mix(in srgb, currentColor 7%, transparent);\n /*\n * ๐ด The ACTIVE channel is green (owner request 2026-10-25: ใๆฟๆดป็ๆ ทๅผ็จ็ปฟ่ฒใ).\n *\n * It used to be derived from `currentColor`, which made the live row look like every other\n * \"slightly emphasised\" row โ the same neutral tint as a hover or a selected input. Green says\n * \"this one is ON\" in a way a grey tint cannot, and it matches the key-configured dot and the\n * ๅฏ้ฅๅทฒ้
็ฝฎ text that were already green, so the panel now uses one colour for one meaning:\n * green = working / live. Red stays reserved for destructive and for failures.\n *\n * Kept as one token so the mark (border + bar + fill + badge) can never drift apart between\n * the four places it is applied.\n */\n --ad-active: #2f855a;\n --ad-active-fill: color-mix(in srgb, var(--ad-active) 12%, transparent);\n --ad-danger: #e5534b;\n}\n\n.ad-head {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.ad-title {\n margin: 0;\n font-size: 15px;\n font-weight: 600;\n}\n\n.ad-intro {\n margin: 0;\n font-size: 12px;\n line-height: 1.6;\n opacity: 0.72;\n}\n\n.ad-error {\n border: 1px solid var(--ad-danger);\n border-radius: 6px;\n padding: 8px 10px;\n font-size: 12px;\n}\n\n.ad-section {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.ad-sectionTitle {\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n opacity: 0.6;\n}\n\n.ad-rows {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n/*\n * ๐ด Compact rows (owner request 2026-10-24: ใๆฏไธชๆธ ้้ซๅบฆๅธๆๅฐไธไบ๏ผ็ดงๅไบใ).\n *\n * The row used to be a four-line stack โ title / modelยทapiยทbaseURL / key line / balance โ and\n * with five channels that is most of the panel spent on air. The fix is layout, not information:\n * everything stays on screen, but the secondary facts move BESIDE the name instead of under it.\n *\n * What changed and why:\n * ยท padding 10pxโ7px and gap 6pxโ4px: the row now reads as one line of text plus a hairline of\n * metadata, instead of a card with its own interior spacing;\n * ยท `ad-rowMain` became a ROW (was a column): the title line and the meta line share one axis,\n * so the row is two text lines tall at most, not four;\n * ยท the meta line keeps `flex-wrap` โ on a narrow panel it may wrap, and that is the correct\n * trade: a row that stays readable beats one that clips the endpoint URL.\n */\n.ad-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n border: 1px solid var(--ad-line);\n border-radius: 8px;\n padding: 7px 10px;\n /*\n * The left edge is reserved on EVERY row so the current one does not shift its content when\n * selected โ a row that reindents on click makes the list feel like it moved.\n */\n border-left: 3px solid transparent;\n}\n\n/*\n * ๐ด The narrow-viewport layout: the action buttons get their own line.\n *\n * Measured on the owner's phone (2026-11-06 screenshot): 390px viewport, ~340px of content. Four\n * buttons at min-width 56px + 8px gaps need ~272px; together with a name column that cannot be\n * narrower than one word, they do not fit side by side. Below ~520px they now wrap below the\n * name instead of squeezing it into a vertical strip.\n *\n * Chosen as a media query rather than left to flex alone: without an explicit basis the group\n * wraps only when its CONTENT overflows, which leaves the name column at min-content width for a\n * long stretch before that happens โ the exact state the screenshot was taken in.\n */\n@media (max-width: 520px) {\n .ad-rowActions {\n flex-basis: 100%;\n }\n .ad-btn {\n flex: 1 1 auto;\n min-width: 0;\n }\n}\n\n/*\n * ๐ด The current channel is marked in GREEN (owner 2026-10-25: ใๆฟๆดป็ๆ ทๅผ็จ็ปฟ่ฒใ).\n *\n * Previously the marks were derived from `currentColor` โ a neutral bar, a stronger border and a\n * grey tint. All three were so low-contrast that the live row read as \"merely hovered\", which is\n * exactly what the owner was reacting to.\n *\n * Green is also the coherent choice: the key dot and ๅฏ้ฅๅทฒ้
็ฝฎ text were already green, so the\n * panel now uses ONE colour for ONE meaning (green = working / live), and red stays reserved for\n * destructive actions and failures.\n *\n * Four marks read from the same token so they cannot drift apart: left bar, border, fill, badge.\n */\n.ad-row-current {\n border-color: var(--ad-active);\n border-left-color: var(--ad-active);\n background: var(--ad-active-fill);\n}\n\n/* The ๅฝๅ badge is the textual confirmation, for when colour alone is not enough (colour-blind\n readers, screenshots, forced-colours mode). */\n.ad-row-current .ad-badge {\n border-color: var(--ad-active);\n color: var(--ad-active);\n opacity: 1;\n font-weight: 600;\n}\n\n/* The live row's NAME goes green too: the name is where the eye lands first, so marking only the\n border leaves the reader to connect two separate cues. */\n.ad-row-current .ad-rowTitle {\n color: var(--ad-active);\n}\n\n/*\n * The row's content is a COLUMN of at most two lines: (1) name + status, (2) everything else.\n * It was a four-line stack before the compactness pass โ see the note on `.ad-row`.\n */\n.ad-rowMain {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n flex: 1 1 auto;\n}\n\n.ad-rowTitleLine {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n font-weight: 500;\n min-width: 0;\n}\n\n.ad-rowTitle {\n white-space: nowrap;\n}\n\n.ad-badge {\n font-size: 10px;\n padding: 1px 6px;\n border-radius: 999px;\n border: 1px solid currentColor;\n opacity: 0.8;\n}\n\n.ad-warn {\n color: #b7791f;\n cursor: help;\n}\n\n/*\n * The live-state line under a channel's name: probe verdict and/or balance, nothing else.\n *\n * ๐ด It shrank twice at the owner's request, and the history matters:\n * 2026-10-24 ใ็ดงๅไบใ โ four stacked lines (endpoint identity / key state / verdict / balance)\n * became one wrapping line;\n * 2026-10-25 ใ่ฟ้จๅไธ่ฆไบใ โ endpoint identity and key state were removed outright. What\n * remains is only what changes at runtime: did the probe pass, what is\n * the balance. Those two cannot be derived from anything else on screen,\n * which is why they survived while model/api/baseURL did not.\n *\n * The element is rendered ONLY when one of them exists, so an unprobed, unpriced channel shows a\n * single-line row with no orphan gap.\n */\n.ad-rowDetail {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n column-gap: 6px;\n row-gap: 2px;\n font-size: 11px;\n opacity: 0.66;\n min-width: 0;\n}\n\n.ad-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n word-break: break-all;\n}\n\n.ad-sep {\n opacity: 0.5;\n}\n\n/*\n * ๐ด Every control that acts on a channel lives here โ and it MUST be allowed to shrink/wrap.\n *\n * This block is what made the panel unusable on a phone (owner 2026-11-06, screenshot from a\n * 390px-wide viewport). The row itself was already `flex-wrap: wrap`, so the actions SHOULD have\n * dropped to their own line; `flex-shrink: 0` here kept the group at its full intrinsic width\n * (~4 buttons โ 272px) inside a ~340px content box, and `.ad-rowMain` โ which then had only about\n * 60px left โ collapsed to its min-content width, printing `deepseek-v4.1-flash` and the balance\n * one fragment per line. Every control stayed on screen; none of them was readable.\n *\n * Three properties, each doing a different job:\n * ยท flex-basis 100% + the wrap rule below โ the group takes its own line on narrow screens;\n * ยท flex-wrap + no flex-shrink:0 โ it may wrap again rather than overflow if the width shrinks\n * further, and on a wide panel it stays on the title line exactly as before;\n * ยท it keeps `margin-left: auto` so that, once wrapped, the buttons stay right-aligned under the\n * row instead of drifting back under the name.\n */\n.ad-rowActions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n margin-left: auto;\n min-width: 0;\n}\n\n/*\n * โโ the supply group row (owner 2026-11-12) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n *\n * ๐ด The group is a MEMBER OF THE CHANNEL RADIO GROUP that happens to be a container, and the\n * styling has to say both things at once:\n *\n * ยท it must read as a CHOICE (the same radio, the same current-row marks) โ owner's requirement\n * was ใ็ป็จๆทไพๅบ็ปๆฏไธ็ง้ๆฉ็ๆ่งใ, and the browser's radio semantics then guarantee the\n * thing he actually asked for: selecting the group unselects every channel below it;\n * ยท it must also read as a CONTAINER, because its members are edited and ordered here.\n *\n * Hence: same border/background language as `.ad-row`, but stacked (the member editor sits under\n * the title line) and with a muted \"explainer\" line so an unused feature still explains itself.\n */\n.ad-groupRow {\n /* A container, not a one-line row: the picker stays on top, the editor stacks beneath it. */\n flex-wrap: wrap;\n align-items: flex-start;\n}\n\n/* The member editor spans the full width under the picker, so member rows never wrap awkwardly. */\n.ad-groupEditor {\n flex-basis: 100%;\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding-top: 6px;\n margin-top: 2px;\n border-top: 1px dashed var(--ad-line);\n}\n\n.ad-groupCount {\n font-size: 11px;\n opacity: 0.6;\n}\n\n/* The live reading and the last switch are state, not decoration โ they get the full-opacity\n treatment the balance row reserves for facts the reader cannot derive. */\n.ad-groupLive,\n.ad-groupSwitch {\n opacity: 1;\n font-size: 11px;\n}\n\n/* ๐ด ใๅ
จ็ปๅไธๅฏ็จใ must look like the failure it is, not like a status line. The balance table\n made the same distinction: a fact the reader must act on cannot share the muted styling of a\n fact they can ignore. */\n.ad-groupLiveBad {\n color: #c53030;\n}\n\n.ad-groupSwitch {\n color: #b7791f;\n}\n\n.ad-groupDangling {\n color: #c53030;\n opacity: 1;\n font-size: 11px;\n}\n\n.ad-groupMembers {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/*\n * One member line: rank ยท name ยท โ โ ็งปๅบ.\n *\n * `min-width: 0` + `flex: 1` on the name is the same lesson as `.ad-rowMain`: without it a long\n * label refuses to shrink and pushes the buttons out of the panel (decision 82).\n */\n.ad-groupMember {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 8px;\n border: 1px solid var(--ad-line);\n border-radius: 6px;\n border-left: 3px solid transparent;\n font-size: 12px;\n}\n\n/* The member currently serving gets the same green left bar as the live channel row, so \"which\n one is talking to the relay\" is one colour in one place. */\n.ad-groupMemberLive {\n border-left-color: var(--ad-active);\n}\n\n/* A member the router is currently passing over because it answered \"out of credit\"\n (owner 2026-11-19, 30-minute window). Dimmed, NOT hidden and NOT reordered: the rank number\n must keep saying \"this is your priority 1\" while the badge says \"not being tried right now\". */\n.ad-groupMemberCooling {\n opacity: 0.6;\n}\n\n.ad-groupCoolTag {\n flex: none;\n font-size: 10px;\n padding: 1px 5px;\n border-radius: 999px;\n border: 1px solid var(--ad-line);\n color: #b7791f;\n white-space: nowrap;\n}\n\n.ad-groupRank {\n flex: none;\n width: 18px;\n text-align: center;\n opacity: 0.55;\n font-variant-numeric: tabular-nums;\n}\n\n.ad-groupName {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ad-groupAdd {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-wrap: wrap;\n}\n\n/* The select shares the panel's input look; it must be allowed to shrink on a narrow screen. */\n.ad-groupAdd .ad-input {\n flex: 1 1 120px;\n min-width: 0;\n}\n\n/*\n * Buttons: sized to be hit, not guessed at.\n *\n * The previous 4px/10px padding made a 22px-tall target, which is below the comfortable\n * threshold and made the row actions (ๆต่ฏ / ็งป้ค) look like text rather than controls. 6px/12px\n * with a minimum width gives each one a real box while keeping the row compact โ a row action is\n * secondary, so it should be easy to hit and easy to ignore.\n */\n.ad-btn {\n font-size: 11px;\n font-family: inherit;\n line-height: 1.5;\n padding: 5px 12px;\n min-width: 56px;\n min-height: 26px;\n border-radius: 6px;\n border: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n cursor: pointer;\n transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;\n}\n\n.ad-btn:hover:not(:disabled) {\n border-color: var(--ad-line-strong);\n background: var(--ad-fill-subtle);\n}\n\n.ad-btn:disabled {\n opacity: 0.45;\n cursor: default;\n}\n\n.ad-btn-quiet {\n opacity: 0.85;\n}\n\n.ad-probe {\n font-size: 11px;\n padding-top: 2px;\n}\n\n.ad-probe-ok {\n color: #2f855a;\n}\n\n.ad-probe-bad {\n color: #c53030;\n word-break: break-word;\n}\n\n.ad-hint,\n.ad-empty,\n.ad-note {\n margin: 0;\n font-size: 11px;\n line-height: 1.6;\n opacity: 0.66;\n}\n\n.ad-dot {\n width: 8px;\n height: 8px;\n border-radius: 50%;\n flex-shrink: 0;\n display: inline-block;\n}\n\n.ad-dot-on {\n background: #2f855a;\n}\n\n.ad-dot-off {\n border: 1px solid currentColor;\n opacity: 0.5;\n}\n\n.ad-dot-unknown {\n background: linear-gradient(90deg, currentColor 50%, transparent 50%);\n opacity: 0.5;\n}\n\n/* The channel row is a radio \"pick\" zone: the whole left side is clickable, and the radio sits\n at the start of the line so \"which one is live\" is readable down a single column. */\n.ad-rowPick {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n flex: 1;\n min-width: 0;\n cursor: pointer;\n}\n\n.ad-rowPick input[type='radio'] {\n flex: none;\n /* Optically centred against the first text line rather than the row box. */\n margin-top: 3px;\n accent-color: var(--ad-line-strong);\n cursor: pointer;\n}\n\n/* The switch is gone: selection is the only axis (see `channels.ts`). Keeping the rules would\n invite someone to bring the second axis back. */\n\n/* โโ top-level tabs (ๆธ ้ / ็จ้) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n/*\n * The panel answers two questions asked at different moments: \"which relay serves me and does\n * its key work\" and \"what has each relay cost\". They used to be stacked on one scroll, so\n * reading the cost table meant scrolling past every channel row. As tabs, each answer gets the\n * whole panel and the reader never scrolls to reach the second one.\n *\n * The selected tab is marked by a bottom rule plus full opacity โ not by colour alone, because\n * this host ships no colour tokens and a colour-only cue would vary with the theme.\n */\n.ad-tabs {\n display: flex;\n gap: 4px;\n border-bottom: 1px solid var(--ad-line);\n}\n\n.ad-tab {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n /* Comfortable click target: 28px tall is enough to hit without aiming, and still compact\n enough that two tabs do not dominate the panel. */\n padding: 6px 14px;\n font-size: 12px;\n font-family: inherit;\n border: none;\n border-bottom: 2px solid transparent;\n /* Pulled down over the container's rule so the selected tab's underline replaces it. */\n margin-bottom: -1px;\n background: transparent;\n color: inherit;\n opacity: 0.62;\n cursor: pointer;\n}\n\n.ad-tab:hover {\n opacity: 0.85;\n}\n\n.ad-tab-on {\n opacity: 1;\n font-weight: 600;\n border-bottom-color: currentColor;\n}\n\n/* A count on the channel tab, so \"how many do I have\" is answered without opening it. */\n.ad-tabCount {\n font-size: 10px;\n font-weight: 500;\n min-width: 16px;\n padding: 0 4px;\n border-radius: 999px;\n text-align: center;\n background: var(--ad-fill-subtle);\n opacity: 0.8;\n}\n\n/* โโ segmented control (ๆๆธ ้ / ๆๅคฉ / ๅทๆฐ) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n/*\n * A segmented control rather than free-floating pill buttons: these three share one meaning\n * (\"how the table below is grouped, and re-read it\"), so they are drawn as one object. The\n * borders collapse to avoid double lines between neighbours.\n */\n.ad-segmented {\n display: inline-flex;\n align-items: stretch;\n border: 1px solid var(--ad-line);\n border-radius: 7px;\n overflow: hidden;\n}\n\n.ad-seg {\n padding: 4px 11px;\n font-size: 11px;\n font-family: inherit;\n border: none;\n border-right: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n opacity: 0.7;\n cursor: pointer;\n}\n\n.ad-seg:last-child {\n border-right: none;\n}\n\n.ad-seg:hover:not(:disabled) {\n opacity: 1;\n background: var(--ad-fill-subtle);\n}\n\n.ad-seg-on {\n opacity: 1;\n font-weight: 600;\n background: var(--ad-fill-subtle);\n}\n\n/* Refresh is an action, not a grouping โ a gap separates it from the choice it refreshes. */\n.ad-seg-refresh {\n border-left: 1px solid var(--ad-line);\n}\n\n.ad-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11px;\n}\n\n.ad-table th,\n.ad-table td {\n padding: 5px 8px;\n border-bottom: 1px solid var(--ad-line);\n text-align: left;\n}\n\n.ad-table th {\n font-weight: 500;\n opacity: 0.6;\n}\n\n.ad-num {\n text-align: right;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n\n.ad-total td {\n font-weight: 600;\n border-bottom: none;\n}\n\n/* โโ add-channel form โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n.ad-addForm {\n display: flex;\n flex-direction: column;\n gap: 14px;\n border: 1px dashed var(--ad-line);\n border-radius: 8px;\n padding: 14px;\n}\n\n.ad-field {\n display: flex;\n flex-direction: column;\n gap: 5px;\n font-size: 11px;\n}\n\n/* The label row: the field name, plus a required/optional marker that says which is which. */\n.ad-field > span:first-child {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n font-weight: 500;\n opacity: 0.9;\n}\n\n/*\n * ๅฟ
้ / ๅฏ็ฉบ as a small marker rather than a sentence.\n *\n * The add form used to leave the reader guessing which fields could be skipped โ and the one\n * field that could not be skipped (the key) looked exactly like the two that could. The marker\n * is text, not colour, so it survives both themes and any colour-blindness.\n */\n.ad-req,\n.ad-opt {\n font-style: normal;\n font-size: 10px;\n font-weight: 400;\n padding: 1px 5px;\n border-radius: 4px;\n opacity: 0.7;\n}\n\n.ad-req {\n border: 1px solid var(--ad-line-strong);\n}\n\n.ad-opt {\n border: 1px dotted var(--ad-line);\n}\n\n/* Why this field exists, in one line โ printed under the control, not hidden in a tooltip. */\n.ad-fieldHelp {\n font-size: 11px;\n line-height: 1.55;\n opacity: 0.6;\n}\n\n.ad-input {\n font-size: 12px;\n font-family: inherit;\n /* 6px/9px keeps the control the same height as a `.ad-btn` (26px), so a field and its button\n on one line align without a per-case override. */\n padding: 5px 9px;\n min-height: 26px;\n border-radius: 6px;\n border: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n}\n\n.ad-input:focus-visible {\n outline: 2px solid var(--ad-line-strong);\n outline-offset: 1px;\n border-color: var(--ad-line-strong);\n}\n\n/*\n * ๐ด A native `<select>` cannot be themed by leaving the background transparent.\n *\n * The popup list is drawn by the browser, not by the closed control's box: the options inherit\n * nothing from it, so `background: transparent` made them render in the platform default (light)\n * palette against this dark theme โ reported by the owner and measured on the real host.\n *\n * ๐ด SECOND correction (measured 2026-10-21): this file used `var(--dsw-alias-color-*, #fallback)`\n * throughout, and **none of those variables exist**. The host declares only 29 custom properties\n * in total and not one is a colour token, so every `var()` here was falling back โ and a fallback\n * that happens to be set inside a shorthand can be silently dropped (the select's background\n * computed to `rgba(0,0,0,0)`, i.e. still transparent, which is exactly the bug).\n *\n * โ Use only values this file controls, derived from `currentColor` (the host sets a light text\n * colour on both themes) plus explicit translucent layers. No host token is assumed.\n */\nselect.ad-input {\n /* Tells the engine which palette to use for the popup. This part DID work. */\n color-scheme: dark light;\n /*\n * Paint the closed box with a layer that follows the surrounding text colour, so it matches\n * whichever theme is active instead of hardcoding a dark value into a light theme.\n */\n background-color: color-mix(in srgb, currentColor 8%, transparent);\n color: inherit;\n cursor: pointer;\n padding-right: 22px;\n /* Room for the chevron drawn below, so text never runs under it. */\n appearance: none;\n background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),\n linear-gradient(135deg, currentColor 50%, transparent 50%);\n background-position: calc(100% - 12px) calc(50% + 1px), calc(100% - 8px) calc(50% + 1px);\n background-size: 4px 4px, 4px 4px;\n background-repeat: no-repeat;\n}\n\nselect.ad-input:hover:not(:disabled) {\n background-color: color-mix(in srgb, currentColor 14%, transparent);\n}\n\nselect.ad-input:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n\n/*\n * The popup itself follows `color-scheme`; these keep the option rows explicit for engines that\n * honour per-option colours. `color-scheme: dark` above is what actually stops the light-on-dark\n * list, because the popup is native chrome rather than a styled element.\n */\nselect.ad-input option {\n background-color: Canvas;\n color: CanvasText;\n}\n\n.ad-fieldError {\n margin: 0;\n font-size: 11px;\n color: #c53030;\n}\n\n/* โโ balance โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n/*\n * Remaining balance.\n *\n * A fact about this channel, not a control. The subtle fill marks it as a measurement rather than\n * a warning: the words themselves say whether it is fine (\"72.50 USD\") or not (\"๏ผไฝ้ขไธ่ถณ๏ผ\").\n */\n.ad-balance {\n font-variant-numeric: tabular-nums;\n font-size: 11px;\n padding: 1px 6px;\n border-radius: 4px;\n background: var(--ad-fill-subtle);\n}\n\n/* A section heading with one action on its right (currently: ๆฅ่ฏขไฝ้ข). */\n.ad-sectionBar {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px;\n}\n\n/* The reference name, not a secret: monospace so it lines up and misreads as a name, not a value. */\n.ad-keyName {\n font-size: 10px;\n padding: 1px 5px;\n border-radius: 4px;\n background: var(--ad-fill-subtle);\n opacity: 0.8;\n}\n\n/* A text-shaped action. Styled as a link because it opens an inline editor, not a dialog. */\n.ad-link {\n font-size: 11px;\n padding: 0;\n border: none;\n background: none;\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n opacity: 0.75;\n cursor: pointer;\n}\n\n.ad-link:hover {\n opacity: 1;\n}\n\n/* The inline key editor: one masked field and one button, on the same line as the fact above. */\n.ad-keyForm {\n display: flex;\n align-items: center;\n gap: 6px;\n padding-top: 4px;\n}\n\n.ad-keyForm .ad-input {\n flex: 1;\n min-width: 0;\n}\n\n/* A destructive action is quiet until hovered: it should be findable, not inviting. */\n.ad-btn-danger {\n opacity: 0.6;\n}\n\n.ad-btn-danger:hover:not(:disabled) {\n opacity: 1;\n border-color: var(--ad-danger);\n color: var(--ad-danger);\n}\n\n/*\n * The one hint that must not be skimmed past: where the key ends up.\n *\n * It carries a left rule and slightly higher opacity than an ordinary hint, because a reader who\n * skips it has been told something false by omission โ the key IS in the profile document.\n */\n.ad-hint-warn {\n padding: 8px 10px;\n border-left: 3px solid var(--ad-line-strong);\n background: var(--ad-fill-subtle);\n border-radius: 0 6px 6px 0;\n opacity: 0.82;\n}\n\n/*\n * The table can be wider than a narrow settings pane (ten columns of numbers). Scrolling it\n * inside its own box keeps the tab strip and the channel list reachable, instead of pushing the\n * whole panel sideways.\n */\n.ad-tableWrap {\n overflow-x: auto;\n /* A hint that there is more to the right, without a scrollbar competing with the borders. */\n scrollbar-width: thin;\n}\n\n.ad-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11px;\n}\n\n/* The first column is a name, not a number: keep it from being squeezed by the numeric columns. */\n.ad-table th:first-child,\n.ad-table td:first-child {\n white-space: nowrap;\n padding-right: 14px;\n}\n\n/* โโ footer โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */\n\n/*\n * States what this thing is (MIT, open, improvable) and where it lives. A user deciding whether\n * to fork it or add a relay should not have to search for the source.\n */\n.ad-foot {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: 8px;\n padding-top: 10px;\n border-top: 1px solid var(--ad-line);\n font-size: 11px;\n opacity: 0.6;\n}\n\n.ad-footLink {\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-size: 10px;\n}\n\n.ad-footLink:hover {\n opacity: 0.9;\n}\n";
|
|
369
375
|
if (typeof document !== "undefined" && document.querySelector("style[data-ad-css=\"SettingsPage\"]") === null) {
|
|
370
376
|
const tag = document.createElement("style");
|
|
371
377
|
tag.setAttribute("data-ad-css", "SettingsPage");
|
|
@@ -868,6 +874,14 @@ window.__ModuleLoader__.load({
|
|
|
868
874
|
" ไฝ๏ผ"
|
|
869
875
|
]
|
|
870
876
|
}),
|
|
877
|
+
!groupSelected && supply?.viaFallback === true && supply.serving !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
878
|
+
className: "ad-rowDetail ad-groupLive ad-groupSwitch",
|
|
879
|
+
children: [
|
|
880
|
+
"่ชๅจๆฅ็ฎกไธญ๏ผ",
|
|
881
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: rows.find((row) => row.id === supply.serving)?.label ?? supply.serving }),
|
|
882
|
+
"๏ผไฝ ้็ๆธ ้ๆฒกไฝ้ขไบ๏ผๅ
ๅผๅไผ่ชๅจๅๅฐๅฎ๏ผ"
|
|
883
|
+
]
|
|
884
|
+
}),
|
|
871
885
|
groupSelected && supply?.lastSwitch !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
872
886
|
className: "ad-rowDetail ad-groupSwitch",
|
|
873
887
|
children: [
|
|
@@ -880,6 +894,10 @@ window.__ModuleLoader__.load({
|
|
|
880
894
|
"๏ผ"
|
|
881
895
|
]
|
|
882
896
|
}),
|
|
897
|
+
supply !== void 0 && supply.cooling !== void 0 && supply.cooling.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
898
|
+
className: "ad-rowDetail ad-groupSwitch",
|
|
899
|
+
children: ["ๆๆถ่ทณ่ฟ๏ผ", supply.cooling.map((entry) => `${rows.find((row) => row.id === entry.id)?.label ?? entry.id}๏ผ${Math.ceil(entry.retryInMs / 6e4)} ๅ้ๅ้่ฏ๏ผ`).join("ใ")]
|
|
900
|
+
}),
|
|
883
901
|
supply !== void 0 && supply.dangling.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
884
902
|
className: "ad-rowDetail ad-groupDangling",
|
|
885
903
|
children: [
|
|
@@ -902,8 +920,17 @@ window.__ModuleLoader__.load({
|
|
|
902
920
|
children: members.map((id, index) => {
|
|
903
921
|
const row = rows.find((candidate) => candidate.id === id);
|
|
904
922
|
const live = groupSelected && supply?.serving === id;
|
|
923
|
+
/**
|
|
924
|
+
* Whether this member is currently being SKIPPED.
|
|
925
|
+
*
|
|
926
|
+
* ๐ด Marks the row so the rank number and the actual trial order cannot silently
|
|
927
|
+
* disagree: member 1 with a skip badge reads as "priority 1, not being tried
|
|
928
|
+
* right now", which is the truth; without the badge the list would claim an order
|
|
929
|
+
* the router is not using.
|
|
930
|
+
*/
|
|
931
|
+
const cooling = supply?.cooling?.some((entry) => entry.id === id) === true;
|
|
905
932
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
906
|
-
className: `ad-groupMember${live ? " ad-groupMemberLive" : ""}`,
|
|
933
|
+
className: `ad-groupMember${live ? " ad-groupMemberLive" : ""}${cooling ? " ad-groupMemberCooling" : ""}`,
|
|
907
934
|
children: [
|
|
908
935
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
909
936
|
className: "ad-groupRank",
|
|
@@ -913,6 +940,11 @@ window.__ModuleLoader__.load({
|
|
|
913
940
|
className: "ad-groupName",
|
|
914
941
|
children: row?.label ?? `${id}๏ผๆพไธๅฐ๏ผ`
|
|
915
942
|
}),
|
|
943
|
+
cooling && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
944
|
+
className: "ad-groupCoolTag",
|
|
945
|
+
title: "ๅๆฅ่ฟใไฝ้ขไธ่ถณใ๏ผๆๆถๆๅฐๆๅ๏ผๅฐ็น่ชๅจๆขๅคๅๆฅ็ไฝ็ฝฎ",
|
|
946
|
+
children: "่ทณ่ฟไธญ"
|
|
947
|
+
}),
|
|
916
948
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
917
949
|
type: "button",
|
|
918
950
|
className: "ad-btn ad-btn-quiet",
|
|
@@ -1792,7 +1824,7 @@ window.__ModuleLoader__.load({
|
|
|
1792
1824
|
]
|
|
1793
1825
|
}), provider === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1794
1826
|
className: "ad-usageRow ad-providerRow",
|
|
1795
|
-
title: "ๅฝๅไพๅบๅ๏ผ่ฏทๆฑๆญฃๅจ่ตฐ็้ฃไธชๆธ ้๏ผใๆๅค 15 ็งๅปถ่ฟ๏ผๅๆขๆธ ้ๅๅๅฐๆฌ็ชๅฃไผ็ซๅป้่ฏปใ",
|
|
1827
|
+
title: channels?.supply?.viaFallback === true && channels.current !== "__group__" ? "ๅฝๅไพๅบๅ๏ผไฝ ้็ๆธ ้ๆฒกๆไฝ้ขไบ๏ผ่ฏทๆฑๅทฒ่ชๅจๆน็ฑไพๅบ็ปๆฟๆ
ใๆ้ฃไธชๆธ ้ๅ
ๅผๅๅฎไผ็ซๅปๅๅฐไฝฟ็จ๏ผไธ็จไปปไฝๆไฝ๏ผใ" : "ๅฝๅไพๅบๅ๏ผ่ฏทๆฑๆญฃๅจ่ตฐ็้ฃไธชๆธ ้๏ผใๆๅค 15 ็งๅปถ่ฟ๏ผๅๆขๆธ ้ๅๅๅฐๆฌ็ชๅฃไผ็ซๅป้่ฏปใ",
|
|
1796
1828
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1797
1829
|
className: "ad-usageDot ad-providerDot",
|
|
1798
1830
|
"aria-hidden": "true"
|
package/lib/failover.d.ts
CHANGED
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
* happened, not inputs to what happens next. They live in {@link SupplyStatus}, which the routing
|
|
29
29
|
* path writes and never reads.
|
|
30
30
|
*/
|
|
31
|
+
/** The channel shape this module orders; a structural view so no import cycle is needed. */
|
|
32
|
+
interface OrderableChannel {
|
|
33
|
+
id: string;
|
|
34
|
+
}
|
|
31
35
|
/**
|
|
32
36
|
* Whether a failed attempt justifies moving to the next group member.
|
|
33
37
|
*
|
|
@@ -38,6 +42,124 @@
|
|
|
38
42
|
* @returns true when the channel itself is unusable for this request.
|
|
39
43
|
*/
|
|
40
44
|
export declare function shouldFailover(code: string | undefined): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* How long a member that answered "out of credit" is SKIPPED for.
|
|
47
|
+
*
|
|
48
|
+
* ๐ด Owner decision 2026-11-19, after measuring the cost of the pure priority order: two dead
|
|
49
|
+
* members in front of a healthy one made every request pay two serial HTTP round-trips (measured
|
|
50
|
+
* 253โ964 ms each) before the real attempt, i.e. โ0.55 s of pure overhead per request on a 4.6 s
|
|
51
|
+
* first token. Owner chose this design over "just move them out of the group" because that one
|
|
52
|
+
* needs a human to reorder whenever a relay runs dry or is topped up.
|
|
53
|
+
*
|
|
54
|
+
* **Owner set the window: ๅๅฐๆถ.** The number is a trade with two sides, and both are stated
|
|
55
|
+
* rather than hidden:
|
|
56
|
+
* ยท too short โ the wasted round-trip comes back sooner, and a relay that is still dry gets
|
|
57
|
+
* re-probed more often than it can possibly recover;
|
|
58
|
+
* ยท too long โ a top-up takes up to this long to be noticed.
|
|
59
|
+
* 30 minutes is what the owner picked after seeing the measurement.
|
|
60
|
+
*/
|
|
61
|
+
export declare const QUOTA_COOLDOWN_MS: number;
|
|
62
|
+
/**
|
|
63
|
+
* Per-member, time-bounded skipping of members that just answered "out of credit".
|
|
64
|
+
*
|
|
65
|
+
* ## Why this is NOT the sticky cursor that was rejected
|
|
66
|
+
*
|
|
67
|
+
* The vetoed design (2026-11-12) was a POSITION: one index, advanced on failure, never expiring,
|
|
68
|
+
* invisible, and it silently outranked the configured order forever. Recovering from it needed a
|
|
69
|
+
* manual reset button.
|
|
70
|
+
*
|
|
71
|
+
* This is the opposite on every axis:
|
|
72
|
+
* ยท **keyed by member, not by position** โ reordering the list changes nothing about who is skipped;
|
|
73
|
+
* ยท **bounded** โ {@link QUOTA_COOLDOWN_MS}, then the member is tried again automatically;
|
|
74
|
+
* ยท **triggered by ONE cause** โ `QUOTA`/`ACCOUNT_QUOTA` only, so a dead key or a timeout never
|
|
75
|
+
* hides a channel;
|
|
76
|
+
* ยท **VISIBLE** โ `/channels` reports the skipped ids with their remaining time, and the panel
|
|
77
|
+
* shows them.
|
|
78
|
+
*
|
|
79
|
+
* And the property the owner cared about is preserved: **the order that remains IS the configured
|
|
80
|
+
* order**. Skipping is not reordering; when a member comes back it comes back at its own rank.
|
|
81
|
+
*
|
|
82
|
+
* โ ๏ธ In-memory and process-scoped on purpose: a host restart re-probes everything, which is the
|
|
83
|
+
* honest behaviour when the only thing known about a relay is 30 minutes old.
|
|
84
|
+
*/
|
|
85
|
+
export declare class QuotaCooldown {
|
|
86
|
+
/** member id โ the instant its cooldown ends (epoch ms). */
|
|
87
|
+
private until;
|
|
88
|
+
/**
|
|
89
|
+
* Start (or restart) a cooldown for one member.
|
|
90
|
+
* @param id - the channel that answered "out of credit".
|
|
91
|
+
* @param atMs - when the refusal was observed.
|
|
92
|
+
*/
|
|
93
|
+
noteQuota(id: string, atMs: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Forget a member's cooldown because it just served successfully.
|
|
96
|
+
* @param id - the channel that worked.
|
|
97
|
+
*/
|
|
98
|
+
clear(id: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* The members currently being skipped.
|
|
101
|
+
*
|
|
102
|
+
* Pruning happens here rather than on a timer: an expired entry is indistinguishable from no
|
|
103
|
+
* entry, and a timer would be a second clock that can disagree with the one the request uses.
|
|
104
|
+
* @param nowMs - current time.
|
|
105
|
+
* @returns the ids to skip for this request.
|
|
106
|
+
*/
|
|
107
|
+
coolingIds(nowMs: number): ReadonlySet<string>;
|
|
108
|
+
/**
|
|
109
|
+
* Forget cooldowns for members that are no longer configured.
|
|
110
|
+
*
|
|
111
|
+
* A removed-and-re-added member must not inherit an old verdict: the user may well have pointed
|
|
112
|
+
* the id at a different account in between, and a stale skip would silently keep it out of use.
|
|
113
|
+
* @param members - the configured member ids.
|
|
114
|
+
*/
|
|
115
|
+
bind(members: readonly string[]): void;
|
|
116
|
+
/**
|
|
117
|
+
* The skips, for the panel.
|
|
118
|
+
*
|
|
119
|
+
* `retryInMs` is computed HERE rather than on the client so the reading does not depend on the
|
|
120
|
+
* browser's clock โ a client 10 minutes slow would otherwise claim a member is still cooling
|
|
121
|
+
* when the server had already put it back in the walk.
|
|
122
|
+
* @param nowMs - current time.
|
|
123
|
+
* @returns one entry per skipped member, soonest-ending first.
|
|
124
|
+
*/
|
|
125
|
+
active(nowMs: number): Array<{
|
|
126
|
+
id: string;
|
|
127
|
+
retryInMs: number;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
/** Codes that mean "this account has no credit", the only ones that start a cooldown. */
|
|
131
|
+
export declare const QUOTA_COOLDOWN_CODES: ReadonlySet<string>;
|
|
132
|
+
/**
|
|
133
|
+
* Whether a failure should put its member into a cooldown.
|
|
134
|
+
*
|
|
135
|
+
* โ Narrower than {@link CHANNEL_UNUSABLE_CODES} on purpose. `AUTH` / `MISSING_CREDENTIAL` are also
|
|
136
|
+
* terminal, but they are CONFIGURATION faults: skipping them for 30 minutes would hide a mistyped
|
|
137
|
+
* key behind a plausible-looking "the group is just using another relay", and the user would never
|
|
138
|
+
* learn the channel is broken. They keep failing loudly, every request.
|
|
139
|
+
* @param code - the failure code from the attempt.
|
|
140
|
+
* @returns true when this failure earns a 30-minute skip.
|
|
141
|
+
*/
|
|
142
|
+
export declare function shouldCoolDown(code: string | undefined): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Order the walk for one request: configured priority, minus members in cooldown.
|
|
145
|
+
*
|
|
146
|
+
* ๐ด **The cooling members are APPENDED, never dropped.** A group where every member is cooling
|
|
147
|
+
* would otherwise route to nothing and fail a request that a relay could have served โ the cooldown
|
|
148
|
+
* is an optimisation, and an optimisation that can take the supplier offline is not one. So the
|
|
149
|
+
* order is "everyone who might work, in priority order; then everyone we suspect, in priority
|
|
150
|
+
* order". When nothing is cooling this is exactly the configured list, which is the property the
|
|
151
|
+
* owner asked for.
|
|
152
|
+
*
|
|
153
|
+
* โ ๏ธ A member whose id is not in `ordered` at all (a dangling member) never appears โ that is a
|
|
154
|
+
* separate, already-handled case (`groupMembers` drops it and `/channels` reports it).
|
|
155
|
+
* @param ordered - resolvable channels, configured priority order.
|
|
156
|
+
* @param cooling - ids currently being skipped.
|
|
157
|
+
* @returns the walk order plus which of them are only there as a last resort.
|
|
158
|
+
*/
|
|
159
|
+
export declare function orderWithCooldowns<T extends OrderableChannel>(ordered: readonly T[], cooling: ReadonlySet<string>): {
|
|
160
|
+
walk: T[];
|
|
161
|
+
skipped: string[];
|
|
162
|
+
};
|
|
41
163
|
/** What the dispatch loop knows when deciding whether to move on. */
|
|
42
164
|
export interface SwitchDecisionInput {
|
|
43
165
|
/** The failure code from the just-failed attempt. */
|
|
@@ -72,6 +194,49 @@ export interface SupplySwitch {
|
|
|
72
194
|
code: string;
|
|
73
195
|
atMs: number;
|
|
74
196
|
}
|
|
197
|
+
/** What the adapter knows when deciding whether a dead channel may fall back into the group. */
|
|
198
|
+
export interface FallbackDecisionInput {
|
|
199
|
+
/** The failure code from the attempt on the DIRECTLY selected channel. */
|
|
200
|
+
code: string | undefined;
|
|
201
|
+
/**
|
|
202
|
+
* Whether ANY chunk reached the consumer.
|
|
203
|
+
*
|
|
204
|
+
* ๐ด Same load-bearing guard as {@link canSwitchAttempt}, and for the identical reason: once a
|
|
205
|
+
* chunk is yielded it is in the session and on screen, so continuing on another supplier would
|
|
206
|
+
* splice two models into one message with no seam.
|
|
207
|
+
*/
|
|
208
|
+
emitted: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Whether `current` names a CHANNEL rather than the supply group.
|
|
211
|
+
*
|
|
212
|
+
* โ When the group is already serving, its own walk owns this decision (`canSwitchAttempt`).
|
|
213
|
+
* Two mechanisms acting on one failure would double-attempt the same member.
|
|
214
|
+
*/
|
|
215
|
+
selectionIsChannel: boolean;
|
|
216
|
+
/** How many resolvable members the group has, EXCLUDING the channel that just failed. */
|
|
217
|
+
groupCandidates: number;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Whether a plain-channel request may fall back into the supply group.
|
|
221
|
+
*
|
|
222
|
+
* ## Why this is a separate decision from the group's own walk
|
|
223
|
+
*
|
|
224
|
+
* The group walk answers "which OTHER member serves this request"; this answers "should a request
|
|
225
|
+
* that was NOT walking the group start walking it, because the chosen channel ran out of money".
|
|
226
|
+
* They share the emitted guard and the switch set's philosophy, but they differ in the trigger set
|
|
227
|
+
* (narrower โ {@link OUT_OF_CREDIT_CODES}) and in what they must leave alone: this one never
|
|
228
|
+
* applies when the group is already the selection.
|
|
229
|
+
*
|
|
230
|
+
* โ ๏ธ **It is a per-request decision, not a persisted mode change.** `current` stays what the user
|
|
231
|
+
* chose. That is not timidity โ writing settings from a request path is a revision bump in the
|
|
232
|
+
* middle of a request, which is the exact shape of theใไฟๅญๆถๅฅฝๆถๅใdefect (decision 85). The
|
|
233
|
+
* consequence is stated rather than hidden: while the chosen channel has no credit, EVERY request
|
|
234
|
+
* pays one wasted quota refusal on it first, then serves from the group. Same price as the priority
|
|
235
|
+
* order (decision 97), and the same benefit: topping the channel up restores it with no action.
|
|
236
|
+
* @param input - the four facts the decision depends on.
|
|
237
|
+
* @returns true only when the fallback is both useful and safe.
|
|
238
|
+
*/
|
|
239
|
+
export declare function canFallBackToGroup(input: FallbackDecisionInput): boolean;
|
|
75
240
|
/**
|
|
76
241
|
* What the last request did, for the panel only.
|
|
77
242
|
*
|
|
@@ -83,6 +248,27 @@ export interface SupplySwitch {
|
|
|
83
248
|
export declare class SupplyStatus {
|
|
84
249
|
/** The member that last served successfully. */
|
|
85
250
|
private servedId;
|
|
251
|
+
/**
|
|
252
|
+
* The `current` value in force when {@link servedId} was recorded.
|
|
253
|
+
*
|
|
254
|
+
* ๐ด Why a reading needs its own provenance (2026-11-19). `serving` answers "which channel served
|
|
255
|
+
* the last successful request", and that is only meaningful against the selection that request
|
|
256
|
+
* ran under. Without this, a user who switches from a channel to another channel would keep
|
|
257
|
+
* seeing the previous name rendered as if it were live โ the 2026-11-18 wrong-name defect, one
|
|
258
|
+
* layer down. The panel now reports `serving` ONLY when this still matches the live `current`;
|
|
259
|
+
* otherwise the reading is stale and saying nothing is the honest answer.
|
|
260
|
+
*/
|
|
261
|
+
private servedFor;
|
|
262
|
+
/**
|
|
263
|
+
* Whether the last successful request reached that channel by falling back into the group.
|
|
264
|
+
*
|
|
265
|
+
* ๐ด This is the fact that makes the safety net VISIBLE (owner request 2026-11-19). With a plain
|
|
266
|
+
* channel selected, a request can now be served by a group MEMBER after the chosen channel runs
|
|
267
|
+
* out of credit. Without this flag the sidebar would print the member's own label as though the
|
|
268
|
+
* user had selected it โ a confident wrong answer about where the request went, which is exactly
|
|
269
|
+
* the defect of 2026-11-18 one layer down.
|
|
270
|
+
*/
|
|
271
|
+
private servedViaFallback;
|
|
86
272
|
/** The last switch, if any since the process started (or since the group was re-read). */
|
|
87
273
|
private switchRecord;
|
|
88
274
|
/** Whether the most recent request found no usable member at all. */
|
|
@@ -100,8 +286,13 @@ export declare class SupplyStatus {
|
|
|
100
286
|
* @param members - the configured ordered member ids.
|
|
101
287
|
*/
|
|
102
288
|
bind(members: readonly string[]): void;
|
|
103
|
-
/**
|
|
104
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Record that `id` served this request successfully.
|
|
291
|
+
* @param id - the channel that actually produced the response.
|
|
292
|
+
* @param forCurrent - the `current` value this request was routed under.
|
|
293
|
+
* @param viaFallback - whether it served after a plain-channel selection fell back into the group.
|
|
294
|
+
*/
|
|
295
|
+
noteServed(id: string, forCurrent: string, viaFallback?: boolean): void;
|
|
105
296
|
/** Record one move from a member that could not serve to the one tried next. */
|
|
106
297
|
noteSwitch(from: string, to: string, code: string, atMs: number): void;
|
|
107
298
|
/**
|
|
@@ -115,8 +306,35 @@ export declare class SupplyStatus {
|
|
|
115
306
|
* @param exhausted - whether the list ran out (true) or the request failed with members left.
|
|
116
307
|
*/
|
|
117
308
|
noteFailure(lastTried: string | undefined, exhausted: boolean): void;
|
|
309
|
+
/**
|
|
310
|
+
* Whether the last successful request reached its supplier by falling back into the group.
|
|
311
|
+
*
|
|
312
|
+
* โ Only meaningful together with {@link servingUnder}: a stale reading from before a selection
|
|
313
|
+
* change must not be reported as a live fallback.
|
|
314
|
+
*/
|
|
315
|
+
get servedByFallback(): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Whether the member that last served belongs to the currently bound group list.
|
|
318
|
+
*
|
|
319
|
+
* ๐ด This is what makes the safety net VISIBLE (owner request 2026-11-19). With a plain channel
|
|
320
|
+
* selected, a request can now be served by a group member after the chosen channel runs out of
|
|
321
|
+
* credit. Saying so requires two facts together โ "who served" and "is that one of the group's
|
|
322
|
+
* members" โ and neither alone is enough: the same channel may be both `current` and a member.
|
|
323
|
+
* @param id - a channel id, typically {@link servingUnder}.
|
|
324
|
+
* @returns true when `id` is in the bound member list.
|
|
325
|
+
*/
|
|
326
|
+
isMember(id: string | undefined): boolean;
|
|
118
327
|
/** The member that last served, or undefined when nothing has served yet / the last request failed. */
|
|
119
328
|
get serving(): string | undefined;
|
|
329
|
+
/**
|
|
330
|
+
* The member that last served, but only if that reading still applies to `current`.
|
|
331
|
+
*
|
|
332
|
+
* ๐ด This is what a reader should use. {@link serving} alone cannot distinguish "this is who is
|
|
333
|
+
* serving now" from "this is who served before the user changed the selection".
|
|
334
|
+
* @param current - the live `current` value.
|
|
335
|
+
* @returns the serving channel id, or undefined when the reading is stale or absent.
|
|
336
|
+
*/
|
|
337
|
+
servingUnder(current: string | undefined): string | undefined;
|
|
120
338
|
/** The most recent switch, or undefined when none has happened. */
|
|
121
339
|
get lastSwitch(): SupplySwitch | undefined;
|
|
122
340
|
/** Whether the most recent request found no usable member. */
|
|
@@ -124,3 +342,4 @@ export declare class SupplyStatus {
|
|
|
124
342
|
/** The member the last failed request gave up on; undefined when that request succeeded. */
|
|
125
343
|
get lastTried(): string | undefined;
|
|
126
344
|
}
|
|
345
|
+
export {};
|
package/lib/http.d.ts
CHANGED
|
@@ -79,6 +79,24 @@ export interface RouteDeps {
|
|
|
79
79
|
exhausted: boolean;
|
|
80
80
|
/** The member the last FAILED request gave up on; absent when that request succeeded. */
|
|
81
81
|
lastTried?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Members currently moved to the BACK of the walk because they answered "out of credit".
|
|
84
|
+
*
|
|
85
|
+
* ๐ด Owner decision 2026-11-19 (30 minutes). Absent when nothing is cooling โ not an empty
|
|
86
|
+
* array โ so "no skips" and "this build has no cooldown" stay distinguishable to an older panel.
|
|
87
|
+
* `retryInMs` is a server-side reading, so a client with a wrong clock cannot misreport it.
|
|
88
|
+
*/
|
|
89
|
+
cooling?: Array<{
|
|
90
|
+
id: string;
|
|
91
|
+
retryInMs: number;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the last successful request left the CHOSEN channel for a group member.
|
|
95
|
+
*
|
|
96
|
+
* Present only when true: the panel renders ใไพๅบ็ป๏ผ่ชๅจ๏ผยท Xใ for it, and `false` would be a
|
|
97
|
+
* fact nobody displays.
|
|
98
|
+
*/
|
|
99
|
+
viaFallback?: boolean;
|
|
82
100
|
/**
|
|
83
101
|
* The most recent switch, since the process started or since the member list changed.
|
|
84
102
|
*
|
package/lib/index.js
CHANGED
|
@@ -748,6 +748,35 @@ function selectChannel(channels, current, groupMembers = []) {
|
|
|
748
748
|
};
|
|
749
749
|
}
|
|
750
750
|
/**
|
|
751
|
+
* The supply group's members, resolved and ordered: the ONE definition of "who is in the group".
|
|
752
|
+
*
|
|
753
|
+
* ๐ด Extracted for the safety-net path (2026-11-19). Two callers now need it โ the router, which
|
|
754
|
+
* needs a head plus alternates, and the adapter's fallback, which needs the ordered ids to append
|
|
755
|
+
* to a single-channel request that ran out of credit. If each derived the order itself they would
|
|
756
|
+
* eventually disagree about what "priority 1" means, and the disagreement would be invisible: both
|
|
757
|
+
* would look correct on their own.
|
|
758
|
+
*
|
|
759
|
+
* Dangling ids are dropped here and nowhere else, and the caller is told which ones โ the panel
|
|
760
|
+
* lists them, because a group that quietly shrinks is how "three relays" becomes "one relay".
|
|
761
|
+
* @param channels - every resolved channel.
|
|
762
|
+
* @param members - the configured ordered member ids; index 0 is the highest priority.
|
|
763
|
+
* @returns the ordered resolvable channels, plus the member ids that resolve to nothing.
|
|
764
|
+
*/
|
|
765
|
+
function groupMembers(channels, members) {
|
|
766
|
+
const byId = new Map(channels.map((channel) => [channel.id, channel]));
|
|
767
|
+
const ordered = [];
|
|
768
|
+
const dangling = [];
|
|
769
|
+
for (const id of members) {
|
|
770
|
+
const channel = byId.get(id);
|
|
771
|
+
if (channel === void 0) dangling.push(id);
|
|
772
|
+
else ordered.push(channel);
|
|
773
|
+
}
|
|
774
|
+
return {
|
|
775
|
+
ordered,
|
|
776
|
+
dangling
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
751
780
|
* Resolve the supply group into an ordered candidate list, highest priority first.
|
|
752
781
|
*
|
|
753
782
|
* ## Why dangling members are SKIPPED rather than fatal
|
|
@@ -764,33 +793,24 @@ function selectChannel(channels, current, groupMembers = []) {
|
|
|
764
793
|
* @returns the ordered candidates, or a failure.
|
|
765
794
|
*/
|
|
766
795
|
function selectFromGroup(channels, members) {
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
if (resolvable.length === 0) return {
|
|
796
|
+
const { ordered } = groupMembers(channels, members);
|
|
797
|
+
if (ordered.length === 0) return {
|
|
770
798
|
ok: false,
|
|
771
799
|
failure: {
|
|
772
800
|
code: "GROUP_EMPTY",
|
|
773
801
|
detail: members.length === 0 ? "the supply group has no members; add channels to it in Settings โ Any DeepSeek" : `the supply group names no channel that exists (${members.join(", ")}); fix it in Settings โ Any DeepSeek`
|
|
774
802
|
}
|
|
775
803
|
};
|
|
776
|
-
const [head, ...rest] =
|
|
777
|
-
const headChannel = byId.get(head);
|
|
778
|
-
if (headChannel === void 0) return {
|
|
779
|
-
ok: false,
|
|
780
|
-
failure: {
|
|
781
|
-
code: "GROUP_EMPTY",
|
|
782
|
-
detail: "the supply group resolved to nothing usable"
|
|
783
|
-
}
|
|
784
|
-
};
|
|
804
|
+
const [head, ...rest] = ordered;
|
|
785
805
|
return {
|
|
786
806
|
ok: true,
|
|
787
|
-
channel:
|
|
807
|
+
channel: head,
|
|
788
808
|
source: {
|
|
789
809
|
kind: "group",
|
|
790
810
|
index: 0,
|
|
791
|
-
of:
|
|
811
|
+
of: ordered.length
|
|
792
812
|
},
|
|
793
|
-
alternates: rest
|
|
813
|
+
alternates: rest
|
|
794
814
|
};
|
|
795
815
|
}
|
|
796
816
|
//#endregion
|
|
@@ -847,6 +867,150 @@ function shouldFailover(code) {
|
|
|
847
867
|
return CHANNEL_UNUSABLE_CODES.has(code);
|
|
848
868
|
}
|
|
849
869
|
/**
|
|
870
|
+
* How long a member that answered "out of credit" is SKIPPED for.
|
|
871
|
+
*
|
|
872
|
+
* ๐ด Owner decision 2026-11-19, after measuring the cost of the pure priority order: two dead
|
|
873
|
+
* members in front of a healthy one made every request pay two serial HTTP round-trips (measured
|
|
874
|
+
* 253โ964 ms each) before the real attempt, i.e. โ0.55 s of pure overhead per request on a 4.6 s
|
|
875
|
+
* first token. Owner chose this design over "just move them out of the group" because that one
|
|
876
|
+
* needs a human to reorder whenever a relay runs dry or is topped up.
|
|
877
|
+
*
|
|
878
|
+
* **Owner set the window: ๅๅฐๆถ.** The number is a trade with two sides, and both are stated
|
|
879
|
+
* rather than hidden:
|
|
880
|
+
* ยท too short โ the wasted round-trip comes back sooner, and a relay that is still dry gets
|
|
881
|
+
* re-probed more often than it can possibly recover;
|
|
882
|
+
* ยท too long โ a top-up takes up to this long to be noticed.
|
|
883
|
+
* 30 minutes is what the owner picked after seeing the measurement.
|
|
884
|
+
*/
|
|
885
|
+
const QUOTA_COOLDOWN_MS = 18e5;
|
|
886
|
+
/**
|
|
887
|
+
* Per-member, time-bounded skipping of members that just answered "out of credit".
|
|
888
|
+
*
|
|
889
|
+
* ## Why this is NOT the sticky cursor that was rejected
|
|
890
|
+
*
|
|
891
|
+
* The vetoed design (2026-11-12) was a POSITION: one index, advanced on failure, never expiring,
|
|
892
|
+
* invisible, and it silently outranked the configured order forever. Recovering from it needed a
|
|
893
|
+
* manual reset button.
|
|
894
|
+
*
|
|
895
|
+
* This is the opposite on every axis:
|
|
896
|
+
* ยท **keyed by member, not by position** โ reordering the list changes nothing about who is skipped;
|
|
897
|
+
* ยท **bounded** โ {@link QUOTA_COOLDOWN_MS}, then the member is tried again automatically;
|
|
898
|
+
* ยท **triggered by ONE cause** โ `QUOTA`/`ACCOUNT_QUOTA` only, so a dead key or a timeout never
|
|
899
|
+
* hides a channel;
|
|
900
|
+
* ยท **VISIBLE** โ `/channels` reports the skipped ids with their remaining time, and the panel
|
|
901
|
+
* shows them.
|
|
902
|
+
*
|
|
903
|
+
* And the property the owner cared about is preserved: **the order that remains IS the configured
|
|
904
|
+
* order**. Skipping is not reordering; when a member comes back it comes back at its own rank.
|
|
905
|
+
*
|
|
906
|
+
* โ ๏ธ In-memory and process-scoped on purpose: a host restart re-probes everything, which is the
|
|
907
|
+
* honest behaviour when the only thing known about a relay is 30 minutes old.
|
|
908
|
+
*/
|
|
909
|
+
var QuotaCooldown = class {
|
|
910
|
+
/** member id โ the instant its cooldown ends (epoch ms). */
|
|
911
|
+
until = /* @__PURE__ */ new Map();
|
|
912
|
+
/**
|
|
913
|
+
* Start (or restart) a cooldown for one member.
|
|
914
|
+
* @param id - the channel that answered "out of credit".
|
|
915
|
+
* @param atMs - when the refusal was observed.
|
|
916
|
+
*/
|
|
917
|
+
noteQuota(id, atMs) {
|
|
918
|
+
this.until.set(id, atMs + QUOTA_COOLDOWN_MS);
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Forget a member's cooldown because it just served successfully.
|
|
922
|
+
* @param id - the channel that worked.
|
|
923
|
+
*/
|
|
924
|
+
clear(id) {
|
|
925
|
+
this.until.delete(id);
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* The members currently being skipped.
|
|
929
|
+
*
|
|
930
|
+
* Pruning happens here rather than on a timer: an expired entry is indistinguishable from no
|
|
931
|
+
* entry, and a timer would be a second clock that can disagree with the one the request uses.
|
|
932
|
+
* @param nowMs - current time.
|
|
933
|
+
* @returns the ids to skip for this request.
|
|
934
|
+
*/
|
|
935
|
+
coolingIds(nowMs) {
|
|
936
|
+
const live = /* @__PURE__ */ new Set();
|
|
937
|
+
for (const [id, until] of this.until) if (until > nowMs) live.add(id);
|
|
938
|
+
else this.until.delete(id);
|
|
939
|
+
return live;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Forget cooldowns for members that are no longer configured.
|
|
943
|
+
*
|
|
944
|
+
* A removed-and-re-added member must not inherit an old verdict: the user may well have pointed
|
|
945
|
+
* the id at a different account in between, and a stale skip would silently keep it out of use.
|
|
946
|
+
* @param members - the configured member ids.
|
|
947
|
+
*/
|
|
948
|
+
bind(members) {
|
|
949
|
+
const known = new Set(members);
|
|
950
|
+
for (const id of [...this.until.keys()]) if (!known.has(id)) this.until.delete(id);
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* The skips, for the panel.
|
|
954
|
+
*
|
|
955
|
+
* `retryInMs` is computed HERE rather than on the client so the reading does not depend on the
|
|
956
|
+
* browser's clock โ a client 10 minutes slow would otherwise claim a member is still cooling
|
|
957
|
+
* when the server had already put it back in the walk.
|
|
958
|
+
* @param nowMs - current time.
|
|
959
|
+
* @returns one entry per skipped member, soonest-ending first.
|
|
960
|
+
*/
|
|
961
|
+
active(nowMs) {
|
|
962
|
+
const out = [];
|
|
963
|
+
for (const [id, until] of this.until) if (until > nowMs) out.push({
|
|
964
|
+
id,
|
|
965
|
+
retryInMs: until - nowMs
|
|
966
|
+
});
|
|
967
|
+
else this.until.delete(id);
|
|
968
|
+
return out.sort((a, b) => a.retryInMs - b.retryInMs);
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
/** Codes that mean "this account has no credit", the only ones that start a cooldown. */
|
|
972
|
+
const QUOTA_COOLDOWN_CODES = /* @__PURE__ */ new Set(["QUOTA", "ACCOUNT_QUOTA"]);
|
|
973
|
+
/**
|
|
974
|
+
* Whether a failure should put its member into a cooldown.
|
|
975
|
+
*
|
|
976
|
+
* โ Narrower than {@link CHANNEL_UNUSABLE_CODES} on purpose. `AUTH` / `MISSING_CREDENTIAL` are also
|
|
977
|
+
* terminal, but they are CONFIGURATION faults: skipping them for 30 minutes would hide a mistyped
|
|
978
|
+
* key behind a plausible-looking "the group is just using another relay", and the user would never
|
|
979
|
+
* learn the channel is broken. They keep failing loudly, every request.
|
|
980
|
+
* @param code - the failure code from the attempt.
|
|
981
|
+
* @returns true when this failure earns a 30-minute skip.
|
|
982
|
+
*/
|
|
983
|
+
function shouldCoolDown(code) {
|
|
984
|
+
if (code === void 0) return false;
|
|
985
|
+
return QUOTA_COOLDOWN_CODES.has(code);
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Order the walk for one request: configured priority, minus members in cooldown.
|
|
989
|
+
*
|
|
990
|
+
* ๐ด **The cooling members are APPENDED, never dropped.** A group where every member is cooling
|
|
991
|
+
* would otherwise route to nothing and fail a request that a relay could have served โ the cooldown
|
|
992
|
+
* is an optimisation, and an optimisation that can take the supplier offline is not one. So the
|
|
993
|
+
* order is "everyone who might work, in priority order; then everyone we suspect, in priority
|
|
994
|
+
* order". When nothing is cooling this is exactly the configured list, which is the property the
|
|
995
|
+
* owner asked for.
|
|
996
|
+
*
|
|
997
|
+
* โ ๏ธ A member whose id is not in `ordered` at all (a dangling member) never appears โ that is a
|
|
998
|
+
* separate, already-handled case (`groupMembers` drops it and `/channels` reports it).
|
|
999
|
+
* @param ordered - resolvable channels, configured priority order.
|
|
1000
|
+
* @param cooling - ids currently being skipped.
|
|
1001
|
+
* @returns the walk order plus which of them are only there as a last resort.
|
|
1002
|
+
*/
|
|
1003
|
+
function orderWithCooldowns(ordered, cooling) {
|
|
1004
|
+
const fresh = [];
|
|
1005
|
+
const stale = [];
|
|
1006
|
+
for (const channel of ordered) if (cooling.has(channel.id)) stale.push(channel);
|
|
1007
|
+
else fresh.push(channel);
|
|
1008
|
+
return {
|
|
1009
|
+
walk: [...fresh, ...stale],
|
|
1010
|
+
skipped: stale.map((channel) => channel.id)
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
850
1014
|
* Whether one failed attempt may be followed by another attempt on a DIFFERENT channel.
|
|
851
1015
|
*
|
|
852
1016
|
* Kept as a separate pure function rather than inlined in the dispatch loop for one reason:
|
|
@@ -861,6 +1025,48 @@ function canSwitchAttempt(input) {
|
|
|
861
1025
|
return !input.emitted && input.hasNext && shouldFailover(input.code);
|
|
862
1026
|
}
|
|
863
1027
|
/**
|
|
1028
|
+
* Codes that mean "this account has no credit left", as opposed to any other failure.
|
|
1029
|
+
*
|
|
1030
|
+
* ๐ด Deliberately NARROWER than {@link CHANNEL_UNUSABLE_CODES}, and the difference is the whole
|
|
1031
|
+
* point of the safety net this list serves. Owner request 2026-11-19:
|
|
1032
|
+
* ใๅฝไฝฟ็จ้ไพๅบ็ปๆธ ้ ็จๅฐๆ ่ดน็จๆถ ่ชๅจๅๆขๅฐไพๅบ็ปใ็ฎ็ๆฏ็กฎไฟ token ไพๅบไธไธญๆญใ.
|
|
1033
|
+
*
|
|
1034
|
+
* The trigger is ใๆ ่ดน็จใ โ out of credit. A dead key (`AUTH`) or a channel whose key was never
|
|
1035
|
+
* configured (`MISSING_CREDENTIAL`) is ALSO terminal, but falling back into the supply group for
|
|
1036
|
+
* those would be answering a question the owner did not ask: a mistyped key is a configuration
|
|
1037
|
+
* error to fix, not a reason to silently route elsewhere, and routing around it would hide it.
|
|
1038
|
+
* Those two are still fatal for a plain channel selection (decision: no silent fallback), so they
|
|
1039
|
+
* stay OUT of this set. If the owner ever wants them in, this comment is where the change starts.
|
|
1040
|
+
*/
|
|
1041
|
+
const OUT_OF_CREDIT_CODES = /* @__PURE__ */ new Set(["QUOTA", "ACCOUNT_QUOTA"]);
|
|
1042
|
+
/**
|
|
1043
|
+
* Whether a plain-channel request may fall back into the supply group.
|
|
1044
|
+
*
|
|
1045
|
+
* ## Why this is a separate decision from the group's own walk
|
|
1046
|
+
*
|
|
1047
|
+
* The group walk answers "which OTHER member serves this request"; this answers "should a request
|
|
1048
|
+
* that was NOT walking the group start walking it, because the chosen channel ran out of money".
|
|
1049
|
+
* They share the emitted guard and the switch set's philosophy, but they differ in the trigger set
|
|
1050
|
+
* (narrower โ {@link OUT_OF_CREDIT_CODES}) and in what they must leave alone: this one never
|
|
1051
|
+
* applies when the group is already the selection.
|
|
1052
|
+
*
|
|
1053
|
+
* โ ๏ธ **It is a per-request decision, not a persisted mode change.** `current` stays what the user
|
|
1054
|
+
* chose. That is not timidity โ writing settings from a request path is a revision bump in the
|
|
1055
|
+
* middle of a request, which is the exact shape of theใไฟๅญๆถๅฅฝๆถๅใdefect (decision 85). The
|
|
1056
|
+
* consequence is stated rather than hidden: while the chosen channel has no credit, EVERY request
|
|
1057
|
+
* pays one wasted quota refusal on it first, then serves from the group. Same price as the priority
|
|
1058
|
+
* order (decision 97), and the same benefit: topping the channel up restores it with no action.
|
|
1059
|
+
* @param input - the four facts the decision depends on.
|
|
1060
|
+
* @returns true only when the fallback is both useful and safe.
|
|
1061
|
+
*/
|
|
1062
|
+
function canFallBackToGroup(input) {
|
|
1063
|
+
if (input.emitted) return false;
|
|
1064
|
+
if (!input.selectionIsChannel) return false;
|
|
1065
|
+
if (input.groupCandidates <= 0) return false;
|
|
1066
|
+
if (input.code === void 0) return false;
|
|
1067
|
+
return OUT_OF_CREDIT_CODES.has(input.code);
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
864
1070
|
* What the last request did, for the panel only.
|
|
865
1071
|
*
|
|
866
1072
|
* ๐ด **Nothing here is an input to routing.** The owner's rule is "always start at 1", so a value
|
|
@@ -871,6 +1077,27 @@ function canSwitchAttempt(input) {
|
|
|
871
1077
|
var SupplyStatus = class {
|
|
872
1078
|
/** The member that last served successfully. */
|
|
873
1079
|
servedId;
|
|
1080
|
+
/**
|
|
1081
|
+
* The `current` value in force when {@link servedId} was recorded.
|
|
1082
|
+
*
|
|
1083
|
+
* ๐ด Why a reading needs its own provenance (2026-11-19). `serving` answers "which channel served
|
|
1084
|
+
* the last successful request", and that is only meaningful against the selection that request
|
|
1085
|
+
* ran under. Without this, a user who switches from a channel to another channel would keep
|
|
1086
|
+
* seeing the previous name rendered as if it were live โ the 2026-11-18 wrong-name defect, one
|
|
1087
|
+
* layer down. The panel now reports `serving` ONLY when this still matches the live `current`;
|
|
1088
|
+
* otherwise the reading is stale and saying nothing is the honest answer.
|
|
1089
|
+
*/
|
|
1090
|
+
servedFor;
|
|
1091
|
+
/**
|
|
1092
|
+
* Whether the last successful request reached that channel by falling back into the group.
|
|
1093
|
+
*
|
|
1094
|
+
* ๐ด This is the fact that makes the safety net VISIBLE (owner request 2026-11-19). With a plain
|
|
1095
|
+
* channel selected, a request can now be served by a group MEMBER after the chosen channel runs
|
|
1096
|
+
* out of credit. Without this flag the sidebar would print the member's own label as though the
|
|
1097
|
+
* user had selected it โ a confident wrong answer about where the request went, which is exactly
|
|
1098
|
+
* the defect of 2026-11-18 one layer down.
|
|
1099
|
+
*/
|
|
1100
|
+
servedViaFallback = false;
|
|
874
1101
|
/** The last switch, if any since the process started (or since the group was re-read). */
|
|
875
1102
|
switchRecord;
|
|
876
1103
|
/** Whether the most recent request found no usable member at all. */
|
|
@@ -892,13 +1119,22 @@ var SupplyStatus = class {
|
|
|
892
1119
|
if (signature === this.signature) return;
|
|
893
1120
|
this.signature = signature;
|
|
894
1121
|
this.servedId = void 0;
|
|
1122
|
+
this.servedFor = void 0;
|
|
1123
|
+
this.servedViaFallback = false;
|
|
895
1124
|
this.switchRecord = void 0;
|
|
896
1125
|
this.exhausted = false;
|
|
897
1126
|
this.lastTriedId = void 0;
|
|
898
1127
|
}
|
|
899
|
-
/**
|
|
900
|
-
|
|
1128
|
+
/**
|
|
1129
|
+
* Record that `id` served this request successfully.
|
|
1130
|
+
* @param id - the channel that actually produced the response.
|
|
1131
|
+
* @param forCurrent - the `current` value this request was routed under.
|
|
1132
|
+
* @param viaFallback - whether it served after a plain-channel selection fell back into the group.
|
|
1133
|
+
*/
|
|
1134
|
+
noteServed(id, forCurrent, viaFallback = false) {
|
|
901
1135
|
this.servedId = id;
|
|
1136
|
+
this.servedFor = forCurrent;
|
|
1137
|
+
this.servedViaFallback = viaFallback;
|
|
902
1138
|
this.exhausted = false;
|
|
903
1139
|
this.lastTriedId = void 0;
|
|
904
1140
|
}
|
|
@@ -923,13 +1159,50 @@ var SupplyStatus = class {
|
|
|
923
1159
|
*/
|
|
924
1160
|
noteFailure(lastTried, exhausted) {
|
|
925
1161
|
this.servedId = void 0;
|
|
1162
|
+
this.servedFor = void 0;
|
|
1163
|
+
this.servedViaFallback = false;
|
|
926
1164
|
this.exhausted = exhausted;
|
|
927
1165
|
this.lastTriedId = lastTried;
|
|
928
1166
|
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Whether the last successful request reached its supplier by falling back into the group.
|
|
1169
|
+
*
|
|
1170
|
+
* โ Only meaningful together with {@link servingUnder}: a stale reading from before a selection
|
|
1171
|
+
* change must not be reported as a live fallback.
|
|
1172
|
+
*/
|
|
1173
|
+
get servedByFallback() {
|
|
1174
|
+
return this.servedViaFallback;
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Whether the member that last served belongs to the currently bound group list.
|
|
1178
|
+
*
|
|
1179
|
+
* ๐ด This is what makes the safety net VISIBLE (owner request 2026-11-19). With a plain channel
|
|
1180
|
+
* selected, a request can now be served by a group member after the chosen channel runs out of
|
|
1181
|
+
* credit. Saying so requires two facts together โ "who served" and "is that one of the group's
|
|
1182
|
+
* members" โ and neither alone is enough: the same channel may be both `current` and a member.
|
|
1183
|
+
* @param id - a channel id, typically {@link servingUnder}.
|
|
1184
|
+
* @returns true when `id` is in the bound member list.
|
|
1185
|
+
*/
|
|
1186
|
+
isMember(id) {
|
|
1187
|
+
if (id === void 0 || this.signature === "") return false;
|
|
1188
|
+
return this.signature.split("\0").includes(id);
|
|
1189
|
+
}
|
|
929
1190
|
/** The member that last served, or undefined when nothing has served yet / the last request failed. */
|
|
930
1191
|
get serving() {
|
|
931
1192
|
return this.servedId;
|
|
932
1193
|
}
|
|
1194
|
+
/**
|
|
1195
|
+
* The member that last served, but only if that reading still applies to `current`.
|
|
1196
|
+
*
|
|
1197
|
+
* ๐ด This is what a reader should use. {@link serving} alone cannot distinguish "this is who is
|
|
1198
|
+
* serving now" from "this is who served before the user changed the selection".
|
|
1199
|
+
* @param current - the live `current` value.
|
|
1200
|
+
* @returns the serving channel id, or undefined when the reading is stale or absent.
|
|
1201
|
+
*/
|
|
1202
|
+
servingUnder(current) {
|
|
1203
|
+
const live = current ?? "";
|
|
1204
|
+
return this.servedFor === live ? this.servedId : void 0;
|
|
1205
|
+
}
|
|
933
1206
|
/** The most recent switch, or undefined when none has happened. */
|
|
934
1207
|
get lastSwitch() {
|
|
935
1208
|
return this.switchRecord;
|
|
@@ -1710,8 +1983,43 @@ var AnyDeepSeekAdapter = class extends LlmAdapter {
|
|
|
1710
1983
|
yield failureChunk(selection.failure);
|
|
1711
1984
|
return;
|
|
1712
1985
|
}
|
|
1713
|
-
const
|
|
1986
|
+
const head = selection.channel;
|
|
1714
1987
|
const fromGroup = selection.source.kind === "group";
|
|
1988
|
+
/**
|
|
1989
|
+
* The walk order for THIS request.
|
|
1990
|
+
*
|
|
1991
|
+
* ๐ด Owner decision 2026-11-19 (`QUOTA_COOLDOWN_MS` = 30 min). Measured cost of the pure priority
|
|
1992
|
+
* order: two dry members in front of a healthy one made every request pay two serial HTTP
|
|
1993
|
+
* round-trips (253โ964 ms each) before the real attempt โ โ0.55 s of dead time per request
|
|
1994
|
+
* against a 4.6 s first token. The owner's instruction was to keep the priority order but stop
|
|
1995
|
+
* paying that toll on every call.
|
|
1996
|
+
*
|
|
1997
|
+
* โ ๏ธ Members in cooldown are moved to the BACK, never dropped (`orderWithCooldowns`): a group
|
|
1998
|
+
* whose every member is cooling must still route somewhere, or an optimisation has taken the
|
|
1999
|
+
* supplier offline. With nothing cooling this is byte-for-byte the configured order โ the exact
|
|
2000
|
+
* property 0.0.35 exists to guarantee.
|
|
2001
|
+
*/
|
|
2002
|
+
const cooling = this.deps.cooldown.coolingIds(this.deps.now().getTime());
|
|
2003
|
+
/** Mutable on purpose: the safety net appends the group's members mid-request. */
|
|
2004
|
+
const candidates = fromGroup ? orderWithCooldowns([head, ...selection.alternates], cooling).walk : [head];
|
|
2005
|
+
/**
|
|
2006
|
+
* The supply group as an ordered fallback list, prepared BEFORE the first attempt.
|
|
2007
|
+
*
|
|
2008
|
+
* ๐ด Owner request 2026-11-19: ใๅฝไฝฟ็จ้ไพๅบ็ปๆธ ้ ็จๅฐๆ ่ดน็จๆถ ่ชๅจๅๆขๅฐไพๅบ็ปใ็ฎ็ๆฏ็กฎไฟ
|
|
2009
|
+
* token ไพๅบไธไธญๆญใ. The group already knows how to walk itself; what was missing is permission
|
|
2010
|
+
* for a request that chose a SINGLE channel to continue inside it when that channel runs out of
|
|
2011
|
+
* money.
|
|
2012
|
+
*
|
|
2013
|
+
* โ Empty when the group is already serving: its own walk owns that decision, and two
|
|
2014
|
+
* mechanisms acting on one failure would attempt the same member twice.
|
|
2015
|
+
*
|
|
2016
|
+
* โ ๏ธ The failed channel is excluded. It is `current`, so a user may well have put it in the
|
|
2017
|
+
* group too; re-attempting it immediately would spend a guaranteed second refusal on the same
|
|
2018
|
+
* dead account, which is not "ไพๅบไธไธญๆญ", it is a loop.
|
|
2019
|
+
*/
|
|
2020
|
+
const groupFallback = fromGroup ? [] : orderWithCooldowns(groupMembers(this.deps.channels(), supply.members).ordered.filter((channel) => channel.id !== head.id), cooling).walk;
|
|
2021
|
+
/** Whether the safety net has already fired for this request (it may fire at most once). */
|
|
2022
|
+
let fellBack = false;
|
|
1715
2023
|
/** Every attempt this request made, for the message on total failure. */
|
|
1716
2024
|
const tried = [];
|
|
1717
2025
|
for (let position = 0; position < candidates.length; position++) {
|
|
@@ -1834,7 +2142,8 @@ var AnyDeepSeekAdapter = class extends LlmAdapter {
|
|
|
1834
2142
|
}
|
|
1835
2143
|
await record();
|
|
1836
2144
|
if (failure === void 0) {
|
|
1837
|
-
|
|
2145
|
+
this.deps.cooldown.clear(channel.id);
|
|
2146
|
+
supply.status.noteServed(channel.id, this.deps.current() ?? "", fellBack);
|
|
1838
2147
|
return;
|
|
1839
2148
|
}
|
|
1840
2149
|
const code = failure.code;
|
|
@@ -1843,21 +2152,33 @@ var AnyDeepSeekAdapter = class extends LlmAdapter {
|
|
|
1843
2152
|
label: channel.label,
|
|
1844
2153
|
code
|
|
1845
2154
|
});
|
|
2155
|
+
if (shouldCoolDown(code)) this.deps.cooldown.noteQuota(channel.id, this.deps.now().getTime());
|
|
1846
2156
|
if (canSwitchAttempt({
|
|
1847
2157
|
code,
|
|
1848
2158
|
emitted,
|
|
1849
2159
|
hasNext: position + 1 < candidates.length
|
|
1850
2160
|
})) {
|
|
1851
|
-
if (fromGroup) supply.status.noteSwitch(channel.id, candidates[position + 1].id, code, this.deps.now().getTime());
|
|
2161
|
+
if (fromGroup || fellBack) supply.status.noteSwitch(channel.id, candidates[position + 1].id, code, this.deps.now().getTime());
|
|
1852
2162
|
continue;
|
|
1853
2163
|
}
|
|
1854
|
-
if (
|
|
2164
|
+
if (!fellBack && canFallBackToGroup({
|
|
2165
|
+
code,
|
|
2166
|
+
emitted,
|
|
2167
|
+
selectionIsChannel: !fromGroup,
|
|
2168
|
+
groupCandidates: groupFallback.length
|
|
2169
|
+
})) {
|
|
2170
|
+
fellBack = true;
|
|
2171
|
+
candidates.push(...groupFallback);
|
|
2172
|
+
supply.status.noteSwitch(channel.id, groupFallback[0].id, code, this.deps.now().getTime());
|
|
2173
|
+
continue;
|
|
2174
|
+
}
|
|
2175
|
+
if (fromGroup || fellBack) supply.status.noteFailure(channel.id, position + 1 >= candidates.length);
|
|
1855
2176
|
yield {
|
|
1856
2177
|
type: "finish",
|
|
1857
2178
|
reason: {
|
|
1858
2179
|
kind: "error",
|
|
1859
2180
|
failure: {
|
|
1860
|
-
message: describeFailure(failure, tried, emitted),
|
|
2181
|
+
message: describeFailure(failure, tried, emitted, !fromGroup),
|
|
1861
2182
|
code
|
|
1862
2183
|
}
|
|
1863
2184
|
}
|
|
@@ -1875,18 +2196,26 @@ var AnyDeepSeekAdapter = class extends LlmAdapter {
|
|
|
1875
2196
|
/**
|
|
1876
2197
|
* Turn a terminal failure into the message the user reads.
|
|
1877
2198
|
*
|
|
1878
|
-
* ๐ด The attempt trail is appended only when
|
|
1879
|
-
*
|
|
1880
|
-
*
|
|
2199
|
+
* ๐ด The attempt trail is appended only when more than one supplier was tried. A single-attempt
|
|
2200
|
+
* failure gains nothing from "tried: X" โ the user already knows which supplier was live โ and
|
|
2201
|
+
* adding it unconditionally would bury the real error under routing noise.
|
|
2202
|
+
*
|
|
2203
|
+
* โ ๏ธ **Which sentence is used is not cosmetic** (2026-11-19). A request that started on a plain
|
|
2204
|
+
* channel and fell back says "every supply-group member failed" only if the CHOSEN channel is also
|
|
2205
|
+
* mentioned โ otherwise the reader sees a trail beginning with a channel they picked and a claim
|
|
2206
|
+
* about group members, and concludes the group was selected all along.
|
|
1881
2207
|
* @param failure - the last attempt's error.
|
|
1882
2208
|
* @param tried - every attempt, in order.
|
|
1883
2209
|
* @param emitted - whether content had already reached the consumer.
|
|
2210
|
+
* @param startedOnChannel - whether the request began on a directly selected channel (not the group).
|
|
1884
2211
|
* @returns the message to send to the harness.
|
|
1885
2212
|
*/
|
|
1886
|
-
function describeFailure(failure, tried, emitted) {
|
|
2213
|
+
function describeFailure(failure, tried, emitted, startedOnChannel) {
|
|
1887
2214
|
if (tried.length <= 1) return failure.message;
|
|
1888
2215
|
const trail = tried.map((attempt) => `${attempt.label}(${attempt.code})`).join(" โ ");
|
|
1889
|
-
|
|
2216
|
+
if (emitted) return `${failure.message} โ already streaming from ${tried[tried.length - 1].label}, so the group did not switch (tried: ${trail})`;
|
|
2217
|
+
if (startedOnChannel) return `${failure.message} โ your selected channel and every supply-group member failed (tried: ${trail})`;
|
|
2218
|
+
return `${failure.message} โ every supply-group member failed (tried: ${trail})`;
|
|
1890
2219
|
}
|
|
1891
2220
|
/** Turn a routing failure into a terminal chunk. */
|
|
1892
2221
|
function failureChunk(failure) {
|
|
@@ -3132,6 +3461,14 @@ function apply(ctx, config) {
|
|
|
3132
3461
|
*/
|
|
3133
3462
|
const supplyStatus = new SupplyStatus();
|
|
3134
3463
|
/**
|
|
3464
|
+
* The one quota-cooldown map for this plugin instance.
|
|
3465
|
+
*
|
|
3466
|
+
* ๐ด Owner decision 2026-11-19: a member that answers "out of credit" is moved to the BACK of the
|
|
3467
|
+
* walk for 30 minutes instead of being retried first on every request. Measured: two dry members
|
|
3468
|
+
* in front of a healthy one cost โ0.55 s of dead time per request.
|
|
3469
|
+
*/
|
|
3470
|
+
const cooldown = new QuotaCooldown();
|
|
3471
|
+
/**
|
|
3135
3472
|
* The supply group, read fresh each request.
|
|
3136
3473
|
*
|
|
3137
3474
|
* `members` is read from the live config (not captured at apply time) for the same reason
|
|
@@ -3185,6 +3522,7 @@ function apply(ctx, config) {
|
|
|
3185
3522
|
channels,
|
|
3186
3523
|
current,
|
|
3187
3524
|
supply,
|
|
3525
|
+
cooldown,
|
|
3188
3526
|
resolveKey,
|
|
3189
3527
|
readImage,
|
|
3190
3528
|
record: makeRecorder(ctx, config),
|
|
@@ -3219,16 +3557,37 @@ function apply(ctx, config) {
|
|
|
3219
3557
|
const live = channels();
|
|
3220
3558
|
const known = new Set(live.map((channel) => channel.id));
|
|
3221
3559
|
const order = members.filter((id) => known.has(id));
|
|
3222
|
-
const
|
|
3560
|
+
const selection = current() ?? "";
|
|
3561
|
+
const serving = status.servingUnder(selection);
|
|
3223
3562
|
const position = serving === void 0 ? -1 : order.indexOf(serving);
|
|
3224
3563
|
const last = status.lastSwitch;
|
|
3225
3564
|
const lastTried = status.lastTried;
|
|
3565
|
+
cooldown.bind(members);
|
|
3566
|
+
/**
|
|
3567
|
+
* Members currently skipped because they answered "out of credit" within the window.
|
|
3568
|
+
*
|
|
3569
|
+
* ๐ด Owner decision 2026-11-19 (30 minutes). This is the fact that makes the skip honest:
|
|
3570
|
+
* a reordering the user did not ask for must be visible, or the panel would be describing a
|
|
3571
|
+
* priority order the router is not using. `retryInMs` is computed server-side so the reading
|
|
3572
|
+
* does not depend on the browser's clock.
|
|
3573
|
+
*/
|
|
3574
|
+
const cooling = cooldown.active(Date.now());
|
|
3226
3575
|
return {
|
|
3227
3576
|
members,
|
|
3228
3577
|
dangling: members.filter((id) => !known.has(id)),
|
|
3229
3578
|
...serving === void 0 ? {} : { serving },
|
|
3230
3579
|
position,
|
|
3231
3580
|
exhausted: status.isExhausted,
|
|
3581
|
+
...cooling.length === 0 ? {} : { cooling },
|
|
3582
|
+
/**
|
|
3583
|
+
* ๐ด Whether the last successful request left the CHOSEN channel for this member.
|
|
3584
|
+
*
|
|
3585
|
+
* With a plain channel selected, the sidebar must say ใๆฒกไฝ้ข๏ผๅทฒ่ชๅจๅๅฐไพๅบ็ป ยท Xใ rather
|
|
3586
|
+
* than naming X as if the user had picked it. Two facts are needed together and neither
|
|
3587
|
+
* is enough alone, so both travel: `servedByFallback` says WHY, `isMember` confirms the
|
|
3588
|
+
* served channel really is one of the group's.
|
|
3589
|
+
*/
|
|
3590
|
+
viaFallback: status.servedByFallback && status.isMember(serving),
|
|
3232
3591
|
...lastTried === void 0 ? {} : { lastTried },
|
|
3233
3592
|
...last === void 0 ? {} : { lastSwitch: last }
|
|
3234
3593
|
};
|
package/lib/route.d.ts
CHANGED
|
@@ -82,6 +82,25 @@ export type RouteResult = {
|
|
|
82
82
|
* @returns the selected channel plus its ordered alternates, or the reason there is none.
|
|
83
83
|
*/
|
|
84
84
|
export declare function selectChannel(channels: readonly ResolvedChannel[], current: string | undefined, groupMembers?: readonly string[]): RouteResult;
|
|
85
|
+
/**
|
|
86
|
+
* The supply group's members, resolved and ordered: the ONE definition of "who is in the group".
|
|
87
|
+
*
|
|
88
|
+
* ๐ด Extracted for the safety-net path (2026-11-19). Two callers now need it โ the router, which
|
|
89
|
+
* needs a head plus alternates, and the adapter's fallback, which needs the ordered ids to append
|
|
90
|
+
* to a single-channel request that ran out of credit. If each derived the order itself they would
|
|
91
|
+
* eventually disagree about what "priority 1" means, and the disagreement would be invisible: both
|
|
92
|
+
* would look correct on their own.
|
|
93
|
+
*
|
|
94
|
+
* Dangling ids are dropped here and nowhere else, and the caller is told which ones โ the panel
|
|
95
|
+
* lists them, because a group that quietly shrinks is how "three relays" becomes "one relay".
|
|
96
|
+
* @param channels - every resolved channel.
|
|
97
|
+
* @param members - the configured ordered member ids; index 0 is the highest priority.
|
|
98
|
+
* @returns the ordered resolvable channels, plus the member ids that resolve to nothing.
|
|
99
|
+
*/
|
|
100
|
+
export declare function groupMembers(channels: readonly ResolvedChannel[], members: readonly string[]): {
|
|
101
|
+
ordered: ResolvedChannel[];
|
|
102
|
+
dangling: string[];
|
|
103
|
+
};
|
|
85
104
|
/**
|
|
86
105
|
* Whether `current` names a channel that exists at all.
|
|
87
106
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-any-deepseek",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"description": "One DeepSeek V4.1 Flash provider for DeepSeek Harness: paste a key per channel, switch channels manually, token usage booked per real upstream.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|