dsh-any-deepseek 0.0.38 โ 0.0.40
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 +20 -2
- package/lib/failover.d.ts +123 -0
- package/lib/http.d.ts +18 -0
- package/lib/index.js +206 -3
- 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
|
@@ -371,7 +371,7 @@ window.__ModuleLoader__.load({
|
|
|
371
371
|
}
|
|
372
372
|
//#endregion
|
|
373
373
|
//#region \0ad-css:src/client/SettingsPage
|
|
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.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";
|
|
375
375
|
if (typeof document !== "undefined" && document.querySelector("style[data-ad-css=\"SettingsPage\"]") === null) {
|
|
376
376
|
const tag = document.createElement("style");
|
|
377
377
|
tag.setAttribute("data-ad-css", "SettingsPage");
|
|
@@ -894,6 +894,10 @@ window.__ModuleLoader__.load({
|
|
|
894
894
|
"๏ผ"
|
|
895
895
|
]
|
|
896
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
|
+
}),
|
|
897
901
|
supply !== void 0 && supply.dangling.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
898
902
|
className: "ad-rowDetail ad-groupDangling",
|
|
899
903
|
children: [
|
|
@@ -916,8 +920,17 @@ window.__ModuleLoader__.load({
|
|
|
916
920
|
children: members.map((id, index) => {
|
|
917
921
|
const row = rows.find((candidate) => candidate.id === id);
|
|
918
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;
|
|
919
932
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
920
|
-
className: `ad-groupMember${live ? " ad-groupMemberLive" : ""}`,
|
|
933
|
+
className: `ad-groupMember${live ? " ad-groupMemberLive" : ""}${cooling ? " ad-groupMemberCooling" : ""}`,
|
|
921
934
|
children: [
|
|
922
935
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
923
936
|
className: "ad-groupRank",
|
|
@@ -927,6 +940,11 @@ window.__ModuleLoader__.load({
|
|
|
927
940
|
className: "ad-groupName",
|
|
928
941
|
children: row?.label ?? `${id}๏ผๆพไธๅฐ๏ผ`
|
|
929
942
|
}),
|
|
943
|
+
cooling && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
944
|
+
className: "ad-groupCoolTag",
|
|
945
|
+
title: "ๅๆฅ่ฟใไฝ้ขไธ่ถณใ๏ผๆๆถๆๅฐๆๅ๏ผๅฐ็น่ชๅจๆขๅคๅๆฅ็ไฝ็ฝฎ",
|
|
946
|
+
children: "่ทณ่ฟไธญ"
|
|
947
|
+
}),
|
|
930
948
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
931
949
|
type: "button",
|
|
932
950
|
className: "ad-btn ad-btn-quiet",
|
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. */
|
|
@@ -220,3 +342,4 @@ export declare class SupplyStatus {
|
|
|
220
342
|
/** The member the last failed request gave up on; undefined when that request succeeded. */
|
|
221
343
|
get lastTried(): string | undefined;
|
|
222
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
|
@@ -867,6 +867,150 @@ function shouldFailover(code) {
|
|
|
867
867
|
return CHANNEL_UNUSABLE_CODES.has(code);
|
|
868
868
|
}
|
|
869
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
|
+
/**
|
|
870
1014
|
* Whether one failed attempt may be followed by another attempt on a DIFFERENT channel.
|
|
871
1015
|
*
|
|
872
1016
|
* Kept as a separate pure function rather than inlined in the dispatch loop for one reason:
|
|
@@ -1714,6 +1858,28 @@ function classifyFailure(message) {
|
|
|
1714
1858
|
if (message.stopReason === "aborted") return "ABORTED";
|
|
1715
1859
|
const text = `${message.errorMessage ?? ""} ${message.rawStopReason ?? ""}`.toLowerCase();
|
|
1716
1860
|
if (text.includes("401") || text.includes("403") || text.includes("unauthor") || text.includes("invalid api key")) return "AUTH";
|
|
1861
|
+
/**
|
|
1862
|
+
* ๐ด A SUBSCRIPTION cap, checked BEFORE the generic rate-limit test.
|
|
1863
|
+
*
|
|
1864
|
+
* Owner report (2026-11-22), with the live body: OpenCode Go answers
|
|
1865
|
+
* `{"type":"GoUsageLimitError","message":"OpenCode Go usage limit reached (weekly, resets in 1d 8h)โฆ"}`
|
|
1866
|
+
* with HTTP 429. It reads like a rate limit (429 + ใlimitใ), so it used to classify as
|
|
1867
|
+
* `RATE_LIMIT` โ and that is the one code this route asks the harness to retry 100 times. The
|
|
1868
|
+
* result was visible in the owner's screenshot: ใๆญฃๅจ้่ฏๆจกๅ่ฏทๆฑ (9/100) ยท ้่ฏๅปถ่ฟ 9329 ๆฏซ็งใ,
|
|
1869
|
+
* grinding through a quota that will not come back for a day and eight hours.
|
|
1870
|
+
*
|
|
1871
|
+
* Owner's ruling: ใ่ฟ็ง่งไธบๆฒกๆไฝ้ข ๆ ๆณ้่ฏๆขๅค็ใ โ it is `QUOTA`, not `RATE_LIMIT`. That single
|
|
1872
|
+
* reclassification fixes four things at once, which is why it is worth being precise about:
|
|
1873
|
+
* ยท the retry layer stops retrying it (`QUOTA` is not in `retryableCodes`);
|
|
1874
|
+
* ยท the supply group fails over to the next member (decision 95's switch set);
|
|
1875
|
+
* ยท the group SKIPS this member for 30 minutes (decision 100's cooldown);
|
|
1876
|
+
* ยท the balance row reads it as ใไฝ้ขไธ่ถณ๏ผๅฎๆต่ขซๆ๏ผใ instead of a transient blip.
|
|
1877
|
+
*
|
|
1878
|
+
* โ ๏ธ Positive keyword only, never "contains 429": an ordinary burst rate limit is also 429 and IS
|
|
1879
|
+
* worth retrying. `usage limit` / `usagelimit` name a spent allowance, which is what makes this
|
|
1880
|
+
* unrecoverable-by-waiting-in-seconds.
|
|
1881
|
+
*/
|
|
1882
|
+
if (text.includes("usagelimit") || text.includes("usage limit")) return "QUOTA";
|
|
1717
1883
|
if (text.includes("rate") && text.includes("limit")) return "RATE_LIMIT";
|
|
1718
1884
|
if (text.includes("quota") || text.includes("balance") || text.includes("credit")) return "QUOTA";
|
|
1719
1885
|
if (isContextWindowExceededError(text)) return "CONTEXT_WINDOW_EXCEEDED";
|
|
@@ -1840,10 +2006,25 @@ var AnyDeepSeekAdapter = class extends LlmAdapter {
|
|
|
1840
2006
|
return;
|
|
1841
2007
|
}
|
|
1842
2008
|
const head = selection.channel;
|
|
1843
|
-
/** Mutable on purpose: the safety net appends the group's members mid-request. */
|
|
1844
|
-
const candidates = [head, ...selection.alternates];
|
|
1845
2009
|
const fromGroup = selection.source.kind === "group";
|
|
1846
2010
|
/**
|
|
2011
|
+
* The walk order for THIS request.
|
|
2012
|
+
*
|
|
2013
|
+
* ๐ด Owner decision 2026-11-19 (`QUOTA_COOLDOWN_MS` = 30 min). Measured cost of the pure priority
|
|
2014
|
+
* order: two dry members in front of a healthy one made every request pay two serial HTTP
|
|
2015
|
+
* round-trips (253โ964 ms each) before the real attempt โ โ0.55 s of dead time per request
|
|
2016
|
+
* against a 4.6 s first token. The owner's instruction was to keep the priority order but stop
|
|
2017
|
+
* paying that toll on every call.
|
|
2018
|
+
*
|
|
2019
|
+
* โ ๏ธ Members in cooldown are moved to the BACK, never dropped (`orderWithCooldowns`): a group
|
|
2020
|
+
* whose every member is cooling must still route somewhere, or an optimisation has taken the
|
|
2021
|
+
* supplier offline. With nothing cooling this is byte-for-byte the configured order โ the exact
|
|
2022
|
+
* property 0.0.35 exists to guarantee.
|
|
2023
|
+
*/
|
|
2024
|
+
const cooling = this.deps.cooldown.coolingIds(this.deps.now().getTime());
|
|
2025
|
+
/** Mutable on purpose: the safety net appends the group's members mid-request. */
|
|
2026
|
+
const candidates = fromGroup ? orderWithCooldowns([head, ...selection.alternates], cooling).walk : [head];
|
|
2027
|
+
/**
|
|
1847
2028
|
* The supply group as an ordered fallback list, prepared BEFORE the first attempt.
|
|
1848
2029
|
*
|
|
1849
2030
|
* ๐ด Owner request 2026-11-19: ใๅฝไฝฟ็จ้ไพๅบ็ปๆธ ้ ็จๅฐๆ ่ดน็จๆถ ่ชๅจๅๆขๅฐไพๅบ็ปใ็ฎ็ๆฏ็กฎไฟ
|
|
@@ -1858,7 +2039,7 @@ var AnyDeepSeekAdapter = class extends LlmAdapter {
|
|
|
1858
2039
|
* group too; re-attempting it immediately would spend a guaranteed second refusal on the same
|
|
1859
2040
|
* dead account, which is not "ไพๅบไธไธญๆญ", it is a loop.
|
|
1860
2041
|
*/
|
|
1861
|
-
const groupFallback = fromGroup ? [] : groupMembers(this.deps.channels(), supply.members).ordered.filter((channel) => channel.id !== head.id);
|
|
2042
|
+
const groupFallback = fromGroup ? [] : orderWithCooldowns(groupMembers(this.deps.channels(), supply.members).ordered.filter((channel) => channel.id !== head.id), cooling).walk;
|
|
1862
2043
|
/** Whether the safety net has already fired for this request (it may fire at most once). */
|
|
1863
2044
|
let fellBack = false;
|
|
1864
2045
|
/** Every attempt this request made, for the message on total failure. */
|
|
@@ -1983,6 +2164,7 @@ var AnyDeepSeekAdapter = class extends LlmAdapter {
|
|
|
1983
2164
|
}
|
|
1984
2165
|
await record();
|
|
1985
2166
|
if (failure === void 0) {
|
|
2167
|
+
this.deps.cooldown.clear(channel.id);
|
|
1986
2168
|
supply.status.noteServed(channel.id, this.deps.current() ?? "", fellBack);
|
|
1987
2169
|
return;
|
|
1988
2170
|
}
|
|
@@ -1992,6 +2174,7 @@ var AnyDeepSeekAdapter = class extends LlmAdapter {
|
|
|
1992
2174
|
label: channel.label,
|
|
1993
2175
|
code
|
|
1994
2176
|
});
|
|
2177
|
+
if (shouldCoolDown(code)) this.deps.cooldown.noteQuota(channel.id, this.deps.now().getTime());
|
|
1995
2178
|
if (canSwitchAttempt({
|
|
1996
2179
|
code,
|
|
1997
2180
|
emitted,
|
|
@@ -3300,6 +3483,14 @@ function apply(ctx, config) {
|
|
|
3300
3483
|
*/
|
|
3301
3484
|
const supplyStatus = new SupplyStatus();
|
|
3302
3485
|
/**
|
|
3486
|
+
* The one quota-cooldown map for this plugin instance.
|
|
3487
|
+
*
|
|
3488
|
+
* ๐ด Owner decision 2026-11-19: a member that answers "out of credit" is moved to the BACK of the
|
|
3489
|
+
* walk for 30 minutes instead of being retried first on every request. Measured: two dry members
|
|
3490
|
+
* in front of a healthy one cost โ0.55 s of dead time per request.
|
|
3491
|
+
*/
|
|
3492
|
+
const cooldown = new QuotaCooldown();
|
|
3493
|
+
/**
|
|
3303
3494
|
* The supply group, read fresh each request.
|
|
3304
3495
|
*
|
|
3305
3496
|
* `members` is read from the live config (not captured at apply time) for the same reason
|
|
@@ -3353,6 +3544,7 @@ function apply(ctx, config) {
|
|
|
3353
3544
|
channels,
|
|
3354
3545
|
current,
|
|
3355
3546
|
supply,
|
|
3547
|
+
cooldown,
|
|
3356
3548
|
resolveKey,
|
|
3357
3549
|
readImage,
|
|
3358
3550
|
record: makeRecorder(ctx, config),
|
|
@@ -3392,12 +3584,23 @@ function apply(ctx, config) {
|
|
|
3392
3584
|
const position = serving === void 0 ? -1 : order.indexOf(serving);
|
|
3393
3585
|
const last = status.lastSwitch;
|
|
3394
3586
|
const lastTried = status.lastTried;
|
|
3587
|
+
cooldown.bind(members);
|
|
3588
|
+
/**
|
|
3589
|
+
* Members currently skipped because they answered "out of credit" within the window.
|
|
3590
|
+
*
|
|
3591
|
+
* ๐ด Owner decision 2026-11-19 (30 minutes). This is the fact that makes the skip honest:
|
|
3592
|
+
* a reordering the user did not ask for must be visible, or the panel would be describing a
|
|
3593
|
+
* priority order the router is not using. `retryInMs` is computed server-side so the reading
|
|
3594
|
+
* does not depend on the browser's clock.
|
|
3595
|
+
*/
|
|
3596
|
+
const cooling = cooldown.active(Date.now());
|
|
3395
3597
|
return {
|
|
3396
3598
|
members,
|
|
3397
3599
|
dangling: members.filter((id) => !known.has(id)),
|
|
3398
3600
|
...serving === void 0 ? {} : { serving },
|
|
3399
3601
|
position,
|
|
3400
3602
|
exhausted: status.isExhausted,
|
|
3603
|
+
...cooling.length === 0 ? {} : { cooling },
|
|
3401
3604
|
/**
|
|
3402
3605
|
* ๐ด Whether the last successful request left the CHOSEN channel for this member.
|
|
3403
3606
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-any-deepseek",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
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": {
|