dsh-any-deepseek 0.0.33 → 0.0.35
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 +39 -2
- package/lib/client.js +245 -10
- package/lib/config.d.ts +38 -3
- package/lib/failover.d.ts +126 -0
- package/lib/http.d.ts +39 -0
- package/lib/index.js +465 -166
- package/lib/route.d.ts +53 -21
- package/package.json +1 -1
package/lib/adapter.d.ts
CHANGED
|
@@ -30,6 +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
34
|
import type { LedgerEntry } from './usage-ledger.js';
|
|
34
35
|
/** The single provider route this plugin owns. */
|
|
35
36
|
export declare const PROVIDER_ID = "any-deepseek";
|
|
@@ -122,8 +123,20 @@ export declare function effectiveReasoningEfforts(channel: ResolvedChannel | und
|
|
|
122
123
|
export interface AdapterDeps {
|
|
123
124
|
/** Enabled, resolved channels in configuration order. */
|
|
124
125
|
channels: () => readonly ResolvedChannel[];
|
|
125
|
-
/** The configured channel id. */
|
|
126
|
+
/** The configured selection: a channel id, or {@link SUPPLY_GROUP_ID}. */
|
|
126
127
|
current: () => string | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* The supply group: its ordered members and the display-only status recorder.
|
|
130
|
+
*
|
|
131
|
+
* 🔴 **`status` never feeds routing.** The owner's rule is "always start at member 1", so the
|
|
132
|
+
* status object only records what happened (who served, what switched) for the panel to explain.
|
|
133
|
+
* It is passed here rather than read from the group because the group's member list is the only
|
|
134
|
+
* input a routing decision is allowed to depend on.
|
|
135
|
+
*/
|
|
136
|
+
supply: () => {
|
|
137
|
+
members: readonly string[];
|
|
138
|
+
status: SupplyStatus;
|
|
139
|
+
};
|
|
127
140
|
/**
|
|
128
141
|
* Resolve a credential REFERENCE name to its value; undefined when unconfigured.
|
|
129
142
|
*
|
|
@@ -356,8 +369,32 @@ export declare class AnyDeepSeekAdapter extends LlmAdapter {
|
|
|
356
369
|
* here is what stops a panel change from landing in the middle of a recorded step.
|
|
357
370
|
*/
|
|
358
371
|
prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
|
|
372
|
+
/**
|
|
373
|
+
* Stream one request, walking the supply group when a member cannot serve.
|
|
374
|
+
*
|
|
375
|
+
* ## The shape, and why it is a loop rather than recursion
|
|
376
|
+
*
|
|
377
|
+
* A request gets an ORDERED candidate list: the head (whatever `current` names, or the group's
|
|
378
|
+
* sticky member) plus, when the group is serving, every remaining member after it. Each round
|
|
379
|
+
* is one complete attempt — key, wire, stream, ledger line — and the loop only continues when
|
|
380
|
+
* the attempt failed in a way that says "this CHANNEL cannot serve" (`shouldFailover`) *and*
|
|
381
|
+
* nothing has been handed to the consumer yet.
|
|
382
|
+
*
|
|
383
|
+
* 🔴 **The "nothing emitted yet" precondition is not a nicety; without it this feature corrupts
|
|
384
|
+
* messages.** Once a chunk has been yielded it is gone — the harness has written it to the
|
|
385
|
+
* session and will show it to the user. Switching suppliers afterwards would concatenate two
|
|
386
|
+
* different models' output into one message, with no way to tell which sentence came from
|
|
387
|
+
* where. So a mid-stream failure is reported, never retried on another relay; only a failure
|
|
388
|
+
* that happened BEFORE the first chunk is switchable.
|
|
389
|
+
*
|
|
390
|
+
* ## Ledger: one line per ATTEMPT
|
|
391
|
+
*
|
|
392
|
+
* Not one per request. "This request cost 40k tokens at relay A and then 2k at relay B" is a
|
|
393
|
+
* fact about two accounts, and collapsing it into one line under B's name would make A's spend
|
|
394
|
+
* invisible — the exact class of silent miscount this ledger exists to prevent (decision 3).
|
|
395
|
+
*/
|
|
359
396
|
stream(options: GenerateOptions): AsyncGenerator<StreamChunk>;
|
|
360
|
-
/** The channel the
|
|
397
|
+
/** The channel that will serve the next request, if any (used for model metadata). */
|
|
361
398
|
private selected;
|
|
362
399
|
}
|
|
363
400
|
/** Re-export the credential helper so callers build references the same way the adapter does. */
|
package/lib/client.js
CHANGED
|
@@ -8,20 +8,36 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
//#region src/client/panel-api.ts
|
|
10
10
|
/**
|
|
11
|
-
* The
|
|
11
|
+
* The `current` sentinel meaning "the supply group serves requests".
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ Must match `SUPPLY_GROUP_ID` in `src/config.ts`. It is duplicated rather than imported
|
|
14
|
+
* because that module pulls in schemastery and the node runtime; the client bundle must not carry
|
|
15
|
+
* either. The value is asserted in a test so the two cannot drift silently.
|
|
16
|
+
*/
|
|
17
|
+
const SUPPLY_GROUP_ID = "__group__";
|
|
18
|
+
/**
|
|
19
|
+
* The label the sidebar shows for the live supplier.
|
|
12
20
|
*
|
|
13
21
|
* 🔴 Owner request 2026-11-03: the sidebar should name the live provider so it does not require
|
|
14
22
|
* opening Settings. Owner constraint the same day: 「左下角空间小,字少点,表意明确即可」 — the seat is
|
|
15
23
|
* 256px wide and already carries a usage figure, so this returns the SHORTEST true sentence:
|
|
16
24
|
* just the channel's own label, with no 「当前供应商:」 prefix on every line.
|
|
17
25
|
*
|
|
18
|
-
*
|
|
26
|
+
* 🟢 Owner request 2026-11-12 extended this to the supply group (「给用户供应组是一种选择的感觉」):
|
|
27
|
+
* when the group is serving, the answer is not one channel but "the group, currently on X". That
|
|
28
|
+
* fact is shown as `供应组 · <label>` — 4 characters of prefix, which fits the 256px seat, and names
|
|
29
|
+
* BOTH truths: a group is in charge, and this is who it is talking to right now.
|
|
30
|
+
*
|
|
31
|
+
* Four states, kept distinct for the same reason the balance row does it:
|
|
32
|
+
* · `供应组 · 名字` when the group serves and its current member resolves;
|
|
33
|
+
* · `供应组 · 全部不可用` when the last request exhausted the list — 🔴 a SEPARATE state, because
|
|
34
|
+
* without it the panel printed 「正在使用:C」 while nobody was serving;
|
|
35
|
+
* · `供应组` alone when the group is selected but nothing has served yet;
|
|
19
36
|
* · a label when a channel is selected and found;
|
|
20
37
|
* · `undefined` when nothing is selected — the caller renders nothing, because "no provider" is
|
|
21
38
|
* already visible as the model picker being unset and a red line here would be noise;
|
|
22
|
-
* · `未找到` when `current` names a channel that no longer exists. That one IS worth a word:
|
|
23
|
-
*
|
|
24
|
-
* something gone and only they can fix it.
|
|
39
|
+
* · `未找到` when `current` names a channel that no longer exists. That one IS worth a word: only
|
|
40
|
+
* the user can fix a dangling selection.
|
|
25
41
|
* @param response - the `/channels` body, or undefined before it loads.
|
|
26
42
|
* @returns the short label, or undefined when there is nothing to say.
|
|
27
43
|
*/
|
|
@@ -29,6 +45,14 @@ window.__ModuleLoader__.load({
|
|
|
29
45
|
if (response === void 0) return void 0;
|
|
30
46
|
const id = response.current;
|
|
31
47
|
if (id === void 0 || id === "") return void 0;
|
|
48
|
+
if (id === "__group__") {
|
|
49
|
+
const supply = response.supply;
|
|
50
|
+
if (supply?.exhausted === true) return "供应组 · 全部不可用";
|
|
51
|
+
const serving = supply?.serving;
|
|
52
|
+
if (serving === void 0) return "供应组";
|
|
53
|
+
const channel = response.channels.find((candidate) => candidate.id === serving);
|
|
54
|
+
return channel === void 0 ? "供应组" : `供应组 · ${channel.label}`;
|
|
55
|
+
}
|
|
32
56
|
const channel = response.channels.find((candidate) => candidate.id === id);
|
|
33
57
|
return channel === void 0 ? "未找到" : channel.label;
|
|
34
58
|
}
|
|
@@ -318,7 +342,7 @@ window.__ModuleLoader__.load({
|
|
|
318
342
|
}
|
|
319
343
|
//#endregion
|
|
320
344
|
//#region \0ad-css:src/client/SettingsPage
|
|
321
|
-
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 * 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";
|
|
345
|
+
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";
|
|
322
346
|
if (typeof document !== "undefined" && document.querySelector("style[data-ad-css=\"SettingsPage\"]") === null) {
|
|
323
347
|
const tag = document.createElement("style");
|
|
324
348
|
tag.setAttribute("data-ad-css", "SettingsPage");
|
|
@@ -419,6 +443,21 @@ window.__ModuleLoader__.load({
|
|
|
419
443
|
const [probing, setProbing] = (0, react.useState)(null);
|
|
420
444
|
const [verdict, setVerdict] = (0, react.useState)({});
|
|
421
445
|
const [error, setError] = (0, react.useState)(null);
|
|
446
|
+
/**
|
|
447
|
+
* The supply group's live state from `/channels` (members, who served last, last switch).
|
|
448
|
+
*
|
|
449
|
+
* 🔴 Kept SEPARATE from `rows` and from the settings document on purpose. `rows` is "what
|
|
450
|
+
* channels exist"; `supplyGroup.members` in the settings document is "what the user configured";
|
|
451
|
+
* this is "what the router is actually doing". The panel needs all three to explain a fallback
|
|
452
|
+
* ("member 1 ran out of quota, so requests now go to member 2") — merge any two and the third
|
|
453
|
+
* question becomes unanswerable.
|
|
454
|
+
*
|
|
455
|
+
* ⚠️ There is no cursor and therefore no reset: every request starts at member 1 (owner rule
|
|
456
|
+
* 2026-11-12), so a position is derived from the priority list and never remembered.
|
|
457
|
+
*/
|
|
458
|
+
const [supply, setSupply] = (0, react.useState)(void 0);
|
|
459
|
+
/** Which channel id the group editor is offering to append (empty = picker closed). */
|
|
460
|
+
const [addingMember, setAddingMember] = (0, react.useState)("");
|
|
422
461
|
/** The "add a channel" form. Collapsed until asked for — an empty panel is not a form. */
|
|
423
462
|
const [adding, setAdding] = (0, react.useState)(false);
|
|
424
463
|
const [newId, setNewId] = (0, react.useState)("");
|
|
@@ -457,6 +496,7 @@ window.__ModuleLoader__.load({
|
|
|
457
496
|
setRows(loaded.channels);
|
|
458
497
|
setPresets(loaded.presets);
|
|
459
498
|
setModel(loaded.model);
|
|
499
|
+
setSupply(loaded.supply);
|
|
460
500
|
setStats(statsNow);
|
|
461
501
|
}, [
|
|
462
502
|
loadChannels,
|
|
@@ -487,10 +527,47 @@ window.__ModuleLoader__.load({
|
|
|
487
527
|
});
|
|
488
528
|
}, [refresh]);
|
|
489
529
|
const current = settings.value?.current ?? "";
|
|
530
|
+
/** Whether the supply group is the selected supplier — ONE fact, read from ONE field. */
|
|
531
|
+
const groupSelected = current === SUPPLY_GROUP_ID;
|
|
532
|
+
/** The configured member list, as this panel last read it from the settings document. */
|
|
533
|
+
const members = (() => {
|
|
534
|
+
const raw = settings.value?.supplyGroup?.members;
|
|
535
|
+
return Array.isArray(raw) ? raw.filter((id) => typeof id === "string") : [];
|
|
536
|
+
})();
|
|
490
537
|
const select = (id) => {
|
|
491
538
|
write(() => setField(["current"], id));
|
|
492
539
|
};
|
|
493
540
|
/**
|
|
541
|
+
* Write the whole member list.
|
|
542
|
+
*
|
|
543
|
+
* One write per edit, and the list is replaced WHOLE rather than patched index by index:
|
|
544
|
+
* `members` is an ordered array, so a per-index write could interleave with a concurrent read
|
|
545
|
+
* (the same revision-conflict shape that produced decision 85) and leave the order scrambled.
|
|
546
|
+
* @param next - the complete new order.
|
|
547
|
+
*/
|
|
548
|
+
const writeMembers = (next) => {
|
|
549
|
+
write(() => setField(["supplyGroup", "members"], [...next]), "保存供应组失败");
|
|
550
|
+
};
|
|
551
|
+
/** Move one member one position earlier or later. */
|
|
552
|
+
const moveMember = (index, delta) => {
|
|
553
|
+
const target = index + delta;
|
|
554
|
+
if (target < 0 || target >= members.length) return;
|
|
555
|
+
const next = [...members];
|
|
556
|
+
const [item] = next.splice(index, 1);
|
|
557
|
+
next.splice(target, 0, item);
|
|
558
|
+
writeMembers(next);
|
|
559
|
+
};
|
|
560
|
+
/**
|
|
561
|
+
* Switch the supplier: the group, or one channel.
|
|
562
|
+
*
|
|
563
|
+
* 🔴 Both arms write the SAME field (`current`) — that is the whole point of the sentinel design.
|
|
564
|
+
* Writing the group means "the group serves", and every channel row stops being the selection in
|
|
565
|
+
* exactly the way it already does when a different channel is picked.
|
|
566
|
+
*/
|
|
567
|
+
const selectGroup = () => {
|
|
568
|
+
write(() => setField(["current"], SUPPLY_GROUP_ID), "启用供应组失败");
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
494
571
|
* Run one settings write and surface a refusal.
|
|
495
572
|
*
|
|
496
573
|
* A write can be refused for reasons the user can act on (read-only deployment, the settings
|
|
@@ -711,11 +788,169 @@ window.__ModuleLoader__.load({
|
|
|
711
788
|
className: "ad-empty",
|
|
712
789
|
children: "还没有渠道。点下面的「添加渠道」,选一个规格、粘一个 key 就能用。"
|
|
713
790
|
}),
|
|
714
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
791
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
|
|
715
792
|
className: "ad-rows",
|
|
716
793
|
role: "radiogroup",
|
|
717
|
-
"aria-label": "
|
|
718
|
-
children:
|
|
794
|
+
"aria-label": "选择当前供应商",
|
|
795
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
796
|
+
className: `ad-row ad-groupRow${groupSelected ? " ad-row-current" : ""}`,
|
|
797
|
+
"aria-current": groupSelected ? "true" : void 0,
|
|
798
|
+
"data-current": groupSelected ? "true" : "false",
|
|
799
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
800
|
+
className: "ad-rowPick",
|
|
801
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
802
|
+
type: "radio",
|
|
803
|
+
name: "ad-current-channel",
|
|
804
|
+
checked: groupSelected,
|
|
805
|
+
onChange: () => selectGroup()
|
|
806
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
807
|
+
className: "ad-rowMain",
|
|
808
|
+
children: [
|
|
809
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
810
|
+
className: "ad-rowTitleLine",
|
|
811
|
+
children: [
|
|
812
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
813
|
+
className: "ad-rowTitle",
|
|
814
|
+
children: "供应组"
|
|
815
|
+
}),
|
|
816
|
+
groupSelected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
817
|
+
className: "ad-badge",
|
|
818
|
+
children: "当前"
|
|
819
|
+
}),
|
|
820
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
821
|
+
className: "ad-groupCount",
|
|
822
|
+
children: members.length > 0 ? `${members.length} 个渠道` : "未配置"
|
|
823
|
+
})
|
|
824
|
+
]
|
|
825
|
+
}),
|
|
826
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
827
|
+
className: "ad-rowDetail",
|
|
828
|
+
children: "按下面的顺序使用:每次请求都从第 1 位开始试,遇到余额不足或密钥失效才换下一位"
|
|
829
|
+
}),
|
|
830
|
+
groupSelected && supply?.exhausted === true && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
831
|
+
className: "ad-rowDetail ad-groupLive ad-groupLiveBad",
|
|
832
|
+
children: [
|
|
833
|
+
"全组均不可用(最后一个试的是",
|
|
834
|
+
supply.lastTried === void 0 ? "—" : rows.find((row) => row.id === supply.lastTried)?.label ?? supply.lastTried,
|
|
835
|
+
")"
|
|
836
|
+
]
|
|
837
|
+
}),
|
|
838
|
+
groupSelected && supply?.exhausted !== true && supply?.serving !== void 0 && supply.position >= 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
839
|
+
className: "ad-rowDetail ad-groupLive",
|
|
840
|
+
children: [
|
|
841
|
+
"正在使用:",
|
|
842
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: rows.find((row) => row.id === supply.serving)?.label ?? supply.serving }),
|
|
843
|
+
"(第 ",
|
|
844
|
+
supply.position + 1,
|
|
845
|
+
" 位)"
|
|
846
|
+
]
|
|
847
|
+
}),
|
|
848
|
+
groupSelected && supply?.lastSwitch !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
849
|
+
className: "ad-rowDetail ad-groupSwitch",
|
|
850
|
+
children: [
|
|
851
|
+
"最近切换:",
|
|
852
|
+
rows.find((row) => row.id === supply.lastSwitch.from)?.label ?? supply.lastSwitch.from,
|
|
853
|
+
" → ",
|
|
854
|
+
rows.find((row) => row.id === supply.lastSwitch.to)?.label ?? supply.lastSwitch.to,
|
|
855
|
+
"(",
|
|
856
|
+
supply.lastSwitch.code,
|
|
857
|
+
")"
|
|
858
|
+
]
|
|
859
|
+
}),
|
|
860
|
+
supply !== void 0 && supply.dangling.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
861
|
+
className: "ad-rowDetail ad-groupDangling",
|
|
862
|
+
children: [
|
|
863
|
+
"找不到这些渠道:",
|
|
864
|
+
supply.dangling.join("、"),
|
|
865
|
+
"(已跳过)"
|
|
866
|
+
]
|
|
867
|
+
})
|
|
868
|
+
]
|
|
869
|
+
})]
|
|
870
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
871
|
+
className: "ad-groupEditor",
|
|
872
|
+
children: [
|
|
873
|
+
members.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
874
|
+
className: "ad-empty",
|
|
875
|
+
children: "还没放渠道进来。选一个渠道加进来,就会按下面的顺序依次使用。"
|
|
876
|
+
}),
|
|
877
|
+
members.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
|
|
878
|
+
className: "ad-groupMembers",
|
|
879
|
+
children: members.map((id, index) => {
|
|
880
|
+
const row = rows.find((candidate) => candidate.id === id);
|
|
881
|
+
const live = groupSelected && supply?.serving === id;
|
|
882
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
883
|
+
className: `ad-groupMember${live ? " ad-groupMemberLive" : ""}`,
|
|
884
|
+
children: [
|
|
885
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
886
|
+
className: "ad-groupRank",
|
|
887
|
+
children: index + 1
|
|
888
|
+
}),
|
|
889
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
890
|
+
className: "ad-groupName",
|
|
891
|
+
children: row?.label ?? `${id}(找不到)`
|
|
892
|
+
}),
|
|
893
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
894
|
+
type: "button",
|
|
895
|
+
className: "ad-btn ad-btn-quiet",
|
|
896
|
+
disabled: index === 0,
|
|
897
|
+
title: "往上移(更优先)",
|
|
898
|
+
onClick: () => moveMember(index, -1),
|
|
899
|
+
children: "↑"
|
|
900
|
+
}),
|
|
901
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
902
|
+
type: "button",
|
|
903
|
+
className: "ad-btn ad-btn-quiet",
|
|
904
|
+
disabled: index === members.length - 1,
|
|
905
|
+
title: "往下移(更靠后)",
|
|
906
|
+
onClick: () => moveMember(index, 1),
|
|
907
|
+
children: "↓"
|
|
908
|
+
}),
|
|
909
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
910
|
+
type: "button",
|
|
911
|
+
className: "ad-btn ad-btn-danger",
|
|
912
|
+
title: "移出供应组(不删除渠道本身)",
|
|
913
|
+
onClick: () => writeMembers(members.filter((candidate) => candidate !== id)),
|
|
914
|
+
children: "移出"
|
|
915
|
+
})
|
|
916
|
+
]
|
|
917
|
+
}, id);
|
|
918
|
+
})
|
|
919
|
+
}),
|
|
920
|
+
(() => {
|
|
921
|
+
const addable = rows.filter((row) => !members.includes(row.id));
|
|
922
|
+
if (addable.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
923
|
+
className: "ad-hint",
|
|
924
|
+
children: "所有渠道都已在供应组里。"
|
|
925
|
+
});
|
|
926
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
927
|
+
className: "ad-groupAdd",
|
|
928
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
929
|
+
className: "ad-input",
|
|
930
|
+
value: addingMember,
|
|
931
|
+
onChange: (event) => setAddingMember(event.target.value),
|
|
932
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
933
|
+
value: "",
|
|
934
|
+
children: "选一个渠道加进来…"
|
|
935
|
+
}), addable.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
936
|
+
value: row.id,
|
|
937
|
+
children: row.label
|
|
938
|
+
}, row.id))]
|
|
939
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
940
|
+
type: "button",
|
|
941
|
+
className: "ad-btn",
|
|
942
|
+
disabled: addingMember === "",
|
|
943
|
+
onClick: () => {
|
|
944
|
+
writeMembers([...members, addingMember]);
|
|
945
|
+
setAddingMember("");
|
|
946
|
+
},
|
|
947
|
+
children: "加进来"
|
|
948
|
+
})]
|
|
949
|
+
});
|
|
950
|
+
})()
|
|
951
|
+
]
|
|
952
|
+
})]
|
|
953
|
+
}), rows.map((row) => {
|
|
719
954
|
const isCurrent = current === row.id;
|
|
720
955
|
const probeResult = verdict[row.id];
|
|
721
956
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
@@ -814,7 +1049,7 @@ window.__ModuleLoader__.load({
|
|
|
814
1049
|
]
|
|
815
1050
|
})]
|
|
816
1051
|
}, row.id);
|
|
817
|
-
})
|
|
1052
|
+
})]
|
|
818
1053
|
}),
|
|
819
1054
|
adding ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
820
1055
|
className: "ad-addForm",
|
package/lib/config.d.ts
CHANGED
|
@@ -27,13 +27,33 @@
|
|
|
27
27
|
*
|
|
28
28
|
* ## Why `fallback` exists but nothing reads it
|
|
29
29
|
*
|
|
30
|
-
* v1
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
* v1 selected one channel and did not fail over (owner decision 2026-10-19). Failover arrived on
|
|
31
|
+
* 2026-11-12 as the **supply group** (`supplyGroup.members`) at the owner's request, and it is
|
|
32
|
+
* deliberately NOT built on `fallback`: the group is one ordered list the user edits, whereas
|
|
33
|
+
* `fallback` was an unordered per-channel hint that nothing ever populated. `fallback` stays
|
|
34
|
+
* declared-and-unread as the honest record of a shape we decided not to use — deleting it would
|
|
35
|
+
* make an old configuration containing it fail schema validation.
|
|
33
36
|
*/
|
|
34
37
|
import type { Volatile } from '@deepseek-ai/cordis';
|
|
35
38
|
/** Nameable schema type; see the TS2742 note in the file header. */
|
|
36
39
|
type SchemaOf<S, T = S> = Schemastery<S, T>;
|
|
40
|
+
/**
|
|
41
|
+
* The sentinel `current` value that means "the supply group serves requests".
|
|
42
|
+
*
|
|
43
|
+
* 🔴 **Why a sentinel value instead of an `enabled` flag** — this is the load-bearing decision of
|
|
44
|
+
* the whole feature. "Which supplier is live" must be answerable from ONE field. A separate
|
|
45
|
+
* `supplyGroup.enabled` would let the document say two contradictory things:
|
|
46
|
+
* `enabled: true` with `current: 'opencode-go'` (which one wins?) and
|
|
47
|
+
* `enabled: false` with nothing selected (did the user turn the group off, or never pick a channel?).
|
|
48
|
+
* The panel would then need rules to reconcile the pair, and those rules would be the new bug
|
|
49
|
+
* surface. The old per-channel `enabled` flag was retired for exactly this reason (`channels.ts`).
|
|
50
|
+
*
|
|
51
|
+
* The value is deliberately not a valid channel id: `__group__` fails `^[a-z0-9][a-z0-9_-]*$`
|
|
52
|
+
* (leading underscore, and the panel's id validator rejects it), so it can never collide with a
|
|
53
|
+
* real channel — a collision would make "the group is on" indistinguishable from "a channel named
|
|
54
|
+
* `__group__` is on".
|
|
55
|
+
*/
|
|
56
|
+
export declare const SUPPLY_GROUP_ID = "__group__";
|
|
37
57
|
/** One channel entry as a user writes it (schema INPUT). */
|
|
38
58
|
export interface ChannelConfigInput {
|
|
39
59
|
label?: string;
|
|
@@ -104,6 +124,17 @@ export interface UsageConfigValue {
|
|
|
104
124
|
enabled?: boolean;
|
|
105
125
|
path?: string;
|
|
106
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* The supply group: an ordered member list.
|
|
129
|
+
*
|
|
130
|
+
* ⚠️ **The INPUT side must use a mutable `string[]`.** schemastery derives the input type from
|
|
131
|
+
* `z.array(z.string())` as `string[]`, so declaring `readonly string[]` here makes the schema
|
|
132
|
+
* unassignable to its own annotation (measured: TS2322 on `PluginConfigSchema`). The OUTPUT side
|
|
133
|
+
* is the one that is readonly, because that is what the schema actually produces.
|
|
134
|
+
*/
|
|
135
|
+
export interface SupplyGroupConfig {
|
|
136
|
+
members?: string[];
|
|
137
|
+
}
|
|
107
138
|
/** Ledger settings schema. */
|
|
108
139
|
export declare const UsageConfigSchema: SchemaOf<UsageConfigValue>;
|
|
109
140
|
/**
|
|
@@ -114,6 +145,7 @@ export declare const UsageConfigSchema: SchemaOf<UsageConfigValue>;
|
|
|
114
145
|
export interface PluginConfigInput {
|
|
115
146
|
channels?: Record<string, ChannelConfigInput>;
|
|
116
147
|
current?: string;
|
|
148
|
+
supplyGroup?: SupplyGroupConfig;
|
|
117
149
|
usage?: UsageConfigValue;
|
|
118
150
|
fallback?: string[];
|
|
119
151
|
}
|
|
@@ -129,6 +161,9 @@ export interface PluginConfigInput {
|
|
|
129
161
|
export interface PluginConfigValue {
|
|
130
162
|
channels: Volatile<Record<string, ChannelConfigValue>>;
|
|
131
163
|
current: Volatile<string>;
|
|
164
|
+
supplyGroup: Volatile<{
|
|
165
|
+
readonly members: readonly string[];
|
|
166
|
+
}>;
|
|
132
167
|
usage: UsageConfigValue;
|
|
133
168
|
fallback: string[];
|
|
134
169
|
}
|