dsh-fallback-router 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +162 -2
- package/README.zh-CN.md +170 -0
- package/bundle/cordis.patch.yml +19 -0
- package/dist/authorized-route.d.ts +68 -0
- package/dist/automatch.d.ts +98 -0
- package/dist/chains.d.ts +186 -0
- package/dist/client/ConversationFallbackSwitch.d.ts +91 -0
- package/dist/client/FallbacksCard.d.ts +36 -0
- package/dist/client/GeneralFallbacksRow.d.ts +19 -0
- package/dist/client/ModelsPanel.d.ts +64 -0
- package/dist/client/SubagentRoleBadge.d.ts +53 -0
- package/dist/client/fallbacks-store.d.ts +631 -0
- package/dist/client/index.d.ts +64 -0
- package/dist/client/index.js +3420 -0
- package/dist/client/locales.d.ts +454 -0
- package/dist/client/switch-guard.d.ts +17 -0
- package/dist/client/use-snapshot.d.ts +11 -0
- package/dist/commands.d.ts +380 -0
- package/dist/config.d.ts +239 -0
- package/dist/cooldown.d.ts +57 -0
- package/dist/events.d.ts +52 -0
- package/dist/gateway.d.ts +359 -0
- package/dist/index.d.ts +195 -0
- package/dist/index.js +4587 -0
- package/dist/models.d.ts +306 -0
- package/dist/override.d.ts +39 -0
- package/dist/presets.d.ts +20 -0
- package/dist/recovery.d.ts +92 -0
- package/dist/role-notice.d.ts +184 -0
- package/dist/role-persona.d.ts +71 -0
- package/dist/role-projection-key.d.ts +41 -0
- package/dist/role-projection.d.ts +152 -0
- package/dist/role-resolution.d.ts +105 -0
- package/dist/roles.d.ts +90 -0
- package/dist/route-allowlist.d.ts +43 -0
- package/dist/schema.d.ts +46 -0
- package/dist/seeds.d.ts +237 -0
- package/dist/selectors.d.ts +38 -0
- package/dist/state.d.ts +205 -0
- package/dist/subagent-policy.d.ts +123 -0
- package/dist/subagents-seam.d.ts +305 -0
- package/dist/time-slots.d.ts +147 -0
- package/dist/tui-settings.d.ts +145 -0
- package/dist/tui.d.ts +63 -0
- package/dist/virtual-adapter.d.ts +259 -0
- package/icon.svg +16 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +138 -6
|
@@ -0,0 +1,3420 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-fallback-router",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
//#endregion
|
|
10
|
+
let react = require("react");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
|
|
13
|
+
//#region ../Artifacts/dsh-llm-router/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
|
|
14
|
+
/**
|
|
15
|
+
* @license React
|
|
16
|
+
* use-sync-external-store-shim.production.js
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/
|
|
23
|
+
var require_use_sync_external_store_shim_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
24
|
+
var React$1 = require("react");
|
|
25
|
+
function is(x, y) {
|
|
26
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
27
|
+
}
|
|
28
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
|
29
|
+
var useState = React$1.useState;
|
|
30
|
+
var useEffect = React$1.useEffect;
|
|
31
|
+
var useLayoutEffect = React$1.useLayoutEffect;
|
|
32
|
+
var useDebugValue = React$1.useDebugValue;
|
|
33
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
34
|
+
var value = getSnapshot(), _useState = useState({ inst: {
|
|
35
|
+
value,
|
|
36
|
+
getSnapshot
|
|
37
|
+
} }), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
38
|
+
useLayoutEffect(function() {
|
|
39
|
+
inst.value = value;
|
|
40
|
+
inst.getSnapshot = getSnapshot;
|
|
41
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
42
|
+
}, [
|
|
43
|
+
subscribe,
|
|
44
|
+
value,
|
|
45
|
+
getSnapshot
|
|
46
|
+
]);
|
|
47
|
+
useEffect(function() {
|
|
48
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
49
|
+
return subscribe(function() {
|
|
50
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
51
|
+
});
|
|
52
|
+
}, [subscribe]);
|
|
53
|
+
useDebugValue(value);
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
function checkIfSnapshotChanged(inst) {
|
|
57
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
58
|
+
inst = inst.value;
|
|
59
|
+
try {
|
|
60
|
+
var nextValue = latestGetSnapshot();
|
|
61
|
+
return !objectIs(inst, nextValue);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return !0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
67
|
+
return getSnapshot();
|
|
68
|
+
}
|
|
69
|
+
var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
70
|
+
exports.useSyncExternalStore = void 0 !== React$1.useSyncExternalStore ? React$1.useSyncExternalStore : shim;
|
|
71
|
+
}));
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region ../Artifacts/dsh-llm-router/node_modules/use-sync-external-store/shim/index.js
|
|
74
|
+
var require_shim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
75
|
+
module.exports = require_use_sync_external_store_shim_production();
|
|
76
|
+
}));
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region ../Artifacts/dsh-llm-router/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js
|
|
79
|
+
/**
|
|
80
|
+
* @license React
|
|
81
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
82
|
+
*
|
|
83
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the MIT license found in the
|
|
86
|
+
* LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/
|
|
88
|
+
var require_with_selector_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
89
|
+
var React = require("react");
|
|
90
|
+
var shim = require_shim();
|
|
91
|
+
function is(x, y) {
|
|
92
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
93
|
+
}
|
|
94
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
|
95
|
+
var useSyncExternalStore = shim.useSyncExternalStore;
|
|
96
|
+
var useRef = React.useRef;
|
|
97
|
+
var useEffect = React.useEffect;
|
|
98
|
+
var useMemo = React.useMemo;
|
|
99
|
+
var useDebugValue = React.useDebugValue;
|
|
100
|
+
exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
101
|
+
var instRef = useRef(null);
|
|
102
|
+
if (null === instRef.current) {
|
|
103
|
+
var inst = {
|
|
104
|
+
hasValue: !1,
|
|
105
|
+
value: null
|
|
106
|
+
};
|
|
107
|
+
instRef.current = inst;
|
|
108
|
+
} else inst = instRef.current;
|
|
109
|
+
instRef = useMemo(function() {
|
|
110
|
+
function memoizedSelector(nextSnapshot) {
|
|
111
|
+
if (!hasMemo) {
|
|
112
|
+
hasMemo = !0;
|
|
113
|
+
memoizedSnapshot = nextSnapshot;
|
|
114
|
+
nextSnapshot = selector(nextSnapshot);
|
|
115
|
+
if (void 0 !== isEqual && inst.hasValue) {
|
|
116
|
+
var currentSelection = inst.value;
|
|
117
|
+
if (isEqual(currentSelection, nextSnapshot)) return memoizedSelection = currentSelection;
|
|
118
|
+
}
|
|
119
|
+
return memoizedSelection = nextSnapshot;
|
|
120
|
+
}
|
|
121
|
+
currentSelection = memoizedSelection;
|
|
122
|
+
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
|
123
|
+
var nextSelection = selector(nextSnapshot);
|
|
124
|
+
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
125
|
+
memoizedSnapshot = nextSnapshot;
|
|
126
|
+
return memoizedSelection = nextSelection;
|
|
127
|
+
}
|
|
128
|
+
var hasMemo = !1, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
129
|
+
return [function() {
|
|
130
|
+
return memoizedSelector(getSnapshot());
|
|
131
|
+
}, null === maybeGetServerSnapshot ? void 0 : function() {
|
|
132
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
133
|
+
}];
|
|
134
|
+
}, [
|
|
135
|
+
getSnapshot,
|
|
136
|
+
getServerSnapshot,
|
|
137
|
+
selector,
|
|
138
|
+
isEqual
|
|
139
|
+
]);
|
|
140
|
+
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
141
|
+
useEffect(function() {
|
|
142
|
+
inst.hasValue = !0;
|
|
143
|
+
inst.value = value;
|
|
144
|
+
}, [value]);
|
|
145
|
+
useDebugValue(value);
|
|
146
|
+
return value;
|
|
147
|
+
};
|
|
148
|
+
}));
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/client/use-snapshot.ts
|
|
151
|
+
var import_with_selector = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
152
|
+
module.exports = require_with_selector_production();
|
|
153
|
+
})))();
|
|
154
|
+
/**
|
|
155
|
+
* Bind a bare observable source to a typed uSES selector hook.
|
|
156
|
+
* subscribe/getSnapshot are captured once per source into stable closures
|
|
157
|
+
* (also re-binds `this` for method-based sources), so components never
|
|
158
|
+
* resubscribe across renders. Equality defaults to Object.is.
|
|
159
|
+
* @param w - snapshot source (engine store, Session object, store instance).
|
|
160
|
+
* @returns the selector hook.
|
|
161
|
+
*/
|
|
162
|
+
function bindSnapshotSelector(w) {
|
|
163
|
+
const subscribe = (fn) => w.subscribe(fn);
|
|
164
|
+
const getSnapshot = () => w.getSnapshot();
|
|
165
|
+
return function useSelector(sel, eq) {
|
|
166
|
+
return (0, import_with_selector.useSyncExternalStoreWithSelector)(subscribe, getSnapshot, void 0, sel, eq);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region \0dsh-css:D:\Repos\dsh-llm-router\src\client\FallbacksCard.module.css.mjs
|
|
171
|
+
const css$4 = "\r\n\r\n\r\n._c6b9cfef_root {\r\n min-width: 0;\r\n}\r\n\r\n\r\n._17e44069_readOnly {\r\n margin: 12px 0 0;\r\n font-size: 12px;\r\n line-height: 1.5;\r\n color: var(--dsw-alias-label-tertiary);\r\n}\r\n\r\n._dbee053b_notice {\r\n margin: 12px 0 0;\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-state-business-primary);\r\n}\r\n\r\n\r\n._a7fc41a0_legacyNotice {\r\n margin: 12px 0 0;\r\n padding: 10px 12px;\r\n border-radius: 8px;\r\n background: var(--dsw-alias-bg-module-platform);\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-state-business-primary);\r\n}\r\n\r\n._23364cdb_error {\r\n margin: 12px 0 0;\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-state-error-primary);\r\n}\r\n\r\n\r\n._8b79a4c1_noticeRow {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n margin: 12px 0 0;\r\n}\r\n\r\n._8b79a4c1_noticeRow ._23364cdb_error {\r\n flex: 1;\r\n min-width: 0;\r\n margin: 0;\r\n}\r\n\r\n\r\n._dd5a759b_fieldset {\r\n margin: 0;\r\n padding: 0;\r\n border: none;\r\n display: flex;\r\n flex-direction: column;\r\n min-width: 0;\r\n}\r\n\r\n\r\n._4a9f4378_sectionHeading {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n margin: 0;\r\n padding: 4px 0;\r\n font-size: 16px;\r\n line-height: 24px;\r\n font-weight: 600;\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n._3b1ec6bf_sectionHeadingText {\r\n display: block;\r\n min-width: 0;\r\n}\r\n\r\n\r\n._243fb84d_sectionActions {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n margin-left: auto;\r\n}\r\n\r\n._243fb84d_sectionActions ._9320e17f_discard,\r\n._243fb84d_sectionActions ._c8248e0e_save {\r\n padding: 3px 12px;\r\n font-size: 12px;\r\n line-height: 18px;\r\n}\r\n\r\n\r\n._1a4fb8ee_sectionToggle {\r\n appearance: none;\r\n border: 0;\r\n background: none;\r\n display: flex;\r\n align-items: center;\r\n gap: 4px;\r\n margin: 0;\r\n padding: 0;\r\n font: inherit;\r\n color: inherit;\r\n cursor: pointer;\r\n}\r\n\r\n._1a4fb8ee_sectionToggle:disabled {\r\n cursor: default;\r\n}\r\n\r\n._1a4fb8ee_sectionToggle:focus-visible {\r\n outline: 2px solid var(--dsw-alias-brand-primary);\r\n outline-offset: 1px;\r\n}\r\n\r\n\r\n._49e6b68d_advancedBody {\r\n display: flex;\r\n flex-direction: column;\r\n min-width: 0;\r\n}\r\n\r\n._dd5a759b_fieldset > ._49e6b68d_advancedBody > ._a72f7f8d_field,\r\n._dd5a759b_fieldset > ._49e6b68d_advancedBody > ._345d580e_checkboxRow,\r\n._dd5a759b_fieldset > ._49e6b68d_advancedBody > ._adeed03f_numberFields {\r\n padding: 12px 0;\r\n}\r\n\r\n._dd5a759b_fieldset > ._49e6b68d_advancedBody > ._a72f7f8d_field + ._a72f7f8d_field,\r\n._dd5a759b_fieldset > ._49e6b68d_advancedBody > ._345d580e_checkboxRow + ._a72f7f8d_field,\r\n._dd5a759b_fieldset > ._49e6b68d_advancedBody > ._a72f7f8d_field + ._adeed03f_numberFields {\r\n border-top: 0.5px solid var(--dsw-alias-border-l2);\r\n}\r\n\r\n\r\n._a72f7f8d_field {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 6px;\r\n margin: 0;\r\n padding: 0;\r\n border: none;\r\n min-width: 0;\r\n}\r\n\r\n\r\n._dd5a759b_fieldset > ._a72f7f8d_field,\r\n._dd5a759b_fieldset > ._345d580e_checkboxRow,\r\n._dd5a759b_fieldset > ._adeed03f_numberFields {\r\n padding: 12px 0;\r\n}\r\n\r\n._dd5a759b_fieldset > ._a72f7f8d_field + ._a72f7f8d_field,\r\n._dd5a759b_fieldset > ._a72f7f8d_field + ._adeed03f_numberFields,\r\n._dd5a759b_fieldset > ._345d580e_checkboxRow + ._a72f7f8d_field {\r\n border-top: 0.5px solid var(--dsw-alias-border-l2);\r\n}\r\n\r\n\r\n._345d580e_checkboxRow {\r\n display: flex;\r\n align-items: flex-start;\r\n gap: 8px;\r\n}\r\n\r\n\r\n._345d580e_checkboxRow ._27b96bc2_checkbox {\r\n margin-top: 3px;\r\n}\r\n\r\n._56212755_fieldLabel {\r\n \r\n display: inline-flex;\r\n align-items: center;\r\n gap: 10px;\r\n padding: 0;\r\n font-size: 13px;\r\n line-height: 1.5;\r\n font-weight: 500;\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n._d7541ea2_hint {\r\n display: inline-flex;\r\n align-items: center;\r\n gap: 6px;\r\n flex-wrap: wrap;\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-tertiary);\r\n}\r\n\r\n\r\n._9e7453cd_checkLabel {\r\n flex: 1;\r\n min-width: 0;\r\n display: flex;\r\n flex-direction: column;\r\n gap: 4px;\r\n font-size: 14px;\r\n line-height: 22px;\r\n font-weight: 400;\r\n color: var(--dsw-alias-label-primary);\r\n cursor: pointer;\r\n}\r\n\r\n._e4709a41_checkLabelTitle {\r\n display: inline-flex;\r\n align-items: center;\r\n gap: 6px;\r\n font-weight: 400;\r\n}\r\n\r\n._8234d308_checkLabelDesc {\r\n font-size: 12px;\r\n line-height: 18px;\r\n font-weight: 400;\r\n color: var(--dsw-alias-label-tertiary);\r\n}\r\n\r\n\r\n._27b96bc2_checkbox {\r\n flex: none;\r\n width: 16px;\r\n height: 16px;\r\n margin: 0;\r\n accent-color: var(--dsw-alias-brand-primary);\r\n cursor: pointer;\r\n}\r\n\r\n._27b96bc2_checkbox:disabled {\r\n opacity: 0.4;\r\n cursor: default;\r\n}\r\n\r\n\r\n._3c784feb_slotPresetName {\r\n font-size: 14px;\r\n line-height: 22px;\r\n font-weight: 500;\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n\r\n._9cdfc0a6_infoHint {\r\n position: relative;\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n flex: none;\r\n width: 16px;\r\n height: 16px;\r\n border-radius: 50%;\r\n font-size: 14px;\r\n line-height: 1;\r\n color: var(--dsw-alias-label-tertiary);\r\n background: var(--dsw-alias-interactive-bg-hover);\r\n cursor: help;\r\n user-select: none;\r\n}\r\n\r\n._9cdfc0a6_infoHint:focus-visible {\r\n outline: none;\r\n box-shadow: 0 0 0 2px var(--dsw-alias-border-l3);\r\n}\r\n\r\n._9cdfc0a6_infoHint::after {\r\n content: attr(data-tip);\r\n position: absolute;\r\n top: 50%;\r\n left: calc(100% + 8px);\r\n transform: translateY(-50%);\r\n z-index: 10;\r\n box-sizing: border-box;\r\n width: max-content;\r\n max-width: 280px;\r\n padding: 5px 10px;\r\n border-radius: 8px;\r\n background: var(--dsw-alias-label-primary);\r\n color: var(--dsw-alias-bg-layer-3);\r\n font-size: 11px;\r\n line-height: 17px;\r\n font-weight: 400;\r\n white-space: normal;\r\n text-align: left;\r\n pointer-events: none;\r\n opacity: 0;\r\n transition: opacity .12s;\r\n}\r\n\r\n._9cdfc0a6_infoHint:hover::after,\r\n._9cdfc0a6_infoHint:focus-visible::after {\r\n opacity: 1;\r\n}\r\n\r\n\r\n._74c4f11e_infoHintDisabled {\r\n opacity: 0.4;\r\n cursor: default;\r\n}\r\n\r\n\r\n._a106dba2_optionRow {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n padding: 6px 8px;\r\n border-radius: 6px;\r\n font-size: 14px;\r\n line-height: 22px;\r\n color: var(--dsw-alias-label-primary);\r\n cursor: pointer;\r\n}\r\n\r\n._a106dba2_optionRow:hover:has(input:not(:disabled)) {\r\n background: var(--dsw-alias-interactive-bg-hover);\r\n}\r\n\r\n\r\n._27b96bc2_checkbox,\r\n._a106dba2_optionRow input {\r\n flex: none;\r\n width: 16px;\r\n height: 16px;\r\n margin: 0;\r\n accent-color: var(--dsw-alias-brand-primary);\r\n cursor: pointer;\r\n}\r\n\r\n._27b96bc2_checkbox:focus-visible,\r\n._a106dba2_optionRow input:focus-visible {\r\n outline: none;\r\n box-shadow: 0 0 0 2px var(--dsw-alias-border-l3);\r\n}\r\n\r\n._a106dba2_optionRow input:disabled {\r\n cursor: default;\r\n}\r\n\r\n\r\n._a49c7ded_dayRow {\r\n display: flex;\r\n flex-wrap: wrap;\r\n gap: 4px;\r\n}\r\n\r\n._bdf02c23_dayCell {\r\n display: inline-flex;\r\n align-items: center;\r\n gap: 4px;\r\n padding: 2px 6px;\r\n border-radius: 6px;\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-secondary);\r\n cursor: pointer;\r\n}\r\n\r\n._bdf02c23_dayCell:hover:has(input:not(:disabled)) {\r\n background: var(--dsw-alias-interactive-bg-hover);\r\n}\r\n\r\n._bdf02c23_dayCell input {\r\n flex: none;\r\n width: 16px;\r\n height: 16px;\r\n margin: 0;\r\n accent-color: var(--dsw-alias-brand-primary);\r\n cursor: pointer;\r\n}\r\n\r\n._bdf02c23_dayCell input:disabled {\r\n cursor: default;\r\n}\r\n\r\n._bdf02c23_dayCell input:focus-visible {\r\n outline: none;\r\n box-shadow: 0 0 0 2px var(--dsw-alias-border-l3);\r\n}\r\n\r\n\r\n._b82bc091_input {\r\n box-sizing: border-box;\r\n width: 100%;\r\n height: 34px;\r\n padding: 0 12px;\r\n border: 0.5px solid var(--dsw-alias-border-l4);\r\n border-radius: var(--dsw-radius-md);\r\n font: inherit;\r\n font-size: 13px;\r\n line-height: 1.5;\r\n background: var(--dsw-alias-bg-layer-3);\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n._b82bc091_input:focus-visible {\r\n outline: none;\r\n border-color: var(--dsw-alias-state-business-primary);\r\n}\r\n\r\n._b82bc091_input::placeholder {\r\n color: var(--dsw-alias-label-dimmed);\r\n}\r\n\r\n._b82bc091_input:disabled {\r\n color: var(--dsw-alias-label-tertiary);\r\n cursor: default;\r\n}\r\n\r\n\r\n._c9e5ffe7_inputTextarea {\r\n height: auto;\r\n min-height: 72px;\r\n padding: 8px 12px;\r\n resize: vertical;\r\n}\r\n\r\n\r\n._b5886f05_personaBriefRow {\r\n display: flex;\r\n align-items: center;\r\n gap: 4px;\r\n min-width: 0;\r\n}\r\n\r\n._ee45acf7_personaBrief {\r\n flex: 1;\r\n min-width: 0;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n font-size: 14px;\r\n line-height: 22px;\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n\r\n._1d900a64_personaBriefEmpty {\r\n color: var(--dsw-alias-label-tertiary);\r\n}\r\n\r\n\r\n._5ecb2b94_personaFull {\r\n margin: 0;\r\n font-size: 14px;\r\n line-height: 22px;\r\n color: var(--dsw-alias-label-secondary);\r\n white-space: pre-wrap;\r\n overflow-wrap: anywhere;\r\n}\r\n\r\n\r\n._90bd6054_inputInvalid,\r\n._90bd6054_inputInvalid:focus-visible {\r\n border-color: var(--dsw-alias-state-error-primary);\r\n}\r\n\r\n\r\nselect._b82bc091_input {\r\n max-width: 240px;\r\n cursor: pointer;\r\n}\r\n\r\n\r\n._261230a1_selectInput {\r\n appearance: none;\r\n padding-right: 32px;\r\n \r\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\");\r\n background-repeat: no-repeat;\r\n background-position: right 12px center;\r\n background-size: 12px 12px;\r\n}\r\n\r\n\r\n._adeed03f_numberFields {\r\n display: grid;\r\n grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));\r\n gap: 12px;\r\n}\r\n\r\n._adeed03f_numberFields ._a72f7f8d_field {\r\n padding: 0;\r\n}\r\n\r\n._8c756cfb_list {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 8px;\r\n margin-top: 4px;\r\n}\r\n\r\n\r\n._bba0bbe4_editorCard {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 14px;\r\n padding: 14px 16px;\r\n border-radius: 12px;\r\n background: var(--dsw-alias-bg-module-platform);\r\n}\r\n\r\n._87c4f7f9_cardFoot {\r\n display: flex;\r\n justify-content: flex-end;\r\n}\r\n\r\n._fce20e49_ruleGrid {\r\n display: flex;\r\n flex-wrap: wrap;\r\n gap: 8px;\r\n}\r\n\r\n._cfc66c5d_ruleCell {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 4px;\r\n min-width: 120px;\r\n flex: 1;\r\n}\r\n\r\n._9d4091c5_ruleCellLabel {\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n\r\n._8e7f566e_chevron {\r\n flex: none;\r\n color: var(--dsw-alias-label-tertiary);\r\n transform: rotate(-90deg);\r\n transition: transform .16s;\r\n}\r\n\r\n._7dbaf9ce_chevronOpen {\r\n transform: none;\r\n}\r\n\r\n\r\n._ae6bf76d_chevronFlip {\r\n transform: rotate(180deg);\r\n}\r\n\r\n\r\n._e93c9e2c_collapseRow {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n min-width: 0;\r\n}\r\n\r\n._0934b8f4_collapseToggle {\r\n appearance: none;\r\n border: 0;\r\n background: none;\r\n padding: 0;\r\n cursor: pointer;\r\n color: var(--dsw-alias-label-secondary);\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n flex: 1;\r\n min-width: 0;\r\n font: inherit;\r\n text-align: left;\r\n}\r\n\r\n._0934b8f4_collapseToggle:disabled {\r\n cursor: default;\r\n}\r\n\r\n._1133fbee_collapseTitle {\r\n \r\n flex: none;\r\n max-width: 55%;\r\n min-width: 0;\r\n font-size: 12px;\r\n line-height: 18px;\r\n font-weight: 500;\r\n color: var(--dsw-alias-label-primary);\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n}\r\n\r\n._d82ef63d_collapseMeta {\r\n \r\n flex: 0 1 auto;\r\n min-width: 0;\r\n max-width: 40%;\r\n margin-left: auto;\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-secondary);\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n}\r\n\r\n\r\n._b134c585_seedBadge {\r\n flex: none;\r\n max-width: 40%;\r\n min-width: 0;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n border-radius: 999px;\r\n padding: 1px 8px;\r\n font-size: 11px;\r\n line-height: 17px;\r\n font-weight: 500;\r\n white-space: nowrap;\r\n background: var(--dsw-alias-bg-layer-1);\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n\r\n._0e70e355_slotTag {\r\n flex: none;\r\n display: inline-flex;\r\n align-items: center;\r\n border-radius: 999px;\r\n padding: 0 6px;\r\n font-size: 11px;\r\n line-height: 17px;\r\n font-weight: 500;\r\n white-space: nowrap;\r\n border: 1px solid;\r\n}\r\n\r\n._f3b7ca50_slotTagHighCost {\r\n color: var(--dsw-alias-state-error-primary);\r\n border-color: var(--dsw-alias-state-error-primary);\r\n background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent);\r\n}\r\n\r\n._9216af96_slotTagMultiplier {\r\n color: var(--dsw-alias-state-warn-primary);\r\n border-color: var(--dsw-alias-state-warn-primary);\r\n background: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 10%, transparent);\r\n}\r\n\r\n._e6c0e39f_slotTagActive {\r\n color: var(--dsw-alias-state-success-primary);\r\n border-color: var(--dsw-alias-state-success-primary);\r\n background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 10%, transparent);\r\n}\r\n\r\n\r\n._0849b09f_dragHandle {\r\n appearance: none;\r\n border: 0;\r\n background: none;\r\n padding: 0;\r\n cursor: grab;\r\n color: var(--dsw-alias-label-tertiary);\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 20px;\r\n height: 20px;\r\n border-radius: 6px;\r\n flex: none;\r\n}\r\n\r\n._0849b09f_dragHandle:hover:not(:disabled) {\r\n background: var(--dsw-alias-interactive-bg-hover);\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n._0849b09f_dragHandle:active {\r\n cursor: grabbing;\r\n}\r\n\r\n._0849b09f_dragHandle:disabled {\r\n cursor: default;\r\n opacity: 0.4;\r\n}\r\n\r\n._0849b09f_dragHandle:focus-visible {\r\n outline: none;\r\n box-shadow: 0 0 0 2px var(--dsw-alias-border-l3);\r\n}\r\n\r\n\r\n._83fb72f8_slotCardDragging {\r\n opacity: 0.45;\r\n}\r\n\r\n._5d67996b_slotCardOver {\r\n outline: 1px dashed var(--dsw-alias-brand-primary);\r\n outline-offset: 2px;\r\n}\r\n\r\n\r\n._d8f6c9e3_selectorRowDragging {\r\n opacity: 0.45;\r\n}\r\n\r\n._49b56db4_selectorRowOver {\r\n outline: 1px dashed var(--dsw-alias-brand-primary);\r\n outline-offset: 2px;\r\n border-radius: 6px;\r\n}\r\n\r\n\r\n._13d58efe_selectorGrip {\r\n flex: none;\r\n}\r\n\r\n._13d58efe_selectorGrip:disabled {\r\n display: none;\r\n}\r\n\r\n\r\n._bfe77c29_chainBlock {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 6px;\r\n}\r\n\r\n\r\n._428b5d1a_chainSelectors {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 4px;\r\n}\r\n\r\n\r\n._c190e3f0_selectorLine {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n flex-wrap: nowrap;\r\n \r\n min-height: 32px;\r\n}\r\n\r\n\r\n._6534b816_selectorIndex {\r\n flex: none;\r\n width: 1.5em;\r\n text-align: right;\r\n font-size: 11px;\r\n line-height: 16px;\r\n color: var(--dsw-alias-label-tertiary);\r\n font-variant-numeric: tabular-nums;\r\n}\r\n\r\n\r\n._334a37c3_selectorProviderCell {\r\n flex: 0 1 clamp(140px, 20%, 220px);\r\n min-width: 0;\r\n}\r\n\r\n._63065c63_selectorModelCell {\r\n flex: 1 1 auto;\r\n min-width: 0;\r\n}\r\n\r\n\r\n._63065c63_selectorModelCell > select._b82bc091_input {\r\n max-width: 100%;\r\n}\r\n\r\n\r\n._9222de4f_selectorHint {\r\n display: flex;\r\n align-items: center;\r\n flex: 0 1 auto;\r\n min-width: 0;\r\n}\r\n\r\n\r\n._b3f9f018_selectorHintText {\r\n flex: 0 1 auto;\r\n min-width: 0;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n font-size: 11px;\r\n line-height: 16px;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n\r\n._9222de4f_selectorHint > ._9cdfc0a6_infoHint {\r\n flex: none;\r\n margin-left: 4px;\r\n}\r\n\r\n\r\n._832cfce6_selectorRemove {\r\n flex: none;\r\n opacity: 0;\r\n transition: opacity .12s;\r\n}\r\n\r\n\r\n._832cfce6_selectorRemove:disabled {\r\n display: none;\r\n}\r\n\r\n\r\n._15ebf4ae_selectorRow:hover ._832cfce6_selectorRemove:not(:disabled),\r\n._15ebf4ae_selectorRow:focus-within ._832cfce6_selectorRemove:not(:disabled) {\r\n opacity: 1;\r\n}\r\n\r\n@media (hover: none) {\r\n ._832cfce6_selectorRemove:not(:disabled) {\r\n opacity: 0.7;\r\n }\r\n}\r\n\r\n\r\n._572ba95a_iconButton {\r\n position: relative;\r\n box-sizing: border-box;\r\n appearance: none;\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 28px;\r\n height: 28px;\r\n padding: 0;\r\n border: 0;\r\n border-radius: 6px;\r\n background: none;\r\n color: var(--dsw-alias-label-tertiary);\r\n cursor: pointer;\r\n}\r\n\r\n._572ba95a_iconButton:disabled {\r\n opacity: 0.4;\r\n cursor: default;\r\n}\r\n\r\n._572ba95a_iconButton:hover:not(:disabled) {\r\n background: var(--dsw-alias-interactive-bg-hover);\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n._572ba95a_iconButton:focus-visible {\r\n outline: none;\r\n box-shadow: 0 0 0 2px var(--dsw-alias-border-l3);\r\n}\r\n\r\n._572ba95a_iconButton::after {\r\n content: attr(data-tip);\r\n position: absolute;\r\n bottom: calc(100% + 6px);\r\n left: 50%;\r\n transform: translateX(-50%);\r\n padding: 3px 8px;\r\n border-radius: 6px;\r\n background: var(--dsw-alias-label-primary);\r\n color: var(--dsw-alias-bg-layer-3);\r\n font-size: 11px;\r\n line-height: 17px;\r\n white-space: nowrap;\r\n opacity: 0;\r\n pointer-events: none;\r\n transition: opacity .12s;\r\n}\r\n\r\n._572ba95a_iconButton:hover::after,\r\n._572ba95a_iconButton:focus-visible::after {\r\n opacity: 1;\r\n}\r\n\r\n\r\n._dce04c19_iconButtonDanger:hover:not(:disabled) {\r\n background: var(--dsw-alias-interactive-bg-hover-danger);\r\n color: var(--dsw-alias-state-error-primary);\r\n}\r\n\r\n\r\n._60ce2a17_outlineButton {\r\n appearance: none;\r\n display: inline-flex;\r\n align-items: center;\r\n gap: 4px;\r\n padding: 4px 10px;\r\n border: 1px solid var(--dsw-alias-border-l2);\r\n border-radius: var(--dsw-radius-md);\r\n background: none;\r\n font: inherit;\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-secondary);\r\n cursor: pointer;\r\n}\r\n\r\n._60ce2a17_outlineButton:hover:not(:disabled) {\r\n color: var(--dsw-alias-label-primary);\r\n border-color: var(--dsw-alias-label-dimmed);\r\n}\r\n\r\n._60ce2a17_outlineButton:disabled {\r\n opacity: 0.4;\r\n cursor: default;\r\n}\r\n\r\n._60ce2a17_outlineButton:focus-visible {\r\n outline: 2px solid var(--dsw-alias-brand-primary);\r\n outline-offset: 1px;\r\n}\r\n\r\n\r\n._0b13c716_addButton {\r\n align-self: flex-start;\r\n}\r\n\r\n\r\n._bfe77c29_chainBlock > ._0b13c716_addButton {\r\n box-sizing: border-box;\r\n align-self: flex-start;\r\n height: 26px;\r\n padding: 0 8px;\r\n border: 1px solid transparent;\r\n gap: 4px;\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n._bfe77c29_chainBlock > ._0b13c716_addButton:hover:not(:disabled) {\r\n border-color: transparent;\r\n background: var(--dsw-alias-interactive-bg-hover);\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n\r\n._bfe77c29_chainBlock > ._0b13c716_addButton:focus-visible {\r\n outline: none;\r\n box-shadow: 0 0 0 2px var(--dsw-alias-border-l3);\r\n}\r\n\r\n\r\n._26e91326_slotAddRow {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n margin-top: 4px;\r\n flex-wrap: wrap;\r\n}\r\n\r\n\r\n._007c1b38_rowActions {\r\n display: flex;\r\n align-items: center;\r\n gap: 4px;\r\n}\r\n\r\n\r\n._9320e17f_discard,\r\n._c8248e0e_save {\r\n appearance: none;\r\n border: 1px solid transparent;\r\n border-radius: var(--dsw-radius-md);\r\n padding: 5px 14px;\r\n font: inherit;\r\n font-size: 13px;\r\n line-height: 1.5;\r\n cursor: pointer;\r\n}\r\n\r\n._9320e17f_discard {\r\n border-color: var(--dsw-alias-border-l2);\r\n background: none;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n._9320e17f_discard:hover:not(:disabled) {\r\n color: var(--dsw-alias-label-primary);\r\n border-color: var(--dsw-alias-label-dimmed);\r\n}\r\n\r\n._c8248e0e_save {\r\n background: var(--dsw-alias-label-primary);\r\n color: var(--dsw-alias-bg-layer-3);\r\n}\r\n\r\n._9320e17f_discard:disabled,\r\n._c8248e0e_save:disabled {\r\n opacity: 0.4;\r\n cursor: default;\r\n}\r\n\r\n._9320e17f_discard:focus-visible,\r\n._c8248e0e_save:focus-visible {\r\n outline: 2px solid var(--dsw-alias-brand-primary);\r\n outline-offset: 1px;\r\n}\r\n\r\n\r\n._7d807542_statusBlock {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 12px;\r\n padding: 12px 14px;\r\n margin-top: 12px;\r\n border: 1px solid var(--dsw-alias-border-l2);\r\n border-radius: 12px;\r\n}\r\n\r\n._2d5242e9_statusTitle {\r\n font-size: 12px;\r\n line-height: 18px;\r\n font-weight: 500;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n\r\n._06913287_statusLine {\r\n margin: 0;\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-secondary);\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n}\r\n\r\n._b5c76c1f_statusLineLabel {\r\n font-weight: 500;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n\r\n._0d87013f_policyStatus {\r\n margin: 12px 0 0;\r\n padding: 10px 12px;\r\n border-radius: 8px;\r\n background: var(--dsw-alias-bg-module-platform);\r\n display: flex;\r\n flex-direction: column;\r\n gap: 6px;\r\n}\r\n\r\n\r\n._0ebbca28_policyStatusText {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 6px;\r\n}\r\n\r\n._c1a1a4b8_policyStatusSync {\r\n display: flex;\r\n flex-wrap: wrap;\r\n align-items: center;\r\n gap: 6px;\r\n}\r\n\r\n\r\n._59029705_policyStatusLive:empty {\r\n position: absolute;\r\n width: 1px;\r\n height: 1px;\r\n overflow: hidden;\r\n clip-path: inset(50%);\r\n white-space: nowrap;\r\n}\r\n\r\n._f899bec7_policyStatusLabel {\r\n font-size: 12px;\r\n font-weight: 600;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n._68ef287d_policyStatusLine {\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n._67addcbf_policyStatusWarn {\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-state-warn-primary);\r\n}\r\n\r\n@media (prefers-reduced-motion: reduce) {\r\n ._572ba95a_iconButton::after,\r\n ._9cdfc0a6_infoHint::after {\r\n transition: none;\r\n }\r\n\r\n ._8e7f566e_chevron {\r\n transition: none;\r\n }\r\n}\r\n";
|
|
172
|
+
const tagId$4 = "dsh-fallback-router/FallbacksCard.module.css";
|
|
173
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$4) + "]") === null) {
|
|
174
|
+
const tag = document.createElement("style");
|
|
175
|
+
tag.dataset.plugin = "dsh-fallback-router";
|
|
176
|
+
tag.dataset.pluginCss = tagId$4;
|
|
177
|
+
tag.textContent = css$4;
|
|
178
|
+
document.head.appendChild(tag);
|
|
179
|
+
}
|
|
180
|
+
var FallbacksCard_module_css_default = {
|
|
181
|
+
"root": "_c6b9cfef_root",
|
|
182
|
+
"readOnly": "_17e44069_readOnly",
|
|
183
|
+
"notice": "_dbee053b_notice",
|
|
184
|
+
"legacyNotice": "_a7fc41a0_legacyNotice",
|
|
185
|
+
"error": "_23364cdb_error",
|
|
186
|
+
"noticeRow": "_8b79a4c1_noticeRow",
|
|
187
|
+
"fieldset": "_dd5a759b_fieldset",
|
|
188
|
+
"sectionHeading": "_4a9f4378_sectionHeading",
|
|
189
|
+
"sectionHeadingText": "_3b1ec6bf_sectionHeadingText",
|
|
190
|
+
"sectionActions": "_243fb84d_sectionActions",
|
|
191
|
+
"discard": "_9320e17f_discard",
|
|
192
|
+
"save": "_c8248e0e_save",
|
|
193
|
+
"sectionToggle": "_1a4fb8ee_sectionToggle",
|
|
194
|
+
"advancedBody": "_49e6b68d_advancedBody",
|
|
195
|
+
"field": "_a72f7f8d_field",
|
|
196
|
+
"checkboxRow": "_345d580e_checkboxRow",
|
|
197
|
+
"numberFields": "_adeed03f_numberFields",
|
|
198
|
+
"checkbox": "_27b96bc2_checkbox",
|
|
199
|
+
"fieldLabel": "_56212755_fieldLabel",
|
|
200
|
+
"hint": "_d7541ea2_hint",
|
|
201
|
+
"checkLabel": "_9e7453cd_checkLabel",
|
|
202
|
+
"checkLabelTitle": "_e4709a41_checkLabelTitle",
|
|
203
|
+
"checkLabelDesc": "_8234d308_checkLabelDesc",
|
|
204
|
+
"slotPresetName": "_3c784feb_slotPresetName",
|
|
205
|
+
"infoHint": "_9cdfc0a6_infoHint",
|
|
206
|
+
"infoHintDisabled": "_74c4f11e_infoHintDisabled",
|
|
207
|
+
"optionRow": "_a106dba2_optionRow",
|
|
208
|
+
"dayRow": "_a49c7ded_dayRow",
|
|
209
|
+
"dayCell": "_bdf02c23_dayCell",
|
|
210
|
+
"input": "_b82bc091_input",
|
|
211
|
+
"inputTextarea": "_c9e5ffe7_inputTextarea",
|
|
212
|
+
"personaBriefRow": "_b5886f05_personaBriefRow",
|
|
213
|
+
"personaBrief": "_ee45acf7_personaBrief",
|
|
214
|
+
"personaBriefEmpty": "_1d900a64_personaBriefEmpty",
|
|
215
|
+
"personaFull": "_5ecb2b94_personaFull",
|
|
216
|
+
"inputInvalid": "_90bd6054_inputInvalid",
|
|
217
|
+
"selectInput": "_261230a1_selectInput",
|
|
218
|
+
"list": "_8c756cfb_list",
|
|
219
|
+
"editorCard": "_bba0bbe4_editorCard",
|
|
220
|
+
"cardFoot": "_87c4f7f9_cardFoot",
|
|
221
|
+
"ruleGrid": "_fce20e49_ruleGrid",
|
|
222
|
+
"ruleCell": "_cfc66c5d_ruleCell",
|
|
223
|
+
"ruleCellLabel": "_9d4091c5_ruleCellLabel",
|
|
224
|
+
"chevron": "_8e7f566e_chevron",
|
|
225
|
+
"chevronOpen": "_7dbaf9ce_chevronOpen",
|
|
226
|
+
"chevronFlip": "_ae6bf76d_chevronFlip",
|
|
227
|
+
"collapseRow": "_e93c9e2c_collapseRow",
|
|
228
|
+
"collapseToggle": "_0934b8f4_collapseToggle",
|
|
229
|
+
"collapseTitle": "_1133fbee_collapseTitle",
|
|
230
|
+
"collapseMeta": "_d82ef63d_collapseMeta",
|
|
231
|
+
"seedBadge": "_b134c585_seedBadge",
|
|
232
|
+
"slotTag": "_0e70e355_slotTag",
|
|
233
|
+
"slotTagHighCost": "_f3b7ca50_slotTagHighCost",
|
|
234
|
+
"slotTagMultiplier": "_9216af96_slotTagMultiplier",
|
|
235
|
+
"slotTagActive": "_e6c0e39f_slotTagActive",
|
|
236
|
+
"dragHandle": "_0849b09f_dragHandle",
|
|
237
|
+
"slotCardDragging": "_83fb72f8_slotCardDragging",
|
|
238
|
+
"slotCardOver": "_5d67996b_slotCardOver",
|
|
239
|
+
"selectorRowDragging": "_d8f6c9e3_selectorRowDragging",
|
|
240
|
+
"selectorRowOver": "_49b56db4_selectorRowOver",
|
|
241
|
+
"selectorGrip": "_13d58efe_selectorGrip",
|
|
242
|
+
"chainBlock": "_bfe77c29_chainBlock",
|
|
243
|
+
"chainSelectors": "_428b5d1a_chainSelectors",
|
|
244
|
+
"selectorLine": "_c190e3f0_selectorLine",
|
|
245
|
+
"selectorIndex": "_6534b816_selectorIndex",
|
|
246
|
+
"selectorProviderCell": "_334a37c3_selectorProviderCell",
|
|
247
|
+
"selectorModelCell": "_63065c63_selectorModelCell",
|
|
248
|
+
"selectorHint": "_9222de4f_selectorHint",
|
|
249
|
+
"selectorHintText": "_b3f9f018_selectorHintText",
|
|
250
|
+
"selectorRemove": "_832cfce6_selectorRemove",
|
|
251
|
+
"selectorRow": "_15ebf4ae_selectorRow",
|
|
252
|
+
"iconButton": "_572ba95a_iconButton",
|
|
253
|
+
"iconButtonDanger": "_dce04c19_iconButtonDanger",
|
|
254
|
+
"outlineButton": "_60ce2a17_outlineButton",
|
|
255
|
+
"addButton": "_0b13c716_addButton",
|
|
256
|
+
"slotAddRow": "_26e91326_slotAddRow",
|
|
257
|
+
"rowActions": "_007c1b38_rowActions",
|
|
258
|
+
"statusBlock": "_7d807542_statusBlock",
|
|
259
|
+
"statusTitle": "_2d5242e9_statusTitle",
|
|
260
|
+
"statusLine": "_06913287_statusLine",
|
|
261
|
+
"statusLineLabel": "_b5c76c1f_statusLineLabel",
|
|
262
|
+
"policyStatus": "_0d87013f_policyStatus",
|
|
263
|
+
"policyStatusText": "_0ebbca28_policyStatusText",
|
|
264
|
+
"policyStatusSync": "_c1a1a4b8_policyStatusSync",
|
|
265
|
+
"policyStatusLive": "_59029705_policyStatusLive",
|
|
266
|
+
"policyStatusLabel": "_f899bec7_policyStatusLabel",
|
|
267
|
+
"policyStatusLine": "_68ef287d_policyStatusLine",
|
|
268
|
+
"policyStatusWarn": "_67addcbf_policyStatusWarn"
|
|
269
|
+
};
|
|
270
|
+
/** The four frozen preset ids (exact strings, spec lock). */
|
|
271
|
+
const PRESET_IDS = [
|
|
272
|
+
"liang-peak",
|
|
273
|
+
"liang-valley",
|
|
274
|
+
"glm-peak",
|
|
275
|
+
"glm-valley"
|
|
276
|
+
];
|
|
277
|
+
Object.freeze([
|
|
278
|
+
"official",
|
|
279
|
+
"loop",
|
|
280
|
+
"none"
|
|
281
|
+
]);
|
|
282
|
+
/**
|
|
283
|
+
* The failure codes a fresh profile reacts to — every code the harness (and
|
|
284
|
+
* the pi-ai provider) can report today, including the catch-all
|
|
285
|
+
* `PI_AI_ERROR` that `Upstream rejected the request` lands on.
|
|
286
|
+
*/
|
|
287
|
+
const DEFAULT_RULES_CODES = Object.freeze([
|
|
288
|
+
"AUTH",
|
|
289
|
+
"QUOTA",
|
|
290
|
+
"RATE_LIMIT",
|
|
291
|
+
"SERVER",
|
|
292
|
+
"TIMEOUT",
|
|
293
|
+
"TRANSPORT",
|
|
294
|
+
"INVALID_REQUEST",
|
|
295
|
+
"PI_AI_ERROR",
|
|
296
|
+
"EMPTY_RESPONSE",
|
|
297
|
+
"CONTEXT_WINDOW_EXCEEDED"
|
|
298
|
+
]);
|
|
299
|
+
/**
|
|
300
|
+
* Protocol markers whose appearance at the END of an answer means the stream
|
|
301
|
+
* died inside a tool call. Carried over from dsh-llm-response-guard, where
|
|
302
|
+
* this list was tuned against 32k historical assistant messages with zero
|
|
303
|
+
* false positives.
|
|
304
|
+
*/
|
|
305
|
+
const DEFAULT_MARKERS = Object.freeze([
|
|
306
|
+
"DSML",
|
|
307
|
+
"antml:",
|
|
308
|
+
"function_calls",
|
|
309
|
+
"tool_calls",
|
|
310
|
+
"tool_use",
|
|
311
|
+
"invoke",
|
|
312
|
+
"parameter",
|
|
313
|
+
"antml_function_calls"
|
|
314
|
+
]);
|
|
315
|
+
Object.freeze(["route", "combo"]);
|
|
316
|
+
/** Defaults of a freshly added provider retry row. */
|
|
317
|
+
const DEFAULT_PROVIDER_RETRY = Object.freeze({
|
|
318
|
+
enabled: true,
|
|
319
|
+
maxRetries: 3,
|
|
320
|
+
windowMs: 3e5,
|
|
321
|
+
initialDelayMs: 800,
|
|
322
|
+
maxDelayMs: 15e3,
|
|
323
|
+
jitterRatio: .1
|
|
324
|
+
});
|
|
325
|
+
/** Defaults of a freshly added model profile. */
|
|
326
|
+
function defaultRules() {
|
|
327
|
+
return {
|
|
328
|
+
codes: [...DEFAULT_RULES_CODES],
|
|
329
|
+
regex: [],
|
|
330
|
+
structural: true,
|
|
331
|
+
markers: [...DEFAULT_MARKERS]
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/** Profile id format (same alphabet as role ids). */
|
|
335
|
+
const MODEL_ID_PATTERN = /^[a-z0-9-]{1,32}$/;
|
|
336
|
+
function text(value) {
|
|
337
|
+
return typeof value === "string" ? value.trim() : "";
|
|
338
|
+
}
|
|
339
|
+
function bool(value, fallback) {
|
|
340
|
+
return typeof value === "boolean" ? value : fallback;
|
|
341
|
+
}
|
|
342
|
+
function count(value, fallback, min, max) {
|
|
343
|
+
return typeof value === "number" && Number.isFinite(value) && value >= min && value <= max ? value : fallback;
|
|
344
|
+
}
|
|
345
|
+
function ratio(value, fallback) {
|
|
346
|
+
return count(value, fallback, 0, 1);
|
|
347
|
+
}
|
|
348
|
+
function normalizeWindow(raw) {
|
|
349
|
+
if (raw === null || typeof raw !== "object") return void 0;
|
|
350
|
+
const record = raw;
|
|
351
|
+
const preset = text(record.preset);
|
|
352
|
+
if (preset !== "" && PRESET_IDS.includes(preset)) {
|
|
353
|
+
const presetUse = text(record.use);
|
|
354
|
+
return presetUse === "" ? {
|
|
355
|
+
preset,
|
|
356
|
+
start: "",
|
|
357
|
+
end: "",
|
|
358
|
+
days: []
|
|
359
|
+
} : {
|
|
360
|
+
preset,
|
|
361
|
+
start: "",
|
|
362
|
+
end: "",
|
|
363
|
+
days: [],
|
|
364
|
+
use: presetUse
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
const start = text(record.start);
|
|
368
|
+
const end = text(record.end);
|
|
369
|
+
if (!/^\d{1,2}:\d{2}$/.test(start) || !/^\d{1,2}:\d{2}$/.test(end)) return void 0;
|
|
370
|
+
const days = Array.isArray(record.days) ? record.days.filter((day) => typeof day === "number" && Number.isInteger(day) && day >= 0 && day <= 6) : [];
|
|
371
|
+
const use = text(record.use);
|
|
372
|
+
return use === "" ? {
|
|
373
|
+
start,
|
|
374
|
+
end,
|
|
375
|
+
days
|
|
376
|
+
} : {
|
|
377
|
+
start,
|
|
378
|
+
end,
|
|
379
|
+
days,
|
|
380
|
+
use
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/** Normalize authored windows; malformed entries are dropped, never thrown. */
|
|
384
|
+
function normalizeWindows(raw) {
|
|
385
|
+
if (!Array.isArray(raw)) return [];
|
|
386
|
+
const out = [];
|
|
387
|
+
for (const item of raw) {
|
|
388
|
+
const window = normalizeWindow(item);
|
|
389
|
+
if (window !== void 0) out.push(window);
|
|
390
|
+
}
|
|
391
|
+
return out;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Normalize an authored 追加兜底路由 list (blank rows dropped, duplicates
|
|
395
|
+
* collapsed). Both shapes are accepted: the legacy plain `provider/model`
|
|
396
|
+
* string, and the current `{ route, reasoningEffort }` row that also pins a
|
|
397
|
+
* 推理等级.
|
|
398
|
+
*/
|
|
399
|
+
function normalizeRoutes(raw) {
|
|
400
|
+
if (!Array.isArray(raw)) return [];
|
|
401
|
+
const out = [];
|
|
402
|
+
const seen = /* @__PURE__ */ new Set();
|
|
403
|
+
for (const item of raw) {
|
|
404
|
+
const record = item !== null && typeof item === "object" ? item : void 0;
|
|
405
|
+
const route = record === void 0 ? text(item) : text(record.route);
|
|
406
|
+
if (route === "" || seen.has(route)) continue;
|
|
407
|
+
seen.add(route);
|
|
408
|
+
out.push({
|
|
409
|
+
route,
|
|
410
|
+
reasoningEffort: record === void 0 ? "" : text(record.reasoningEffort)
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
return out;
|
|
414
|
+
}
|
|
415
|
+
/** Normalize authored failure rules (defaults fill every missing field). */
|
|
416
|
+
function normalizeRules(raw) {
|
|
417
|
+
const base = defaultRules();
|
|
418
|
+
if (raw === null || typeof raw !== "object") return base;
|
|
419
|
+
const record = raw;
|
|
420
|
+
const codes = Array.isArray(record.codes) ? record.codes.filter((code) => typeof code === "string" && code.trim() !== "").map((code) => code.trim()) : base.codes;
|
|
421
|
+
const regex = Array.isArray(record.regex) ? record.regex.filter((source) => typeof source === "string" && source.trim() !== "").map((source) => source.trim()) : base.regex;
|
|
422
|
+
const markers = Array.isArray(record.markers) ? record.markers.filter((marker) => typeof marker === "string" && marker.trim() !== "").map((marker) => marker.trim()) : base.markers;
|
|
423
|
+
return {
|
|
424
|
+
codes,
|
|
425
|
+
regex,
|
|
426
|
+
structural: bool(record.structural, base.structural),
|
|
427
|
+
markers: markers.length > 0 ? markers : base.markers
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/** Normalize one authored fallback mode. */
|
|
431
|
+
function normalizeMode(raw) {
|
|
432
|
+
const value = text(raw);
|
|
433
|
+
return value === "official" || value === "loop" || value === "none" ? value : "official";
|
|
434
|
+
}
|
|
435
|
+
/** Normalize one authored profile kind (anything unknown is a plain route). */
|
|
436
|
+
function normalizeKind(raw) {
|
|
437
|
+
return text(raw) === "combo" ? "combo" : "route";
|
|
438
|
+
}
|
|
439
|
+
/** Normalize the authored profile list (invalid rows are skipped). */
|
|
440
|
+
function normalizeModelProfiles(raw) {
|
|
441
|
+
if (!Array.isArray(raw)) return [];
|
|
442
|
+
const out = [];
|
|
443
|
+
const seen = /* @__PURE__ */ new Set();
|
|
444
|
+
for (const item of raw) {
|
|
445
|
+
if (item === null || typeof item !== "object") continue;
|
|
446
|
+
const record = item;
|
|
447
|
+
const kind = normalizeKind(record.kind);
|
|
448
|
+
const provider = kind === "combo" ? "" : text(record.provider);
|
|
449
|
+
const model = kind === "combo" ? "" : text(record.model);
|
|
450
|
+
if (kind === "route" && (provider === "" || model === "")) continue;
|
|
451
|
+
const requested = text(record.id);
|
|
452
|
+
let id = MODEL_ID_PATTERN.test(requested) && !seen.has(requested) ? requested : "";
|
|
453
|
+
if (id === "") {
|
|
454
|
+
let index = out.length + 1;
|
|
455
|
+
while (seen.has(`model-${index}`)) index += 1;
|
|
456
|
+
id = `model-${index}`;
|
|
457
|
+
}
|
|
458
|
+
seen.add(id);
|
|
459
|
+
out.push({
|
|
460
|
+
id,
|
|
461
|
+
name: text(record.name) || (kind === "combo" ? id : `${provider}/${model}`),
|
|
462
|
+
kind,
|
|
463
|
+
provider,
|
|
464
|
+
model,
|
|
465
|
+
windows: normalizeWindows(record.windows),
|
|
466
|
+
fallback: normalizeMode(record.fallback),
|
|
467
|
+
officialModel: text(record.officialModel) || "deepseek-official/deepseek-flash",
|
|
468
|
+
extraRoutes: normalizeRoutes(record.extraRoutes),
|
|
469
|
+
expose: bool(record.expose, false),
|
|
470
|
+
reasoningEffort: kind === "combo" ? "" : text(record.reasoningEffort),
|
|
471
|
+
rules: normalizeRules(record.rules)
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
return out;
|
|
475
|
+
}
|
|
476
|
+
/** Normalize one authored provider retry row. */
|
|
477
|
+
function normalizeProviderRetry(raw) {
|
|
478
|
+
if (raw === null || typeof raw !== "object") return void 0;
|
|
479
|
+
const record = raw;
|
|
480
|
+
const provider = text(record.provider);
|
|
481
|
+
if (provider === "") return void 0;
|
|
482
|
+
return {
|
|
483
|
+
provider,
|
|
484
|
+
enabled: bool(record.enabled, DEFAULT_PROVIDER_RETRY.enabled),
|
|
485
|
+
maxRetries: Math.trunc(count(record.maxRetries, DEFAULT_PROVIDER_RETRY.maxRetries, 0, 100)),
|
|
486
|
+
windowMs: count(record.windowMs, DEFAULT_PROVIDER_RETRY.windowMs, 1e3, 864e5),
|
|
487
|
+
initialDelayMs: count(record.initialDelayMs, DEFAULT_PROVIDER_RETRY.initialDelayMs, 1, 6e5),
|
|
488
|
+
maxDelayMs: count(record.maxDelayMs, DEFAULT_PROVIDER_RETRY.maxDelayMs, 1, 6e5),
|
|
489
|
+
jitterRatio: ratio(record.jitterRatio, DEFAULT_PROVIDER_RETRY.jitterRatio)
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
/** Normalize the authored per-provider retry list. */
|
|
493
|
+
function normalizeProviders(raw) {
|
|
494
|
+
if (!Array.isArray(raw)) return [];
|
|
495
|
+
const out = [];
|
|
496
|
+
const seen = /* @__PURE__ */ new Set();
|
|
497
|
+
for (const item of raw) {
|
|
498
|
+
const row = normalizeProviderRetry(item);
|
|
499
|
+
if (row === void 0 || seen.has(row.provider)) continue;
|
|
500
|
+
seen.add(row.provider);
|
|
501
|
+
out.push(row);
|
|
502
|
+
}
|
|
503
|
+
return out;
|
|
504
|
+
}
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region \0dsh-css:D:\Repos\dsh-llm-router\src\client\ModelsPanel.module.css.mjs
|
|
507
|
+
const css$3 = "\n\n._c1b3c26c_panel {\n display: flex;\n flex-direction: column;\n gap: 16px;\n min-width: 0;\n}\n\n._666e6b5d_cards {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin-top: 4px;\n min-width: 0;\n}\n\n._070bb53c_card {\n display: flex;\n flex-direction: column;\n gap: 14px;\n min-width: 0;\n padding: 14px 16px;\n border-radius: 12px;\n background: var(--dsw-alias-bg-module-platform);\n}\n\n._d83cbbbe_cardHead {\n display: flex;\n align-items: center;\n gap: 8px;\n min-width: 0;\n}\n\n._b3a9407a_cardTitle {\n flex: 1 1 auto;\n min-width: 0;\n font-size: 12px;\n line-height: 18px;\n font-weight: 500;\n color: var(--dsw-alias-label-primary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n\n\n._eb328c21_group {\n display: flex;\n flex-direction: column;\n gap: 8px;\n min-width: 0;\n}\n\n._1634974d_groupTitle {\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n color: var(--dsw-alias-label-primary);\n}\n\n\n\n._10eb2316_grid {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));\n gap: 10px;\n min-width: 0;\n}\n\n._41343a46_cell {\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n}\n\n._87af396c_cellLabel {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n\n\n._a2c470a2_row {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-end;\n gap: 10px;\n min-width: 0;\n}\n\n._e9775e88_rowMid {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n min-width: 0;\n}\n\n\n._ee1b76c6_rowField {\n display: flex;\n flex-direction: column;\n gap: 4px;\n flex: 0 0 auto;\n min-width: 0;\n}\n\n._0fef9eb1_grow {\n flex: 1 1 180px;\n min-width: 150px;\n}\n\n._21606582_w90 { width: 90px; }\n\n._39a847b7_w110 { width: 110px; }\n\n._2da3b7a5_w130 { width: 130px; }\n\n._23925ec6_w180 { width: 180px; }\n\n\n._1fef9bb0_chipRow {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n flex: 0 0 auto;\n height: 34px;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n white-space: nowrap;\n cursor: pointer;\n}\n\n\n\n._c529eca5_chips {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 16px;\n min-width: 0;\n}\n\n._e0ca1b94_chip {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n line-height: 22px;\n color: var(--dsw-alias-label-primary);\n white-space: nowrap;\n cursor: pointer;\n}\n\n._e0ca1b94_chip input,\n._1fef9bb0_chipRow input,\n._03deab5c_day input {\n flex: 0 0 auto;\n margin: 0;\n}\n\n\n\n._46877afd_days {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 4px;\n}\n\n._03deab5c_day {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 2px 6px;\n border-radius: 6px;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary);\n white-space: nowrap;\n cursor: pointer;\n}\n\n._b3aafe93_arrow {\n flex: 0 0 auto;\n font-size: 12px;\n line-height: 34px;\n color: var(--dsw-alias-label-tertiary);\n}\n\n\n\n._5cd75b59_iconBtn {\n appearance: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: 28px;\n height: 28px;\n padding: 0;\n border: 0;\n border-radius: 6px;\n background: none;\n font: inherit;\n font-size: 12px;\n color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n}\n\n._5cd75b59_iconBtn:hover:not(:disabled) {\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-primary);\n}\n\n._5cd75b59_iconBtn:disabled {\n opacity: 0.5;\n cursor: default;\n}\n\n._3a75da7f_addBtn {\n appearance: none;\n align-self: flex-start;\n padding: 4px 12px;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: var(--dsw-radius-md);\n background: none;\n font: inherit;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n}\n\n._3a75da7f_addBtn:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-border-l3);\n}\n\n._3a75da7f_addBtn:disabled {\n opacity: 0.5;\n cursor: default;\n}\n";
|
|
508
|
+
const tagId$3 = "dsh-fallback-router/ModelsPanel.module.css";
|
|
509
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$3) + "]") === null) {
|
|
510
|
+
const tag = document.createElement("style");
|
|
511
|
+
tag.dataset.plugin = "dsh-fallback-router";
|
|
512
|
+
tag.dataset.pluginCss = tagId$3;
|
|
513
|
+
tag.textContent = css$3;
|
|
514
|
+
document.head.appendChild(tag);
|
|
515
|
+
}
|
|
516
|
+
var ModelsPanel_module_css_default = {
|
|
517
|
+
"panel": "_c1b3c26c_panel",
|
|
518
|
+
"cards": "_666e6b5d_cards",
|
|
519
|
+
"card": "_070bb53c_card",
|
|
520
|
+
"cardHead": "_d83cbbbe_cardHead",
|
|
521
|
+
"cardTitle": "_b3a9407a_cardTitle",
|
|
522
|
+
"group": "_eb328c21_group",
|
|
523
|
+
"groupTitle": "_1634974d_groupTitle",
|
|
524
|
+
"grid": "_10eb2316_grid",
|
|
525
|
+
"cell": "_41343a46_cell",
|
|
526
|
+
"cellLabel": "_87af396c_cellLabel",
|
|
527
|
+
"row": "_a2c470a2_row",
|
|
528
|
+
"rowMid": "_e9775e88_rowMid",
|
|
529
|
+
"rowField": "_ee1b76c6_rowField",
|
|
530
|
+
"grow": "_0fef9eb1_grow",
|
|
531
|
+
"w90": "_21606582_w90",
|
|
532
|
+
"w110": "_39a847b7_w110",
|
|
533
|
+
"w130": "_2da3b7a5_w130",
|
|
534
|
+
"w180": "_23925ec6_w180",
|
|
535
|
+
"chipRow": "_1fef9bb0_chipRow",
|
|
536
|
+
"chips": "_c529eca5_chips",
|
|
537
|
+
"chip": "_e0ca1b94_chip",
|
|
538
|
+
"day": "_03deab5c_day",
|
|
539
|
+
"days": "_46877afd_days",
|
|
540
|
+
"arrow": "_b3aafe93_arrow",
|
|
541
|
+
"iconBtn": "_5cd75b59_iconBtn",
|
|
542
|
+
"addBtn": "_3a75da7f_addBtn"
|
|
543
|
+
};
|
|
544
|
+
//#endregion
|
|
545
|
+
//#region src/client/ModelsPanel.tsx
|
|
546
|
+
/**
|
|
547
|
+
* 模型配置 (model profiles) panel — the ONLY authoring surface of
|
|
548
|
+
* dsh-fallback-router.
|
|
549
|
+
*
|
|
550
|
+
* Every row is a MODEL CONFIGURATION. Two shapes exist:
|
|
551
|
+
*
|
|
552
|
+
* - 单一模型 (`kind: 'route'`) — a `provider/model` route with its own time
|
|
553
|
+
* windows (时间区间, either a frozen preset like 梁高峰/梁低谷 or a
|
|
554
|
+
* hand-written window), its own fallback policy (官方兜底 / 循环兜底 /
|
|
555
|
+
* 不兜底), the extra hops it may try (追加兜底路由) and its own failure
|
|
556
|
+
* rules (错误码 + 正则 + 结构判定).
|
|
557
|
+
* - 自由组合 (`kind: 'combo'`) — no route of its own; every 时间区间 names an
|
|
558
|
+
* existing configuration (`使用配置`), so 梁高峰 can run config A while
|
|
559
|
+
* 梁低谷 runs config B without duplicating either one's settings.
|
|
560
|
+
*
|
|
561
|
+
* Every provider/model field is a dropdown fed by the host catalog
|
|
562
|
+
* (`llm/listConfigurableProviders` + `session/modelCatalog`); a value the
|
|
563
|
+
* catalog does not know is kept as an extra option so a hand-written route is
|
|
564
|
+
* never silently replaced, and an empty catalog degrades to a text input.
|
|
565
|
+
*
|
|
566
|
+
* The host compiles this list down to `rootChain` / `timeSlots` /
|
|
567
|
+
* `namedChains` (`withCompiledRouter`), so the chain-walking engine keeps
|
|
568
|
+
* working unchanged.
|
|
569
|
+
*
|
|
570
|
+
* The panel owns its own draft and its own Save: it writes ONLY `models` and
|
|
571
|
+
* `providers`. Everything the legacy card used to expose (the global chain,
|
|
572
|
+
* the time-slot table, the subagent roles, the advanced scalars) is
|
|
573
|
+
* deliberately NOT editable here — it is either compiled from these rows or
|
|
574
|
+
* left at whatever the config already carries.
|
|
575
|
+
*
|
|
576
|
+
* @module dsh-fallback-router/client/ModelsPanel
|
|
577
|
+
*/
|
|
578
|
+
/** Labels for the two configuration shapes. */
|
|
579
|
+
const KIND_LABELS = [{
|
|
580
|
+
kind: "route",
|
|
581
|
+
label: "单一模型",
|
|
582
|
+
hint: "配置一个 provider/模型,自己带时间区间、兜底与判定规则"
|
|
583
|
+
}, {
|
|
584
|
+
kind: "combo",
|
|
585
|
+
label: "自由组合",
|
|
586
|
+
hint: "不绑定模型:每个时间区间指定使用哪一个已有配置"
|
|
587
|
+
}];
|
|
588
|
+
/** Labels for the three fallback policies (兜底配置按钮). */
|
|
589
|
+
const MODE_LABELS = [
|
|
590
|
+
{
|
|
591
|
+
mode: "official",
|
|
592
|
+
label: "官方兜底",
|
|
593
|
+
hint: "失败后切到官方 DeepSeek 模型"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
mode: "loop",
|
|
597
|
+
label: "循环兜底",
|
|
598
|
+
hint: "按顺序切到下一个模型配置,最后一个失效后回到第一个"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
mode: "none",
|
|
602
|
+
label: "不兜底",
|
|
603
|
+
hint: "失败就停下,只保留重试"
|
|
604
|
+
}
|
|
605
|
+
];
|
|
606
|
+
/** Chinese labels of the four frozen preset windows (梁文峰 / 梁文谷 …). */
|
|
607
|
+
const PRESET_LABELS = {
|
|
608
|
+
"liang-peak": "梁文峰",
|
|
609
|
+
"liang-valley": "梁文谷",
|
|
610
|
+
"glm-peak": "GLM峰",
|
|
611
|
+
"glm-valley": "GLM谷"
|
|
612
|
+
};
|
|
613
|
+
/** One preset option row of the window editor. */
|
|
614
|
+
const PRESET_OPTIONS = [{
|
|
615
|
+
value: "",
|
|
616
|
+
label: "自定义时间段"
|
|
617
|
+
}, ...PRESET_IDS.map((id) => ({
|
|
618
|
+
value: id,
|
|
619
|
+
label: PRESET_LABELS[id]
|
|
620
|
+
}))];
|
|
621
|
+
/** The eight markers the structural detector ships with (可编辑). */
|
|
622
|
+
const MARKER_HINT = DEFAULT_MARKERS.join(" ");
|
|
623
|
+
const WEEKDAYS = [
|
|
624
|
+
"日",
|
|
625
|
+
"一",
|
|
626
|
+
"二",
|
|
627
|
+
"三",
|
|
628
|
+
"四",
|
|
629
|
+
"五",
|
|
630
|
+
"六"
|
|
631
|
+
];
|
|
632
|
+
function splitRoute(route) {
|
|
633
|
+
const text = route.trim();
|
|
634
|
+
const at = text.indexOf("/");
|
|
635
|
+
if (at < 0) return {
|
|
636
|
+
provider: text,
|
|
637
|
+
model: "",
|
|
638
|
+
reasoningEffort: ""
|
|
639
|
+
};
|
|
640
|
+
return {
|
|
641
|
+
provider: text.slice(0, at).trim(),
|
|
642
|
+
model: text.slice(at + 1).trim(),
|
|
643
|
+
reasoningEffort: ""
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
function joinRoute(row) {
|
|
647
|
+
const provider = row.provider.trim();
|
|
648
|
+
const model = row.model.trim();
|
|
649
|
+
if (provider === "" || model === "") return "";
|
|
650
|
+
return `${provider}/${model}`;
|
|
651
|
+
}
|
|
652
|
+
function rowsOf(models) {
|
|
653
|
+
return models.map((model) => ({
|
|
654
|
+
id: model.id,
|
|
655
|
+
name: model.name,
|
|
656
|
+
kind: model.kind === "combo" ? "combo" : "route",
|
|
657
|
+
provider: model.provider,
|
|
658
|
+
model: model.model,
|
|
659
|
+
fallback: model.fallback,
|
|
660
|
+
officialProvider: splitRoute(model.officialModel).provider,
|
|
661
|
+
officialModel: splitRoute(model.officialModel).model,
|
|
662
|
+
windows: model.windows.map((window) => ({
|
|
663
|
+
preset: window.preset ?? "",
|
|
664
|
+
start: window.start,
|
|
665
|
+
end: window.end,
|
|
666
|
+
days: [...window.days ?? []],
|
|
667
|
+
use: window.use ?? ""
|
|
668
|
+
})),
|
|
669
|
+
extraRoutes: normalizeRoutes(model.extraRoutes).map((hop) => ({
|
|
670
|
+
...splitRoute(hop.route),
|
|
671
|
+
reasoningEffort: hop.reasoningEffort
|
|
672
|
+
})),
|
|
673
|
+
expose: model.expose === true,
|
|
674
|
+
reasoningEffort: model.reasoningEffort ?? "",
|
|
675
|
+
codes: [...model.rules.codes],
|
|
676
|
+
customCode: "",
|
|
677
|
+
regex: model.rules.regex.join("\n"),
|
|
678
|
+
structural: model.rules.structural,
|
|
679
|
+
markers: model.rules.markers.join(" ")
|
|
680
|
+
}));
|
|
681
|
+
}
|
|
682
|
+
function splitLines(raw) {
|
|
683
|
+
return raw.split(/[\n,]+/).map((line) => line.trim()).filter((line) => line !== "");
|
|
684
|
+
}
|
|
685
|
+
function profilesOf(rows) {
|
|
686
|
+
return normalizeModelProfiles(rows.map((row, index) => {
|
|
687
|
+
const combo = row.kind === "combo";
|
|
688
|
+
return {
|
|
689
|
+
id: row.id.trim() === "" ? `model-${index + 1}` : row.id.trim(),
|
|
690
|
+
name: row.name.trim() === "" ? combo ? `组合 ${index + 1}` : row.model.trim() === "" ? `模型 ${index + 1}` : row.model.trim() : row.name.trim(),
|
|
691
|
+
kind: row.kind,
|
|
692
|
+
provider: combo ? "" : row.provider.trim(),
|
|
693
|
+
model: combo ? "" : row.model.trim(),
|
|
694
|
+
windows: row.windows.map((window) => {
|
|
695
|
+
const use = combo || window.use !== "" ? { use: window.use } : {};
|
|
696
|
+
return window.preset === "" ? {
|
|
697
|
+
start: window.start,
|
|
698
|
+
end: window.end,
|
|
699
|
+
days: [...window.days],
|
|
700
|
+
...use
|
|
701
|
+
} : {
|
|
702
|
+
preset: window.preset,
|
|
703
|
+
start: "",
|
|
704
|
+
end: "",
|
|
705
|
+
days: [],
|
|
706
|
+
...use
|
|
707
|
+
};
|
|
708
|
+
}),
|
|
709
|
+
fallback: row.fallback,
|
|
710
|
+
officialModel: joinRoute({
|
|
711
|
+
provider: row.officialProvider,
|
|
712
|
+
model: row.officialModel,
|
|
713
|
+
reasoningEffort: ""
|
|
714
|
+
}),
|
|
715
|
+
extraRoutes: row.extraRoutes.map((hop) => ({
|
|
716
|
+
route: joinRoute(hop),
|
|
717
|
+
reasoningEffort: hop.reasoningEffort.trim()
|
|
718
|
+
})).filter((hop) => hop.route !== ""),
|
|
719
|
+
expose: row.expose,
|
|
720
|
+
reasoningEffort: combo ? "" : row.reasoningEffort.trim(),
|
|
721
|
+
rules: {
|
|
722
|
+
codes: [...row.codes, ...splitLines(row.customCode)],
|
|
723
|
+
regex: row.regex.split("\n").map((line) => line.trim()).filter((line) => line !== ""),
|
|
724
|
+
structural: row.structural,
|
|
725
|
+
markers: row.markers.split(/[\s,]+/).map((marker) => marker.trim()).filter((marker) => marker !== "")
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
}));
|
|
729
|
+
}
|
|
730
|
+
function retryRowsOf(providers) {
|
|
731
|
+
return normalizeProviders(providers);
|
|
732
|
+
}
|
|
733
|
+
function newModelRow(rows) {
|
|
734
|
+
const used = new Set(rows.map((row) => row.id.trim()));
|
|
735
|
+
let serial = 1;
|
|
736
|
+
while (used.has(`model-${serial}`)) serial += 1;
|
|
737
|
+
return {
|
|
738
|
+
id: `model-${serial}`,
|
|
739
|
+
name: "",
|
|
740
|
+
kind: "route",
|
|
741
|
+
provider: "",
|
|
742
|
+
model: "",
|
|
743
|
+
fallback: "official",
|
|
744
|
+
officialProvider: "deepseek-official",
|
|
745
|
+
officialModel: "deepseek-flash",
|
|
746
|
+
windows: [],
|
|
747
|
+
extraRoutes: [],
|
|
748
|
+
expose: false,
|
|
749
|
+
reasoningEffort: "",
|
|
750
|
+
codes: [...DEFAULT_RULES_CODES],
|
|
751
|
+
customCode: "",
|
|
752
|
+
regex: "",
|
|
753
|
+
structural: true,
|
|
754
|
+
markers: DEFAULT_MARKERS.join(" ")
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
function newRetryRow(provider) {
|
|
758
|
+
return {
|
|
759
|
+
provider,
|
|
760
|
+
...DEFAULT_PROVIDER_RETRY
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function toggleCode(codes, code) {
|
|
764
|
+
return codes.includes(code) ? codes.filter((entry) => entry !== code) : [...codes, code];
|
|
765
|
+
}
|
|
766
|
+
function toggleDay(days, day) {
|
|
767
|
+
return days.includes(day) ? days.filter((entry) => entry !== day) : [...days, day].sort((a, b) => a - b);
|
|
768
|
+
}
|
|
769
|
+
/** Provider ids the dropdown offers (catalog only; the current value is added by the picker). */
|
|
770
|
+
function providerChoices(catalog) {
|
|
771
|
+
const out = /* @__PURE__ */ new Set();
|
|
772
|
+
for (const provider of catalog ?? []) out.add(provider.id);
|
|
773
|
+
return [...out].sort((left, right) => left.localeCompare(right));
|
|
774
|
+
}
|
|
775
|
+
/** Model ids one provider advertises (catalog only; the picker adds the current value). */
|
|
776
|
+
function modelChoices(catalog, provider) {
|
|
777
|
+
const out = /* @__PURE__ */ new Set();
|
|
778
|
+
const entry = (catalog ?? []).find((candidate) => candidate.id === provider.trim());
|
|
779
|
+
for (const model of entry?.models ?? []) out.add(model.id);
|
|
780
|
+
return [...out].sort((left, right) => left.localeCompare(right));
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* 推理等级 ids the chosen model advertises (catalog only; the picker adds the
|
|
784
|
+
* current value). An unknown provider/model simply has no levels, and the field
|
|
785
|
+
* degrades to free text so a hand-written effort is never lost.
|
|
786
|
+
*/
|
|
787
|
+
function effortChoices(catalog, provider, model) {
|
|
788
|
+
return (((catalog ?? []).find((candidate) => candidate.id === provider.trim())?.models ?? []).find((candidate) => candidate.id === model.trim())?.efforts ?? []).map((effort) => effort.id);
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* A catalog-backed field: the catalog drives the options, a value the catalog
|
|
792
|
+
* does not know stays selectable (a hand-written route is never silently
|
|
793
|
+
* replaced), and an empty catalog degrades to free text so a host without a
|
|
794
|
+
* catalog is still editable.
|
|
795
|
+
*/
|
|
796
|
+
function Picker({ ariaLabel, value, options, placeholder, disabled, onChange }) {
|
|
797
|
+
if (options.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
798
|
+
className: FallbacksCard_module_css_default.input,
|
|
799
|
+
value,
|
|
800
|
+
placeholder,
|
|
801
|
+
"aria-label": ariaLabel,
|
|
802
|
+
disabled,
|
|
803
|
+
onChange: (event) => {
|
|
804
|
+
onChange(event.target.value);
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
const merged = value !== "" && !options.includes(value) ? [value, ...options] : options;
|
|
808
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
809
|
+
className: FallbacksCard_module_css_default.input,
|
|
810
|
+
value,
|
|
811
|
+
"aria-label": ariaLabel,
|
|
812
|
+
disabled,
|
|
813
|
+
onChange: (event) => {
|
|
814
|
+
onChange(event.target.value);
|
|
815
|
+
},
|
|
816
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
817
|
+
value: "",
|
|
818
|
+
children: placeholder
|
|
819
|
+
}), merged.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
820
|
+
value: option,
|
|
821
|
+
children: option
|
|
822
|
+
}, option))]
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
function ModelsPanel({ config, writable, saving, onSave, catalog }) {
|
|
826
|
+
const [rows, setRows] = (0, react.useState)(() => rowsOf(config.models ?? []));
|
|
827
|
+
const [providers, setProviders] = (0, react.useState)(() => retryRowsOf(config.providers ?? []));
|
|
828
|
+
const [seeded, setSeeded] = (0, react.useState)(() => JSON.stringify([config.models, config.providers]));
|
|
829
|
+
const serverKey = JSON.stringify([config.models, config.providers]);
|
|
830
|
+
(0, react.useEffect)(() => {
|
|
831
|
+
if (serverKey === seeded) return;
|
|
832
|
+
setRows(rowsOf(config.models ?? []));
|
|
833
|
+
setProviders(retryRowsOf(config.providers ?? []));
|
|
834
|
+
setSeeded(serverKey);
|
|
835
|
+
}, [
|
|
836
|
+
serverKey,
|
|
837
|
+
seeded,
|
|
838
|
+
config.models,
|
|
839
|
+
config.providers
|
|
840
|
+
]);
|
|
841
|
+
const draft = (0, react.useMemo)(() => profilesOf(rows), [rows]);
|
|
842
|
+
const savedModels = (0, react.useMemo)(() => normalizeModelProfiles(config.models ?? []), [config.models]);
|
|
843
|
+
const savedProviders = (0, react.useMemo)(() => retryRowsOf(config.providers ?? []), [config.providers]);
|
|
844
|
+
const dirty = JSON.stringify(draft) !== JSON.stringify(savedModels) || JSON.stringify(providers) !== JSON.stringify(savedProviders);
|
|
845
|
+
const update = (index, patch) => {
|
|
846
|
+
setRows((current) => current.map((row, at) => at === index ? {
|
|
847
|
+
...row,
|
|
848
|
+
...patch
|
|
849
|
+
} : row));
|
|
850
|
+
};
|
|
851
|
+
/**
|
|
852
|
+
* The configurations one window may point at (使用配置): every OTHER
|
|
853
|
+
* single-model row. A combo can only relay to a real route, so combos are
|
|
854
|
+
* never offered — that also rules out a reference cycle by construction.
|
|
855
|
+
*/
|
|
856
|
+
const useChoicesFor = (selfIndex) => rows.map((row, at) => ({
|
|
857
|
+
row,
|
|
858
|
+
at
|
|
859
|
+
})).filter(({ row, at }) => at !== selfIndex && row.kind === "route" && row.id.trim() !== "").map(({ row }) => ({
|
|
860
|
+
id: row.id.trim(),
|
|
861
|
+
label: row.name.trim() === "" ? row.id.trim() : row.name.trim()
|
|
862
|
+
}));
|
|
863
|
+
const save = () => {
|
|
864
|
+
onSave({
|
|
865
|
+
...config,
|
|
866
|
+
models: draft,
|
|
867
|
+
providers
|
|
868
|
+
});
|
|
869
|
+
setSeeded(JSON.stringify([draft, providers]));
|
|
870
|
+
};
|
|
871
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
872
|
+
className: ModelsPanel_module_css_default.panel,
|
|
873
|
+
children: [
|
|
874
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h2", {
|
|
875
|
+
className: FallbacksCard_module_css_default.sectionHeading,
|
|
876
|
+
id: "models",
|
|
877
|
+
"aria-label": "模型配置",
|
|
878
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
879
|
+
className: FallbacksCard_module_css_default.sectionHeadingText,
|
|
880
|
+
children: "模型配置"
|
|
881
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
882
|
+
className: FallbacksCard_module_css_default.sectionActions,
|
|
883
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
884
|
+
type: "button",
|
|
885
|
+
className: FallbacksCard_module_css_default.discard,
|
|
886
|
+
disabled: !dirty || saving,
|
|
887
|
+
onClick: () => {
|
|
888
|
+
setRows(rowsOf(config.models ?? []));
|
|
889
|
+
setProviders(retryRowsOf(config.providers ?? []));
|
|
890
|
+
setSeeded(serverKey);
|
|
891
|
+
},
|
|
892
|
+
children: "撤销"
|
|
893
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
894
|
+
type: "button",
|
|
895
|
+
className: FallbacksCard_module_css_default.save,
|
|
896
|
+
disabled: !writable || saving || !dirty,
|
|
897
|
+
onClick: save,
|
|
898
|
+
children: saving ? "保存中…" : "保存"
|
|
899
|
+
})]
|
|
900
|
+
})]
|
|
901
|
+
}),
|
|
902
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
903
|
+
className: FallbacksCard_module_css_default.hint,
|
|
904
|
+
children: "每个「模型配置」是一个可路由的模型:它自己的时间区间、兜底方式与失效判定。按顺序构成降级链。"
|
|
905
|
+
}),
|
|
906
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
907
|
+
className: ModelsPanel_module_css_default.cards,
|
|
908
|
+
children: rows.map((row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
909
|
+
className: ModelsPanel_module_css_default.card,
|
|
910
|
+
children: [
|
|
911
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
912
|
+
className: ModelsPanel_module_css_default.cardHead,
|
|
913
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
914
|
+
className: ModelsPanel_module_css_default.cardTitle,
|
|
915
|
+
children: [
|
|
916
|
+
row.name.trim() === "" ? row.kind === "combo" ? `组合 ${index + 1}` : `模型 ${index + 1}` : row.name,
|
|
917
|
+
row.kind === "combo" ? ` · 自由组合(${row.windows.filter((window) => window.use !== "").length} 个区间)` : row.provider.trim() === "" || row.model.trim() === "" ? "(未填写路由)" : ` · ${row.provider}/${row.model}`,
|
|
918
|
+
row.expose ? " · 选择器可见" : ""
|
|
919
|
+
]
|
|
920
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
921
|
+
type: "button",
|
|
922
|
+
className: ModelsPanel_module_css_default.iconBtn,
|
|
923
|
+
"aria-label": "删除这个模型配置",
|
|
924
|
+
disabled: !writable,
|
|
925
|
+
onClick: () => {
|
|
926
|
+
setRows((current) => current.filter((_, at) => at !== index));
|
|
927
|
+
},
|
|
928
|
+
children: "✕"
|
|
929
|
+
})]
|
|
930
|
+
}),
|
|
931
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
932
|
+
className: ModelsPanel_module_css_default.chips,
|
|
933
|
+
role: "group",
|
|
934
|
+
"aria-label": "配置类型",
|
|
935
|
+
children: KIND_LABELS.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
936
|
+
className: ModelsPanel_module_css_default.chip,
|
|
937
|
+
title: entry.hint,
|
|
938
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
939
|
+
type: "radio",
|
|
940
|
+
className: FallbacksCard_module_css_default.checkbox,
|
|
941
|
+
name: `model-kind-${String(index)}`,
|
|
942
|
+
checked: row.kind === entry.kind,
|
|
943
|
+
disabled: !writable,
|
|
944
|
+
onChange: () => {
|
|
945
|
+
update(index, { kind: entry.kind });
|
|
946
|
+
}
|
|
947
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: entry.label })]
|
|
948
|
+
}, entry.kind))
|
|
949
|
+
}),
|
|
950
|
+
row.kind === "route" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
951
|
+
className: ModelsPanel_module_css_default.grid,
|
|
952
|
+
children: [
|
|
953
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
954
|
+
className: ModelsPanel_module_css_default.cell,
|
|
955
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
956
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
957
|
+
children: "名称"
|
|
958
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
959
|
+
className: FallbacksCard_module_css_default.input,
|
|
960
|
+
value: row.name,
|
|
961
|
+
placeholder: `模型 ${index + 1}`,
|
|
962
|
+
onChange: (event) => {
|
|
963
|
+
update(index, { name: event.target.value });
|
|
964
|
+
}
|
|
965
|
+
})]
|
|
966
|
+
}),
|
|
967
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
968
|
+
className: ModelsPanel_module_css_default.cell,
|
|
969
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
970
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
971
|
+
children: "Provider"
|
|
972
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
973
|
+
ariaLabel: "Provider",
|
|
974
|
+
value: row.provider,
|
|
975
|
+
options: providerChoices(catalog),
|
|
976
|
+
placeholder: "选择 Provider",
|
|
977
|
+
disabled: !writable,
|
|
978
|
+
onChange: (next) => {
|
|
979
|
+
update(index, {
|
|
980
|
+
provider: next,
|
|
981
|
+
reasoningEffort: ""
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
})]
|
|
985
|
+
}),
|
|
986
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
987
|
+
className: ModelsPanel_module_css_default.cell,
|
|
988
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
989
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
990
|
+
children: "模型"
|
|
991
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
992
|
+
ariaLabel: "模型",
|
|
993
|
+
value: row.model,
|
|
994
|
+
options: modelChoices(catalog, row.provider),
|
|
995
|
+
placeholder: "选择模型",
|
|
996
|
+
disabled: !writable,
|
|
997
|
+
onChange: (next) => {
|
|
998
|
+
update(index, {
|
|
999
|
+
model: next,
|
|
1000
|
+
reasoningEffort: ""
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
})]
|
|
1004
|
+
}),
|
|
1005
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1006
|
+
className: ModelsPanel_module_css_default.cell,
|
|
1007
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1008
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1009
|
+
children: "推理等级"
|
|
1010
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
1011
|
+
ariaLabel: "推理等级",
|
|
1012
|
+
value: row.reasoningEffort,
|
|
1013
|
+
options: effortChoices(catalog, row.provider, row.model),
|
|
1014
|
+
placeholder: "跟随模型默认",
|
|
1015
|
+
disabled: !writable,
|
|
1016
|
+
onChange: (next) => {
|
|
1017
|
+
update(index, { reasoningEffort: next });
|
|
1018
|
+
}
|
|
1019
|
+
})]
|
|
1020
|
+
})
|
|
1021
|
+
]
|
|
1022
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1023
|
+
className: ModelsPanel_module_css_default.grid,
|
|
1024
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1025
|
+
className: ModelsPanel_module_css_default.cell,
|
|
1026
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1027
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1028
|
+
children: "名称"
|
|
1029
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1030
|
+
className: FallbacksCard_module_css_default.input,
|
|
1031
|
+
value: row.name,
|
|
1032
|
+
placeholder: `组合 ${index + 1}`,
|
|
1033
|
+
onChange: (event) => {
|
|
1034
|
+
update(index, { name: event.target.value });
|
|
1035
|
+
}
|
|
1036
|
+
})]
|
|
1037
|
+
})
|
|
1038
|
+
}),
|
|
1039
|
+
row.kind === "route" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1040
|
+
className: ModelsPanel_module_css_default.group,
|
|
1041
|
+
role: "group",
|
|
1042
|
+
"aria-label": "兜底配置",
|
|
1043
|
+
children: [
|
|
1044
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1045
|
+
className: ModelsPanel_module_css_default.groupTitle,
|
|
1046
|
+
children: "兜底配置"
|
|
1047
|
+
}),
|
|
1048
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1049
|
+
className: ModelsPanel_module_css_default.chips,
|
|
1050
|
+
children: MODE_LABELS.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1051
|
+
className: ModelsPanel_module_css_default.chip,
|
|
1052
|
+
title: entry.hint,
|
|
1053
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1054
|
+
type: "radio",
|
|
1055
|
+
className: FallbacksCard_module_css_default.checkbox,
|
|
1056
|
+
name: `fallback-mode-${String(index)}`,
|
|
1057
|
+
checked: row.fallback === entry.mode,
|
|
1058
|
+
disabled: !writable,
|
|
1059
|
+
onChange: () => {
|
|
1060
|
+
update(index, { fallback: entry.mode });
|
|
1061
|
+
}
|
|
1062
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: entry.label })]
|
|
1063
|
+
}, entry.mode))
|
|
1064
|
+
}),
|
|
1065
|
+
row.fallback === "official" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1066
|
+
className: ModelsPanel_module_css_default.grid,
|
|
1067
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1068
|
+
className: ModelsPanel_module_css_default.cell,
|
|
1069
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1070
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1071
|
+
children: "官方兜底 Provider"
|
|
1072
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
1073
|
+
ariaLabel: "官方兜底 Provider",
|
|
1074
|
+
value: row.officialProvider,
|
|
1075
|
+
options: providerChoices(catalog),
|
|
1076
|
+
placeholder: "deepseek-official",
|
|
1077
|
+
disabled: !writable,
|
|
1078
|
+
onChange: (next) => {
|
|
1079
|
+
update(index, { officialProvider: next });
|
|
1080
|
+
}
|
|
1081
|
+
})]
|
|
1082
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1083
|
+
className: ModelsPanel_module_css_default.cell,
|
|
1084
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1085
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1086
|
+
children: "官方兜底模型"
|
|
1087
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
1088
|
+
ariaLabel: "官方兜底模型",
|
|
1089
|
+
value: row.officialModel,
|
|
1090
|
+
options: modelChoices(catalog, row.officialProvider),
|
|
1091
|
+
placeholder: "deepseek-flash",
|
|
1092
|
+
disabled: !writable,
|
|
1093
|
+
onChange: (next) => {
|
|
1094
|
+
update(index, { officialModel: next });
|
|
1095
|
+
}
|
|
1096
|
+
})]
|
|
1097
|
+
})]
|
|
1098
|
+
}),
|
|
1099
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1100
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1101
|
+
children: MODE_LABELS.find((entry) => entry.mode === row.fallback)?.hint ?? ""
|
|
1102
|
+
}),
|
|
1103
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1104
|
+
className: ModelsPanel_module_css_default.groupTitle,
|
|
1105
|
+
children: "追加兜底路由"
|
|
1106
|
+
}),
|
|
1107
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1108
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1109
|
+
children: "按顺序在主路由之后、官方兜底之前尝试。"
|
|
1110
|
+
}),
|
|
1111
|
+
row.extraRoutes.map((route, at) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1112
|
+
className: ModelsPanel_module_css_default.row,
|
|
1113
|
+
children: [
|
|
1114
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1115
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.grow}`,
|
|
1116
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1117
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1118
|
+
children: "Provider"
|
|
1119
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
1120
|
+
ariaLabel: "追加路由 Provider",
|
|
1121
|
+
value: route.provider,
|
|
1122
|
+
options: providerChoices(catalog),
|
|
1123
|
+
placeholder: "选择 Provider",
|
|
1124
|
+
disabled: !writable,
|
|
1125
|
+
onChange: (next) => {
|
|
1126
|
+
const extraRoutes = row.extraRoutes.map((item, position) => position === at ? {
|
|
1127
|
+
...item,
|
|
1128
|
+
provider: next,
|
|
1129
|
+
model: "",
|
|
1130
|
+
reasoningEffort: ""
|
|
1131
|
+
} : item);
|
|
1132
|
+
update(index, { extraRoutes });
|
|
1133
|
+
}
|
|
1134
|
+
})]
|
|
1135
|
+
}),
|
|
1136
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1137
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.grow}`,
|
|
1138
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1139
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1140
|
+
children: "模型"
|
|
1141
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
1142
|
+
ariaLabel: "追加路由模型",
|
|
1143
|
+
value: route.model,
|
|
1144
|
+
options: modelChoices(catalog, route.provider),
|
|
1145
|
+
placeholder: "选择模型",
|
|
1146
|
+
disabled: !writable,
|
|
1147
|
+
onChange: (next) => {
|
|
1148
|
+
const extraRoutes = row.extraRoutes.map((item, position) => position === at ? {
|
|
1149
|
+
...item,
|
|
1150
|
+
model: next,
|
|
1151
|
+
reasoningEffort: ""
|
|
1152
|
+
} : item);
|
|
1153
|
+
update(index, { extraRoutes });
|
|
1154
|
+
}
|
|
1155
|
+
})]
|
|
1156
|
+
}),
|
|
1157
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1158
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.grow}`,
|
|
1159
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1160
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1161
|
+
children: "推理等级"
|
|
1162
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
1163
|
+
ariaLabel: "追加路由推理等级",
|
|
1164
|
+
value: route.reasoningEffort,
|
|
1165
|
+
options: effortChoices(catalog, route.provider, route.model),
|
|
1166
|
+
placeholder: "跟随系统",
|
|
1167
|
+
disabled: !writable,
|
|
1168
|
+
onChange: (next) => {
|
|
1169
|
+
const extraRoutes = row.extraRoutes.map((item, position) => position === at ? {
|
|
1170
|
+
...item,
|
|
1171
|
+
reasoningEffort: next
|
|
1172
|
+
} : item);
|
|
1173
|
+
update(index, { extraRoutes });
|
|
1174
|
+
}
|
|
1175
|
+
})]
|
|
1176
|
+
}),
|
|
1177
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1178
|
+
type: "button",
|
|
1179
|
+
className: ModelsPanel_module_css_default.iconBtn,
|
|
1180
|
+
"aria-label": "删除这条追加路由",
|
|
1181
|
+
disabled: !writable,
|
|
1182
|
+
onClick: () => {
|
|
1183
|
+
update(index, { extraRoutes: row.extraRoutes.filter((_, position) => position !== at) });
|
|
1184
|
+
},
|
|
1185
|
+
children: "✕"
|
|
1186
|
+
})
|
|
1187
|
+
]
|
|
1188
|
+
}, at)),
|
|
1189
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1190
|
+
type: "button",
|
|
1191
|
+
className: ModelsPanel_module_css_default.addBtn,
|
|
1192
|
+
disabled: !writable,
|
|
1193
|
+
onClick: () => {
|
|
1194
|
+
update(index, { extraRoutes: [...row.extraRoutes, {
|
|
1195
|
+
provider: "",
|
|
1196
|
+
model: "",
|
|
1197
|
+
reasoningEffort: ""
|
|
1198
|
+
}] });
|
|
1199
|
+
},
|
|
1200
|
+
children: "+ 追加兜底路由"
|
|
1201
|
+
})
|
|
1202
|
+
]
|
|
1203
|
+
}),
|
|
1204
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1205
|
+
className: ModelsPanel_module_css_default.group,
|
|
1206
|
+
role: "group",
|
|
1207
|
+
"aria-label": "选择器可见",
|
|
1208
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1209
|
+
className: ModelsPanel_module_css_default.chip,
|
|
1210
|
+
title: "勾选后这个模型配置会出现在模型选择器里(FallbacksChain 下)",
|
|
1211
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1212
|
+
type: "checkbox",
|
|
1213
|
+
className: FallbacksCard_module_css_default.checkbox,
|
|
1214
|
+
checked: row.expose,
|
|
1215
|
+
disabled: !writable,
|
|
1216
|
+
onChange: () => {
|
|
1217
|
+
update(index, { expose: !row.expose });
|
|
1218
|
+
}
|
|
1219
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "在模型选择器里显示" })]
|
|
1220
|
+
}), row.kind === "combo" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1221
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1222
|
+
children: "组合在模型选择器里显示为它各区间链按顺序拼接的固定降级链;实际分时仍按时间区间生效。"
|
|
1223
|
+
})]
|
|
1224
|
+
}),
|
|
1225
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1226
|
+
className: ModelsPanel_module_css_default.group,
|
|
1227
|
+
role: "group",
|
|
1228
|
+
"aria-label": "时间区间",
|
|
1229
|
+
children: [
|
|
1230
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1231
|
+
className: ModelsPanel_module_css_default.groupTitle,
|
|
1232
|
+
children: "时间区间"
|
|
1233
|
+
}),
|
|
1234
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1235
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1236
|
+
children: "留空表示全天可用;命中任一行时这个模型生效。"
|
|
1237
|
+
}),
|
|
1238
|
+
row.kind === "combo" && useChoicesFor(index).length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1239
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1240
|
+
children: "先创建至少一个「单一模型」配置,组合才有可选的配置。"
|
|
1241
|
+
}),
|
|
1242
|
+
row.windows.map((window, at) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1243
|
+
className: ModelsPanel_module_css_default.rowMid,
|
|
1244
|
+
children: [
|
|
1245
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1246
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.w180}`,
|
|
1247
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
1248
|
+
className: FallbacksCard_module_css_default.input,
|
|
1249
|
+
value: window.preset,
|
|
1250
|
+
"aria-label": "时间段预设",
|
|
1251
|
+
disabled: !writable,
|
|
1252
|
+
onChange: (event) => {
|
|
1253
|
+
const preset = event.target.value;
|
|
1254
|
+
const windows = row.windows.map((item, position) => position === at ? {
|
|
1255
|
+
...item,
|
|
1256
|
+
preset
|
|
1257
|
+
} : item);
|
|
1258
|
+
update(index, { windows });
|
|
1259
|
+
},
|
|
1260
|
+
children: PRESET_OPTIONS.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1261
|
+
value: option.value,
|
|
1262
|
+
children: option.label
|
|
1263
|
+
}, option.value))
|
|
1264
|
+
})
|
|
1265
|
+
}),
|
|
1266
|
+
window.preset === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1267
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1268
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.w90}`,
|
|
1269
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1270
|
+
className: FallbacksCard_module_css_default.input,
|
|
1271
|
+
value: window.start,
|
|
1272
|
+
placeholder: "09:00",
|
|
1273
|
+
"aria-label": "开始时间",
|
|
1274
|
+
onChange: (event) => {
|
|
1275
|
+
const windows = row.windows.map((item, position) => position === at ? {
|
|
1276
|
+
...item,
|
|
1277
|
+
start: event.target.value
|
|
1278
|
+
} : item);
|
|
1279
|
+
update(index, { windows });
|
|
1280
|
+
}
|
|
1281
|
+
})
|
|
1282
|
+
}),
|
|
1283
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1284
|
+
className: ModelsPanel_module_css_default.arrow,
|
|
1285
|
+
children: "→"
|
|
1286
|
+
}),
|
|
1287
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1288
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.w90}`,
|
|
1289
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1290
|
+
className: FallbacksCard_module_css_default.input,
|
|
1291
|
+
value: window.end,
|
|
1292
|
+
placeholder: "12:00",
|
|
1293
|
+
"aria-label": "结束时间",
|
|
1294
|
+
onChange: (event) => {
|
|
1295
|
+
const windows = row.windows.map((item, position) => position === at ? {
|
|
1296
|
+
...item,
|
|
1297
|
+
end: event.target.value
|
|
1298
|
+
} : item);
|
|
1299
|
+
update(index, { windows });
|
|
1300
|
+
}
|
|
1301
|
+
})
|
|
1302
|
+
}),
|
|
1303
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1304
|
+
className: ModelsPanel_module_css_default.days,
|
|
1305
|
+
children: WEEKDAYS.map((label, day) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1306
|
+
className: ModelsPanel_module_css_default.day,
|
|
1307
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1308
|
+
type: "checkbox",
|
|
1309
|
+
className: FallbacksCard_module_css_default.checkbox,
|
|
1310
|
+
checked: window.days.includes(day),
|
|
1311
|
+
disabled: !writable,
|
|
1312
|
+
onChange: () => {
|
|
1313
|
+
const windows = row.windows.map((item, position) => position === at ? {
|
|
1314
|
+
...item,
|
|
1315
|
+
days: toggleDay(item.days, day)
|
|
1316
|
+
} : item);
|
|
1317
|
+
update(index, { windows });
|
|
1318
|
+
}
|
|
1319
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label })]
|
|
1320
|
+
}, day))
|
|
1321
|
+
})
|
|
1322
|
+
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1323
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1324
|
+
children: [PRESET_LABELS[window.preset] ?? window.preset, "(预设时间段)"]
|
|
1325
|
+
}),
|
|
1326
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1327
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.w180}`,
|
|
1328
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
1329
|
+
className: FallbacksCard_module_css_default.input,
|
|
1330
|
+
value: window.use,
|
|
1331
|
+
"aria-label": "使用配置",
|
|
1332
|
+
disabled: !writable,
|
|
1333
|
+
onChange: (event) => {
|
|
1334
|
+
const use = event.target.value;
|
|
1335
|
+
const windows = row.windows.map((item, position) => position === at ? {
|
|
1336
|
+
...item,
|
|
1337
|
+
use
|
|
1338
|
+
} : item);
|
|
1339
|
+
update(index, { windows });
|
|
1340
|
+
},
|
|
1341
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1342
|
+
value: "",
|
|
1343
|
+
children: row.kind === "route" ? "本模型" : "选择配置"
|
|
1344
|
+
}), useChoicesFor(index).map((choice) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1345
|
+
value: choice.id,
|
|
1346
|
+
children: choice.label
|
|
1347
|
+
}, choice.id))]
|
|
1348
|
+
})
|
|
1349
|
+
}),
|
|
1350
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1351
|
+
type: "button",
|
|
1352
|
+
className: ModelsPanel_module_css_default.iconBtn,
|
|
1353
|
+
"aria-label": "删除这个时间区间",
|
|
1354
|
+
disabled: !writable,
|
|
1355
|
+
onClick: () => {
|
|
1356
|
+
update(index, { windows: row.windows.filter((_, position) => position !== at) });
|
|
1357
|
+
},
|
|
1358
|
+
children: "✕"
|
|
1359
|
+
})
|
|
1360
|
+
]
|
|
1361
|
+
}, at)),
|
|
1362
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1363
|
+
type: "button",
|
|
1364
|
+
className: ModelsPanel_module_css_default.addBtn,
|
|
1365
|
+
disabled: !writable,
|
|
1366
|
+
onClick: () => {
|
|
1367
|
+
update(index, { windows: [...row.windows, {
|
|
1368
|
+
preset: "",
|
|
1369
|
+
start: "09:00",
|
|
1370
|
+
end: "12:00",
|
|
1371
|
+
days: [],
|
|
1372
|
+
use: ""
|
|
1373
|
+
}] });
|
|
1374
|
+
},
|
|
1375
|
+
children: "+ 时间区间"
|
|
1376
|
+
})
|
|
1377
|
+
]
|
|
1378
|
+
}),
|
|
1379
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1380
|
+
className: ModelsPanel_module_css_default.group,
|
|
1381
|
+
role: "group",
|
|
1382
|
+
"aria-label": "失效判定",
|
|
1383
|
+
children: [
|
|
1384
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1385
|
+
className: ModelsPanel_module_css_default.groupTitle,
|
|
1386
|
+
children: "失效判定"
|
|
1387
|
+
}),
|
|
1388
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1389
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1390
|
+
children: "勾选的错误码触发兜底;正则匹配错误信息;结构判定捕捉「工具调用被截断」。"
|
|
1391
|
+
}),
|
|
1392
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1393
|
+
className: ModelsPanel_module_css_default.chips,
|
|
1394
|
+
children: DEFAULT_RULES_CODES.map((code) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1395
|
+
className: ModelsPanel_module_css_default.chip,
|
|
1396
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1397
|
+
type: "checkbox",
|
|
1398
|
+
className: FallbacksCard_module_css_default.checkbox,
|
|
1399
|
+
checked: row.codes.includes(code),
|
|
1400
|
+
disabled: !writable,
|
|
1401
|
+
onChange: () => {
|
|
1402
|
+
update(index, { codes: toggleCode(row.codes, code) });
|
|
1403
|
+
}
|
|
1404
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: code })]
|
|
1405
|
+
}, code))
|
|
1406
|
+
}),
|
|
1407
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1408
|
+
className: FallbacksCard_module_css_default.input,
|
|
1409
|
+
value: row.customCode,
|
|
1410
|
+
placeholder: "追加错误码,空格分隔",
|
|
1411
|
+
"aria-label": "追加错误码",
|
|
1412
|
+
onChange: (event) => {
|
|
1413
|
+
update(index, { customCode: event.target.value });
|
|
1414
|
+
}
|
|
1415
|
+
}),
|
|
1416
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
1417
|
+
className: `${FallbacksCard_module_css_default.input} ${FallbacksCard_module_css_default.inputTextarea}`,
|
|
1418
|
+
value: row.regex,
|
|
1419
|
+
placeholder: "正则,每行一条,例如:\\b50\\d\\b|upstream rejected",
|
|
1420
|
+
"aria-label": "正则规则",
|
|
1421
|
+
rows: 2,
|
|
1422
|
+
onChange: (event) => {
|
|
1423
|
+
update(index, { regex: event.target.value });
|
|
1424
|
+
}
|
|
1425
|
+
}),
|
|
1426
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1427
|
+
className: ModelsPanel_module_css_default.chip,
|
|
1428
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1429
|
+
type: "checkbox",
|
|
1430
|
+
className: FallbacksCard_module_css_default.checkbox,
|
|
1431
|
+
checked: row.structural,
|
|
1432
|
+
disabled: !writable,
|
|
1433
|
+
onChange: () => {
|
|
1434
|
+
update(index, { structural: !row.structural });
|
|
1435
|
+
}
|
|
1436
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "结构判定(工具调用残片)" })]
|
|
1437
|
+
}),
|
|
1438
|
+
row.structural && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1439
|
+
className: FallbacksCard_module_css_default.input,
|
|
1440
|
+
value: row.markers,
|
|
1441
|
+
placeholder: MARKER_HINT,
|
|
1442
|
+
"aria-label": "结构判定标记",
|
|
1443
|
+
onChange: (event) => {
|
|
1444
|
+
update(index, { markers: event.target.value });
|
|
1445
|
+
}
|
|
1446
|
+
})
|
|
1447
|
+
]
|
|
1448
|
+
})
|
|
1449
|
+
]
|
|
1450
|
+
}, index))
|
|
1451
|
+
}),
|
|
1452
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1453
|
+
type: "button",
|
|
1454
|
+
className: ModelsPanel_module_css_default.addBtn,
|
|
1455
|
+
disabled: !writable,
|
|
1456
|
+
onClick: () => {
|
|
1457
|
+
setRows((current) => [...current, newModelRow(current)]);
|
|
1458
|
+
},
|
|
1459
|
+
children: "+ 新增模型配置"
|
|
1460
|
+
}),
|
|
1461
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1462
|
+
className: ModelsPanel_module_css_default.group,
|
|
1463
|
+
role: "group",
|
|
1464
|
+
"aria-label": "Provider 重试",
|
|
1465
|
+
children: [
|
|
1466
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1467
|
+
className: ModelsPanel_module_css_default.groupTitle,
|
|
1468
|
+
children: "Provider 重试"
|
|
1469
|
+
}),
|
|
1470
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1471
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1472
|
+
children: "每个 provider 单独开启:窗口内失败次数未超过上限时先重试,超过后按上面的兜底配置切换。"
|
|
1473
|
+
}),
|
|
1474
|
+
providers.map((row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1475
|
+
className: ModelsPanel_module_css_default.row,
|
|
1476
|
+
children: [
|
|
1477
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1478
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.grow}`,
|
|
1479
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1480
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1481
|
+
children: "Provider"
|
|
1482
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Picker, {
|
|
1483
|
+
ariaLabel: "Provider",
|
|
1484
|
+
value: row.provider,
|
|
1485
|
+
options: providerChoices(catalog),
|
|
1486
|
+
placeholder: "选择 Provider",
|
|
1487
|
+
disabled: !writable,
|
|
1488
|
+
onChange: (next) => {
|
|
1489
|
+
setProviders((current) => current.map((item, at) => at === index ? {
|
|
1490
|
+
...item,
|
|
1491
|
+
provider: next
|
|
1492
|
+
} : item));
|
|
1493
|
+
}
|
|
1494
|
+
})]
|
|
1495
|
+
}),
|
|
1496
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1497
|
+
className: ModelsPanel_module_css_default.chipRow,
|
|
1498
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1499
|
+
type: "checkbox",
|
|
1500
|
+
className: FallbacksCard_module_css_default.checkbox,
|
|
1501
|
+
checked: row.enabled,
|
|
1502
|
+
disabled: !writable,
|
|
1503
|
+
onChange: () => {
|
|
1504
|
+
setProviders((current) => current.map((item, at) => at === index ? {
|
|
1505
|
+
...item,
|
|
1506
|
+
enabled: !item.enabled
|
|
1507
|
+
} : item));
|
|
1508
|
+
}
|
|
1509
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "启用" })]
|
|
1510
|
+
}),
|
|
1511
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1512
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.w110}`,
|
|
1513
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1514
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1515
|
+
children: "重试次数"
|
|
1516
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1517
|
+
className: FallbacksCard_module_css_default.input,
|
|
1518
|
+
type: "number",
|
|
1519
|
+
min: 0,
|
|
1520
|
+
max: 100,
|
|
1521
|
+
value: row.maxRetries,
|
|
1522
|
+
onChange: (event) => {
|
|
1523
|
+
const value = Number(event.target.value);
|
|
1524
|
+
setProviders((current) => current.map((item, at) => at === index ? {
|
|
1525
|
+
...item,
|
|
1526
|
+
maxRetries: Number.isFinite(value) ? value : item.maxRetries
|
|
1527
|
+
} : item));
|
|
1528
|
+
}
|
|
1529
|
+
})]
|
|
1530
|
+
}),
|
|
1531
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1532
|
+
className: `${ModelsPanel_module_css_default.rowField} ${ModelsPanel_module_css_default.w130}`,
|
|
1533
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1534
|
+
className: ModelsPanel_module_css_default.cellLabel,
|
|
1535
|
+
children: "窗口(ms)"
|
|
1536
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1537
|
+
className: FallbacksCard_module_css_default.input,
|
|
1538
|
+
type: "number",
|
|
1539
|
+
min: 1e3,
|
|
1540
|
+
step: 1e3,
|
|
1541
|
+
value: row.windowMs,
|
|
1542
|
+
onChange: (event) => {
|
|
1543
|
+
const value = Number(event.target.value);
|
|
1544
|
+
setProviders((current) => current.map((item, at) => at === index ? {
|
|
1545
|
+
...item,
|
|
1546
|
+
windowMs: Number.isFinite(value) ? value : item.windowMs
|
|
1547
|
+
} : item));
|
|
1548
|
+
}
|
|
1549
|
+
})]
|
|
1550
|
+
}),
|
|
1551
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1552
|
+
type: "button",
|
|
1553
|
+
className: ModelsPanel_module_css_default.iconBtn,
|
|
1554
|
+
"aria-label": "删除这个 provider 重试配置",
|
|
1555
|
+
disabled: !writable,
|
|
1556
|
+
onClick: () => {
|
|
1557
|
+
setProviders((current) => current.filter((_, at) => at !== index));
|
|
1558
|
+
},
|
|
1559
|
+
children: "✕"
|
|
1560
|
+
})
|
|
1561
|
+
]
|
|
1562
|
+
}, index)),
|
|
1563
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1564
|
+
type: "button",
|
|
1565
|
+
className: ModelsPanel_module_css_default.addBtn,
|
|
1566
|
+
disabled: !writable,
|
|
1567
|
+
onClick: () => {
|
|
1568
|
+
setProviders((current) => [...current, newRetryRow("")]);
|
|
1569
|
+
},
|
|
1570
|
+
children: "+ 新增 provider"
|
|
1571
|
+
})
|
|
1572
|
+
]
|
|
1573
|
+
})
|
|
1574
|
+
]
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
//#endregion
|
|
1578
|
+
//#region src/client/FallbacksCard.tsx
|
|
1579
|
+
/**
|
|
1580
|
+
* The `llm-router` plugin card on the web Plugins page.
|
|
1581
|
+
*
|
|
1582
|
+
* SCOPE (deliberate, post-merge): the card renders ONE thing — the 模型配置
|
|
1583
|
+
* panel. The legacy fallbacks surface (the global 默认降级链 editor, the
|
|
1584
|
+
* time-slot table, the subagent role list, the advanced scalars) is not
|
|
1585
|
+
* editable here any more:
|
|
1586
|
+
*
|
|
1587
|
+
* - `rootChain` / `timeSlots` / `namedChains` are COMPILED from the model
|
|
1588
|
+
* rows by `withCompiledRouter`, so hand-editing them would be overwritten
|
|
1589
|
+
* on the next read;
|
|
1590
|
+
* - `roles` / `cooldownMs` / `revertPolicy` / `presets` / `tz` keep whatever
|
|
1591
|
+
* the composed config already carries — a save writes only `models` and
|
|
1592
|
+
* `providers`, so nothing is dropped;
|
|
1593
|
+
* - provider API keys and other credentials belong to the provider plugins
|
|
1594
|
+
* (`llm-pi-ai`, …) and are never surfaced (let alone made editable) here.
|
|
1595
|
+
*
|
|
1596
|
+
* The card is a thin shell around {@link ModelsPanel}: it loads the store on
|
|
1597
|
+
* mount, renders the channel/error notices, and hands the panel the write
|
|
1598
|
+
* gate. All authoring logic lives in the panel.
|
|
1599
|
+
*/
|
|
1600
|
+
function FallbacksCard({ controller, useSnapshot }) {
|
|
1601
|
+
const state = useSnapshot((snapshot) => snapshot);
|
|
1602
|
+
(0, react.useEffect)(() => {
|
|
1603
|
+
const snapshot = controller.store.getSnapshot();
|
|
1604
|
+
if (snapshot.status === "idle") controller.load();
|
|
1605
|
+
if (snapshot.catalogStatus === "idle") controller.loadCatalog();
|
|
1606
|
+
}, [controller]);
|
|
1607
|
+
const saving = state.status === "saving";
|
|
1608
|
+
const catalog = (0, react.useMemo)(() => state.catalogProviders.map((entry) => ({
|
|
1609
|
+
id: entry.id,
|
|
1610
|
+
name: entry.id,
|
|
1611
|
+
models: entry.models
|
|
1612
|
+
})), [state.catalogProviders]);
|
|
1613
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
1614
|
+
state.legacyKeys.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1615
|
+
className: FallbacksCard_module_css_default.legacyNotice,
|
|
1616
|
+
role: "status",
|
|
1617
|
+
children: [
|
|
1618
|
+
"检测到旧版配置键:",
|
|
1619
|
+
state.legacyKeys.join("、"),
|
|
1620
|
+
"。它们仍然生效,但不再有编辑界面。"
|
|
1621
|
+
]
|
|
1622
|
+
}) : null,
|
|
1623
|
+
state.error !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1624
|
+
className: FallbacksCard_module_css_default.noticeRow,
|
|
1625
|
+
role: "alert",
|
|
1626
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1627
|
+
className: FallbacksCard_module_css_default.error,
|
|
1628
|
+
children: state.error
|
|
1629
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1630
|
+
type: "button",
|
|
1631
|
+
className: FallbacksCard_module_css_default.outlineButton,
|
|
1632
|
+
onClick: () => {
|
|
1633
|
+
controller.load();
|
|
1634
|
+
},
|
|
1635
|
+
children: "重试"
|
|
1636
|
+
})]
|
|
1637
|
+
}) : null,
|
|
1638
|
+
state.error === null && state.status === "ready" && !state.present ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1639
|
+
className: FallbacksCard_module_css_default.noticeRow,
|
|
1640
|
+
role: "status",
|
|
1641
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1642
|
+
className: FallbacksCard_module_css_default.hint,
|
|
1643
|
+
children: "配置通道未连通,下面显示的是默认值(不是你保存的配置)。"
|
|
1644
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1645
|
+
type: "button",
|
|
1646
|
+
className: FallbacksCard_module_css_default.outlineButton,
|
|
1647
|
+
onClick: () => {
|
|
1648
|
+
controller.load();
|
|
1649
|
+
},
|
|
1650
|
+
children: "重新读取"
|
|
1651
|
+
})]
|
|
1652
|
+
}) : null,
|
|
1653
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelsPanel, {
|
|
1654
|
+
config: state.config,
|
|
1655
|
+
catalog,
|
|
1656
|
+
writable: state.writable,
|
|
1657
|
+
saving,
|
|
1658
|
+
onSave: (next) => {
|
|
1659
|
+
controller.save(next);
|
|
1660
|
+
}
|
|
1661
|
+
})
|
|
1662
|
+
] });
|
|
1663
|
+
}
|
|
1664
|
+
//#endregion
|
|
1665
|
+
//#region src/config.ts
|
|
1666
|
+
/**
|
|
1667
|
+
* Spec §4 defaults — `Config({})` must equal this (no-op install).
|
|
1668
|
+
* There is no `enabled` default (the key is removed — the Plugins-page row
|
|
1669
|
+
* toggle is the master switch): an unconfigured install (empty rootChain,
|
|
1670
|
+
* no time slots, empty roles) behaves exactly like an uninstalled plugin
|
|
1671
|
+
* (AC-3 / no-op invariant, {@link isFallbackActive}).
|
|
1672
|
+
*/
|
|
1673
|
+
const defaultFallbacksConfig = {
|
|
1674
|
+
models: [],
|
|
1675
|
+
providers: [],
|
|
1676
|
+
triggerCodes: [
|
|
1677
|
+
"AUTH",
|
|
1678
|
+
"QUOTA",
|
|
1679
|
+
"RATE_LIMIT",
|
|
1680
|
+
"SERVER"
|
|
1681
|
+
],
|
|
1682
|
+
rootChain: [],
|
|
1683
|
+
roles: {
|
|
1684
|
+
list: [],
|
|
1685
|
+
rules: []
|
|
1686
|
+
},
|
|
1687
|
+
namedChains: [],
|
|
1688
|
+
cooldownMs: 3e5,
|
|
1689
|
+
revertPolicy: "cooldown-expiry",
|
|
1690
|
+
maxSwitchesPerStep: 8,
|
|
1691
|
+
alwaysModeRetryCap: 5,
|
|
1692
|
+
presets: "bundled",
|
|
1693
|
+
roleAutoMatch: true,
|
|
1694
|
+
timeSlots: [],
|
|
1695
|
+
tz: "Asia/Shanghai",
|
|
1696
|
+
recovery: "timer"
|
|
1697
|
+
};
|
|
1698
|
+
/**
|
|
1699
|
+
* The no-op gate (AC-8), re-keyed from the removed `enabled` switch to
|
|
1700
|
+
* CONTENT PRESENCE (plan fallbacks-web-ux-alignment T2): the plugin
|
|
1701
|
+
* intervenes exactly when something is configured — a non-empty `rootChain`
|
|
1702
|
+
* (the all-day chain), at least one time-slot row, or at least one declared
|
|
1703
|
+
* role. An inactive config is a pass-through exactly like an uninstalled
|
|
1704
|
+
* plugin; the Plugins-page row toggle remains the master switch (row
|
|
1705
|
+
* disable = fiber destroy). ONE helper for every runtime gate — the former
|
|
1706
|
+
* `config.enabled` sites (request waterfalls, picker-row registration, TUI
|
|
1707
|
+
* summary, General-row badge) all read through this.
|
|
1708
|
+
*/
|
|
1709
|
+
function isFallbackActive(config) {
|
|
1710
|
+
return (config.models?.length ?? 0) > 0 || config.rootChain.length > 0 || (config.timeSlots?.length ?? 0) > 0 || config.roles.list.length > 0 || (config.namedChains?.length ?? 0) > 0;
|
|
1711
|
+
}
|
|
1712
|
+
//#endregion
|
|
1713
|
+
//#region src/client/locales.ts
|
|
1714
|
+
/**
|
|
1715
|
+
* Fallbacks settings section dictionaries (zh source of truth) plus the
|
|
1716
|
+
* `fallbacks` LocaleNamespaceMap merge — the registration's `locale:` seat
|
|
1717
|
+
* (`PropsLocale<'fallbacks'>` puts the typed `t` on the section props).
|
|
1718
|
+
*
|
|
1719
|
+
* Label conventions follow spec §4 用户直观性: enumerable config values
|
|
1720
|
+
* (triggerCodes / revertPolicy) render readable labels, never raw enum
|
|
1721
|
+
* strings.
|
|
1722
|
+
*/
|
|
1723
|
+
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
1724
|
+
const zh = {
|
|
1725
|
+
"discard": "放弃修改",
|
|
1726
|
+
"retry": "重试",
|
|
1727
|
+
"readOnly": "当前环境中的设置为只读。",
|
|
1728
|
+
"triggerCodes.label": "触发失败码",
|
|
1729
|
+
"triggerCodes.hint": "命中这些失败码时进入降级决策",
|
|
1730
|
+
"triggerCodes.tooltip": "命中这些失败码时进入降级链决策;可重试型故障(如 5xx)由 llm-retry 先行退避,预算耗尽后同样进入决策。",
|
|
1731
|
+
"triggerCodes.RATE_LIMIT": "限流(429)",
|
|
1732
|
+
"triggerCodes.QUOTA": "配额超限",
|
|
1733
|
+
"triggerCodes.AUTH": "权限/认证失败",
|
|
1734
|
+
"triggerCodes.SERVER": "服务端故障(5xx)",
|
|
1735
|
+
"namedChains.label": "命名降级链",
|
|
1736
|
+
"namedChains.hint": "固定模型链会在模型选择器中独立显示;Auto 继续使用现有分时槽与默认链。",
|
|
1737
|
+
"namedChains.row": "第 {index} 条命名降级链",
|
|
1738
|
+
"namedChains.id": "稳定 ID",
|
|
1739
|
+
"namedChains.idHint": "小写字母/数字/连字符,1–32 字符;auto 为保留字。修改 ID 会改变模型路由,修改名称不会。",
|
|
1740
|
+
"namedChains.name": "显示名称",
|
|
1741
|
+
"namedChains.add": "添加命名降级链",
|
|
1742
|
+
"namedChains.remove": "删除命名降级链",
|
|
1743
|
+
"validation.namedChainId": "命名链 ID \"{id}\" 须为 1–32 个小写字母、数字或连字符,且不能为 auto",
|
|
1744
|
+
"validation.namedChainIdDuplicate": "命名链 ID \"{id}\" 重复",
|
|
1745
|
+
"validation.namedChainNameRequired": "命名链 \"{id}\" 需要显示名称",
|
|
1746
|
+
"validation.namedChainNameDuplicate": "命名链名称 \"{name}\" 重复(不区分大小写)",
|
|
1747
|
+
"validation.namedChainRequired": "命名链 \"{id}\" 至少需要一个选择器",
|
|
1748
|
+
"validation.namedChainSelectorRequired": "请完成或删除命名链中的空选择器",
|
|
1749
|
+
"triggerCodes.extra": "此外还保留了 {codes} 等自定义失败码。",
|
|
1750
|
+
"revertPolicy.label": "冷却结束后",
|
|
1751
|
+
"revertPolicy.cooldown-expiry": "冷却到期后回主模型",
|
|
1752
|
+
"revertPolicy.never": "保持备用模型(会话内不回)",
|
|
1753
|
+
"revertPolicy.hint": "冷却到期后是否回主模型",
|
|
1754
|
+
"revertPolicy.tooltip": "被切换离的模型在冷却期内不再入选;到期后按此策略决定是否回主。",
|
|
1755
|
+
"cooldownMs.label": "冷却时长(毫秒)",
|
|
1756
|
+
"cooldownMs.hint": "冷却期内模型不再入选",
|
|
1757
|
+
"cooldownMs.tooltip": "被切离/失败的模型在冷却期内不再入选。",
|
|
1758
|
+
"maxSwitchesPerStep.label": "单步最大切换次数",
|
|
1759
|
+
"maxSwitchesPerStep.hint": "超过后停止切换",
|
|
1760
|
+
"maxSwitchesPerStep.tooltip": "超过后停止切换,以原始错误语义结束当前步,防止链循环放大延迟。",
|
|
1761
|
+
"alwaysModeRetryCap.label": "always 模式重试上限",
|
|
1762
|
+
"alwaysModeRetryCap.hint": "达到上限次数后切换;0 表示禁用",
|
|
1763
|
+
"alwaysModeRetryCap.tooltip": "retryPolicy 为 always 的模型在同一请求内重试达到该次数后切换;0 表示禁用。",
|
|
1764
|
+
"advanced.label": "高级选项",
|
|
1765
|
+
"advanced.expand": "展开高级选项",
|
|
1766
|
+
"advanced.collapse": "收起高级选项",
|
|
1767
|
+
"roleAutoMatch.label": "启用角色自动匹配",
|
|
1768
|
+
"roleAutoMatch.hint": "规则未命中时,由模型自选最贴近的已声明角色",
|
|
1769
|
+
"roleAutoMatch.tooltip": "规则未命中时,模型会自动从已声明角色(id + persona)中选择最匹配者并注入该角色的链;关闭后未命中规则时按现状回落(inherit / rootChain)。",
|
|
1770
|
+
"rootChain.label": "默认降级链",
|
|
1771
|
+
"rootChain.tooltip": "未命中任何分时槽时先走这条降级链;全部失败后落到下面的默认模型。",
|
|
1772
|
+
"defaultModel.label": "默认模型",
|
|
1773
|
+
"chains.selector.remove": "删除第 {index} 个选择器",
|
|
1774
|
+
"chains.selector.providerAria": "第 {index} 个选择器的 provider",
|
|
1775
|
+
"chains.selector.modelAria": "第 {index} 个选择器的 model",
|
|
1776
|
+
"chains.selector.reorder": "拖拽排序第 {index} 个选择器,或聚焦后按 ↑/↓ 调整",
|
|
1777
|
+
"chains.selector.providerPlaceholder": "选择 provider",
|
|
1778
|
+
"chains.selector.modelPlaceholder": "选择 model",
|
|
1779
|
+
"chains.selector.wildcardLegacy": "该条目为通配(provider/*):选择具体模型后将转为精确条目",
|
|
1780
|
+
"chains.selector.noModelsStrict": "该 provider 暂无可用模型(目录查询失败),请改选其他 provider。",
|
|
1781
|
+
"mainAgent.label": "主代理",
|
|
1782
|
+
"subagents.label": "子代理",
|
|
1783
|
+
"subagents.policy.label": "宿主子代理模型策略",
|
|
1784
|
+
"subagents.policy.allowlist": "允许的模型",
|
|
1785
|
+
"subagents.policy.head": "当前链头",
|
|
1786
|
+
"subagents.policy.source.authorized": "宿主授权",
|
|
1787
|
+
"subagents.policy.source.injected": "插件注入",
|
|
1788
|
+
"subagents.policy.blocked": "降级候选均不在允许列表中 — 未切换",
|
|
1789
|
+
"subagents.policy.unprovable": "策略存在但无法读取 — 插件切换已禁用",
|
|
1790
|
+
"subagents.policy.offAllowlist": "角色链中有 {count} 个精确条目不在允许列表 — 这些条目不会生效",
|
|
1791
|
+
"subagents.policy.recommend": "建议将 FallbacksChain/Auto 加入允许列表(该虚拟路由不受宿主策略过滤)",
|
|
1792
|
+
"subagents.policy.sync": "同步到宿主允许列表",
|
|
1793
|
+
"subagents.policy.sync.done": "已同步:精确条目(角色链、默认降级链与 FallbacksChain/Auto)已写入允许列表;通配条目不展开、不同步",
|
|
1794
|
+
"subagents.policy.sync.failed": "同步失败:宿主设置未写入(策略未启用、条目不可配置或版本冲突等宿主拒绝),请检查宿主设置",
|
|
1795
|
+
"subagents.policy.sync.dirty": "角色链或默认降级链有未保存的修改 — 请先保存再同步(同步只写入已保存的配置)",
|
|
1796
|
+
"timeSlots.label": "分时槽设置",
|
|
1797
|
+
"timeSlots.hint": "自上而下第一条命中生效;全时段行固定最后",
|
|
1798
|
+
"timeSlots.tz.label": "时区(UTC±)",
|
|
1799
|
+
"timeSlots.drag": "拖拽排序(或使用上下按钮)",
|
|
1800
|
+
"timeSlots.name": "名称",
|
|
1801
|
+
"timeSlots.expand": "展开该行",
|
|
1802
|
+
"timeSlots.collapse": "收起该行",
|
|
1803
|
+
"timeSlots.tooltip": "命中行的模型链成为 root 生效链(取代全时段链);未命中任何行时使用全时段链。分时切换是路由种子而非失败决策:不消耗冷却、不计入单步切换上限。",
|
|
1804
|
+
"timeSlots.addPreset": "添加预设",
|
|
1805
|
+
"timeSlots.addCustom": "添加自定义时段",
|
|
1806
|
+
"timeSlots.presetPlaceholder": "选择预设",
|
|
1807
|
+
"timeSlots.remove": "删除该时段行",
|
|
1808
|
+
"timeSlots.moveUp": "上移该时段行",
|
|
1809
|
+
"timeSlots.moveDown": "下移该时段行",
|
|
1810
|
+
"timeSlots.start": "开始(HH:mm)",
|
|
1811
|
+
"timeSlots.end": "结束(HH:mm)",
|
|
1812
|
+
"timeSlots.days": "星期",
|
|
1813
|
+
"timeSlots.days.hint": "不勾选 = 每天;可跨午夜",
|
|
1814
|
+
"timeSlots.preset.name": "预设",
|
|
1815
|
+
"timeSlots.preset.windowLabel": "时段(只读)",
|
|
1816
|
+
"timeSlots.preset.chainsOnly": "预设窗口已锁定:仅可编辑模型链",
|
|
1817
|
+
"timeSlots.preset.liang-peak.label": "梁文峰",
|
|
1818
|
+
"timeSlots.preset.liang-peak.window": "09:00–12:00 与 14:00–18:00(周一至周五,UTC+8)",
|
|
1819
|
+
"timeSlots.preset.liang-valley.label": "梁文谷",
|
|
1820
|
+
"timeSlots.preset.liang-valley.window": "梁文峰之外的所有时间(UTC+8)",
|
|
1821
|
+
"timeSlots.preset.glm-peak.label": "GLM峰",
|
|
1822
|
+
"timeSlots.preset.glm-peak.window": "周一至周五 14:00–18:00(UTC+8)",
|
|
1823
|
+
"timeSlots.preset.glm-valley.label": "GLM谷",
|
|
1824
|
+
"timeSlots.preset.glm-valley.window": "GLM峰之外的所有时间(UTC+8)",
|
|
1825
|
+
"timeSlots.preset.glm.note": "仅配置了 zai-coding-cn 时有效",
|
|
1826
|
+
"timeSlots.preset.highCost": "高消耗",
|
|
1827
|
+
"timeSlots.preset.multiplier": "x{n}",
|
|
1828
|
+
"timeSlots.active": "激活",
|
|
1829
|
+
"timeSlots.preset.glm.unconfigured": "(需配置 zai-coding-cn)",
|
|
1830
|
+
"timeSlots.day.sun": "日",
|
|
1831
|
+
"timeSlots.day.mon": "一",
|
|
1832
|
+
"timeSlots.day.tue": "二",
|
|
1833
|
+
"timeSlots.day.wed": "三",
|
|
1834
|
+
"timeSlots.day.thu": "四",
|
|
1835
|
+
"timeSlots.day.fri": "五",
|
|
1836
|
+
"timeSlots.day.sat": "六",
|
|
1837
|
+
"timeSlots.selector.add": "添加选择器",
|
|
1838
|
+
"allDay.hint": "全天链的最后一档兜底:官方 Flash 或 Pro 二选一",
|
|
1839
|
+
"allDay.flash": "官方 Flash(deepseek-official/deepseek-flash)",
|
|
1840
|
+
"allDay.pro": "官方 Pro(deepseek-official/deepseek-v4-pro)",
|
|
1841
|
+
"allDay.nonconforming": "当前默认模型不合法:请选择官方 Flash 或 Pro 后保存",
|
|
1842
|
+
"roles.list.label": "角色实体",
|
|
1843
|
+
"roles.list.hint": "先声明角色,规则才能引用",
|
|
1844
|
+
"roles.list.tooltip": "角色 id 须匹配 /^[a-z0-9-]{1,32}$/ 且唯一;\"inherit\" 为保留字,不能用作角色 id。",
|
|
1845
|
+
"roles.id": "id",
|
|
1846
|
+
"roles.id.hint": "小写字母/数字/连字符,1–32 字符",
|
|
1847
|
+
"roles.idPlaceholder": "例如 reviewer",
|
|
1848
|
+
"roles.persona": "人格提示",
|
|
1849
|
+
"roles.personaPlaceholder": "例如:你是资深代码审查员",
|
|
1850
|
+
"roles.persona.expand": "展开人格提示",
|
|
1851
|
+
"roles.persona.collapse": "收起人格提示",
|
|
1852
|
+
"roles.persona.empty": "(未设置)",
|
|
1853
|
+
"roles.seedSource.bundled": "内置",
|
|
1854
|
+
"roles.seedSource.external": "外部",
|
|
1855
|
+
"roles.seedSource.user": "用户",
|
|
1856
|
+
"roles.seedChainOptional": "角色 \"{id}\" 为 seed 角色:链可留空,保存不会被拦截",
|
|
1857
|
+
"roles.fallback": "链拼接策略",
|
|
1858
|
+
"roles.fallback.inherit-root": "继承 root(角色链后追加 rootChain)",
|
|
1859
|
+
"roles.fallback.none": "仅角色链(不追加 rootChain)",
|
|
1860
|
+
"roles.add": "添加角色",
|
|
1861
|
+
"roles.remove": "删除该角色",
|
|
1862
|
+
"roles.expand": "展开该角色",
|
|
1863
|
+
"roles.collapse": "收起该角色",
|
|
1864
|
+
"roles.selector.add": "添加选择器",
|
|
1865
|
+
"roles.rules": "角色规则",
|
|
1866
|
+
"roles.rules.hint": "仅对子代理生效:顺序匹配 provider/model,未命中 → inherit(root 链)",
|
|
1867
|
+
"roles.rules.tooltip": "规则仅对子代理生效(root 请求不匹配规则):命中后走对应角色的链;未命中走内置 inherit(rootChain)。",
|
|
1868
|
+
"roles.rule.provider": "provider",
|
|
1869
|
+
"roles.rule.provider.any": "任意",
|
|
1870
|
+
"roles.rule.model": "model",
|
|
1871
|
+
"roles.rule.model.any": "任意",
|
|
1872
|
+
"roles.rule.role": "角色",
|
|
1873
|
+
"roles.rule.role.inherit": "inherit(内置:root 链)",
|
|
1874
|
+
"roles.rule.roleSelectPlaceholder": "选择角色",
|
|
1875
|
+
"roles.rule.roleUndeclared.short": "(未声明)",
|
|
1876
|
+
"roles.addRule": "添加规则",
|
|
1877
|
+
"roles.removeRule": "删除该规则",
|
|
1878
|
+
"validation.blocked": "配置校验未通过,保存被拦截:",
|
|
1879
|
+
"validation.roleIdFormat": "角色 id \"{id}\" 不符合格式 /^[a-z0-9-]{1,32}$/",
|
|
1880
|
+
"validation.roleIdReserved": "\"inherit\" 为保留角色 id,不能用于角色实体",
|
|
1881
|
+
"validation.roleIdDuplicate": "角色 id \"{id}\" 重复",
|
|
1882
|
+
"validation.ruleRoleUndeclared": "规则引用了未声明的角色 \"{role}\"",
|
|
1883
|
+
"validation.ruleRoleRequired": "规则未选择角色:请选择目标角色,或删除该行",
|
|
1884
|
+
"validation.roleChainRequired": "角色 \"{id}\" 未配置模型:请至少添加一条链选择器(模型配置)",
|
|
1885
|
+
"validation.allDayRequired": "默认模型必须二选一:官方 Flash 或 Pro",
|
|
1886
|
+
"validation.slotChainRequired": "分时槽未配置模型:请至少添加一条链选择器",
|
|
1887
|
+
"validation.slotWindow": "分时槽开始/结束时间须为 HH:mm 格式",
|
|
1888
|
+
"validation.slotDays": "星期取值须为 0–6 的整数",
|
|
1889
|
+
"validation.slotKind": "分时槽 kind 须为 \"preset\" 或 \"custom\"",
|
|
1890
|
+
"validation.slotPresetUnknown": "未知的分时槽预设 \"{preset}\"",
|
|
1891
|
+
"validation.slotPresetDuplicate": "预设 \"{preset}\" 已存在:每个预设只能添加一行",
|
|
1892
|
+
"validation.slotPresetFrozen": "预设窗口是冻结代码常量:预设行不能携带 start/end/days",
|
|
1893
|
+
"validation.selector": "选择器 \"{entry}\" 非法:{message}",
|
|
1894
|
+
"legacy.banner": "检测到旧格式配置字段({keys}):已按新模型展示,请按 docs/configuration.md 迁移表手工改写;插件不会自动改写配置。",
|
|
1895
|
+
"catalog.empty": "暂无可用模型:请先在模型页添加模型,添加后此处将自动可选。",
|
|
1896
|
+
"catalog.error": "模型目录读取失败:{message}",
|
|
1897
|
+
"catalog.partial": "部分 provider 模型查询失败:{message}",
|
|
1898
|
+
"catalog.outside.hint": "目录外,可保留原值",
|
|
1899
|
+
"catalog.outside.tooltip": "不在当前模型目录,可保留原值并保存;新增条目仅可从目录选择。",
|
|
1900
|
+
"catalog.outside.short": " (目录外)",
|
|
1901
|
+
"catalog.unconfigured.short": " (未配置)",
|
|
1902
|
+
"status.title": "运行状态(只读)",
|
|
1903
|
+
"status.switches.label": "最近切换:",
|
|
1904
|
+
"status.switches.empty": "本会话暂无 fallback 切换。",
|
|
1905
|
+
"status.switches.error": "切换历史读取失败:{message}",
|
|
1906
|
+
"status.switches.compact": "最近 {count} 次 · {from} → {to}({role} · {reason})",
|
|
1907
|
+
"status.switches.compact.roleInject": "最近 {count} 次 · {role} → {to}({reason})",
|
|
1908
|
+
"status.switches.reason.trigger-code": "触发失败码",
|
|
1909
|
+
"status.switches.reason.always-cap": "always 模式上限",
|
|
1910
|
+
"status.switches.reason.role-inject": "角色注入",
|
|
1911
|
+
"general.title": "模型故障降级",
|
|
1912
|
+
"general.enabled": "已启用",
|
|
1913
|
+
"general.disabled": "未启用",
|
|
1914
|
+
"general.unknown": "未知",
|
|
1915
|
+
"general.unavailable": "状态通道暂不可达",
|
|
1916
|
+
"general.switch": "最近切换:{from} → {to}({role} · {reason})",
|
|
1917
|
+
"general.switch.roleInject": "最近切换:{role} → {to}({reason})",
|
|
1918
|
+
"general.switch.empty": "本会话暂无切换",
|
|
1919
|
+
"general.error": "状态读取失败:{message}",
|
|
1920
|
+
"chat.switch.title": "模型已降级",
|
|
1921
|
+
"chat.switch.summary": "{from} → {to}({reason})",
|
|
1922
|
+
"chat.switch.summary.roleInject": "({reason})",
|
|
1923
|
+
"chat.switch.roleMap": "{role} → {model}",
|
|
1924
|
+
"subagentRole.hover": "{role} → {model}(请求路由)",
|
|
1925
|
+
"defaults.prefix": "默认值",
|
|
1926
|
+
"save": "保存",
|
|
1927
|
+
"save.saving": "保存中…",
|
|
1928
|
+
"save.error": "保存失败:{message}",
|
|
1929
|
+
"close": "关闭",
|
|
1930
|
+
"loading": "加载中…",
|
|
1931
|
+
"unavailable": "fallbacks 配置通道暂不可达:以下显示默认配置(或上次读取值),可尝试保存;保存失败会在此处如实提示。",
|
|
1932
|
+
"error.generic": "出错:{message}"
|
|
1933
|
+
};
|
|
1934
|
+
/** English dictionary, checked complete against the zh key set. */
|
|
1935
|
+
const en = {
|
|
1936
|
+
"discard": "Discard",
|
|
1937
|
+
"retry": "Retry",
|
|
1938
|
+
"readOnly": "Settings are read-only in this environment.",
|
|
1939
|
+
"triggerCodes.label": "Trigger failure codes",
|
|
1940
|
+
"triggerCodes.hint": "Failures with these codes enter fallback decision",
|
|
1941
|
+
"triggerCodes.tooltip": "Failures with these codes enter chain decision; retryable failures (e.g. 5xx) back off via llm-retry first and reach the decision only when its budget is exhausted.",
|
|
1942
|
+
"triggerCodes.RATE_LIMIT": "Rate limit (429)",
|
|
1943
|
+
"triggerCodes.QUOTA": "Quota exceeded",
|
|
1944
|
+
"triggerCodes.AUTH": "Auth / permission failure",
|
|
1945
|
+
"triggerCodes.SERVER": "Server failure (5xx)",
|
|
1946
|
+
"namedChains.label": "Named fallback chains",
|
|
1947
|
+
"namedChains.hint": "Fixed chains appear separately in the model picker; Auto keeps using the existing time slots and default chain.",
|
|
1948
|
+
"namedChains.row": "Named fallback chain {index}",
|
|
1949
|
+
"namedChains.id": "Stable ID",
|
|
1950
|
+
"namedChains.idHint": "1–32 lowercase letters, digits or hyphens; auto is reserved. Changing the ID changes the model route; renaming does not.",
|
|
1951
|
+
"namedChains.name": "Display name",
|
|
1952
|
+
"namedChains.add": "Add named fallback chain",
|
|
1953
|
+
"namedChains.remove": "Remove named fallback chain",
|
|
1954
|
+
"validation.namedChainId": "Named chain ID \"{id}\" must use 1–32 lowercase letters, digits or hyphens and cannot be auto",
|
|
1955
|
+
"validation.namedChainIdDuplicate": "Duplicate named chain ID \"{id}\"",
|
|
1956
|
+
"validation.namedChainNameRequired": "Named chain \"{id}\" needs a display name",
|
|
1957
|
+
"validation.namedChainNameDuplicate": "Duplicate named chain name \"{name}\" (case-insensitive)",
|
|
1958
|
+
"validation.namedChainRequired": "Named chain \"{id}\" needs at least one selector",
|
|
1959
|
+
"validation.namedChainSelectorRequired": "Complete or remove empty selectors in named chains",
|
|
1960
|
+
"triggerCodes.extra": "Custom codes are preserved: {codes}.",
|
|
1961
|
+
"revertPolicy.label": "After cooldown",
|
|
1962
|
+
"revertPolicy.cooldown-expiry": "Return to the primary model",
|
|
1963
|
+
"revertPolicy.never": "Keep the fallback model (until session end)",
|
|
1964
|
+
"revertPolicy.hint": "Whether to return to the primary model after cooldown",
|
|
1965
|
+
"revertPolicy.tooltip": "A model switched away from stays out of candidacy during its cooldown; this policy decides whether it returns afterwards.",
|
|
1966
|
+
"cooldownMs.label": "Cooldown (milliseconds)",
|
|
1967
|
+
"cooldownMs.hint": "Models stay out of candidacy during cooldown",
|
|
1968
|
+
"cooldownMs.tooltip": "Switched-away or failed models stay out of candidacy during the cooldown window.",
|
|
1969
|
+
"maxSwitchesPerStep.label": "Max switches per step",
|
|
1970
|
+
"maxSwitchesPerStep.hint": "Stops switching beyond the cap",
|
|
1971
|
+
"maxSwitchesPerStep.tooltip": "Beyond this the step stops switching and ends with the original error semantics, preventing chain loops from amplifying latency.",
|
|
1972
|
+
"alwaysModeRetryCap.label": "Always-mode retry cap",
|
|
1973
|
+
"alwaysModeRetryCap.hint": "Switches after the cap; 0 disables",
|
|
1974
|
+
"alwaysModeRetryCap.tooltip": "Models whose retryPolicy is always switch after this many retries within one request; 0 disables.",
|
|
1975
|
+
"advanced.label": "Advanced options",
|
|
1976
|
+
"advanced.expand": "Expand advanced options",
|
|
1977
|
+
"advanced.collapse": "Collapse advanced options",
|
|
1978
|
+
"roleAutoMatch.label": "Enable role auto-match",
|
|
1979
|
+
"roleAutoMatch.hint": "On rules-miss, the model picks the closest declared role",
|
|
1980
|
+
"roleAutoMatch.tooltip": "When no rule matches, the model auto-selects the best-fit declared role (id + persona) and uses its chain; turn off to keep today's fallback (inherit / rootChain) on a rules-miss.",
|
|
1981
|
+
"rootChain.label": "Default fallback chain",
|
|
1982
|
+
"rootChain.tooltip": "Walked first whenever no time slot matches; if every entry fails, the default model below is the last fallback.",
|
|
1983
|
+
"defaultModel.label": "Default model",
|
|
1984
|
+
"chains.selector.remove": "Remove selector {index}",
|
|
1985
|
+
"chains.selector.providerAria": "Selector {index} provider",
|
|
1986
|
+
"chains.selector.modelAria": "Selector {index} model",
|
|
1987
|
+
"chains.selector.reorder": "Drag to reorder selector {index}, or focus and press ↑/↓",
|
|
1988
|
+
"chains.selector.providerPlaceholder": "Select provider",
|
|
1989
|
+
"chains.selector.modelPlaceholder": "Select model",
|
|
1990
|
+
"chains.selector.wildcardLegacy": "This entry is a wildcard (provider/*): picking a model converts it to an exact entry",
|
|
1991
|
+
"chains.selector.noModelsStrict": "No models available for this provider (catalog lookup failed); pick another provider.",
|
|
1992
|
+
"mainAgent.label": "Main agent",
|
|
1993
|
+
"subagents.label": "Subagents",
|
|
1994
|
+
"subagents.policy.label": "Host subagent model policy",
|
|
1995
|
+
"subagents.policy.allowlist": "Allowed models",
|
|
1996
|
+
"subagents.policy.head": "Effective chain head",
|
|
1997
|
+
"subagents.policy.source.authorized": "authorized",
|
|
1998
|
+
"subagents.policy.source.injected": "injected",
|
|
1999
|
+
"subagents.policy.blocked": "No in-allowlist fallback candidate — switch skipped",
|
|
2000
|
+
"subagents.policy.unprovable": "Policy present but unreadable — plugin switches disabled",
|
|
2001
|
+
"subagents.policy.offAllowlist": "{count} exact role-chain entries are outside the allowlist — they will not run",
|
|
2002
|
+
"subagents.policy.recommend": "Add FallbacksChain/Auto to the allowlist (this virtual route is not filtered by the host policy)",
|
|
2003
|
+
"subagents.policy.sync": "Sync to host allowlist",
|
|
2004
|
+
"subagents.policy.sync.done": "Synced: exact entries (role chains, default fallback chain and FallbacksChain/Auto) are now allowed; wildcard entries are not expanded or synced",
|
|
2005
|
+
"subagents.policy.sync.failed": "Sync failed: the host settings were not written (policy off, entry not configurable, revision conflict or another host refusal) — check the host settings",
|
|
2006
|
+
"subagents.policy.sync.dirty": "Unsaved role-chain or default-chain edits — save first, then sync (the sync writes the saved configuration only)",
|
|
2007
|
+
"timeSlots.label": "Time slots",
|
|
2008
|
+
"timeSlots.hint": "First match from top to bottom wins; the all-day row is always last",
|
|
2009
|
+
"timeSlots.tz.label": "Timezone (UTC±)",
|
|
2010
|
+
"timeSlots.drag": "Drag to reorder (or use the up/down buttons)",
|
|
2011
|
+
"timeSlots.name": "Name",
|
|
2012
|
+
"timeSlots.expand": "Expand this row",
|
|
2013
|
+
"timeSlots.collapse": "Collapse this row",
|
|
2014
|
+
"timeSlots.tooltip": "A matched row's model chain becomes the effective root chain (replacing the all-day chain); no match uses the all-day chain. A time-slot switch is a routing seed, not a failure decision: it consumes no cooldown and does not count against the per-step switch cap.",
|
|
2015
|
+
"timeSlots.addPreset": "Add preset",
|
|
2016
|
+
"timeSlots.addCustom": "Add custom time slot",
|
|
2017
|
+
"timeSlots.presetPlaceholder": "Select a preset",
|
|
2018
|
+
"timeSlots.remove": "Remove this time-slot row",
|
|
2019
|
+
"timeSlots.moveUp": "Move this time-slot row up",
|
|
2020
|
+
"timeSlots.moveDown": "Move this time-slot row down",
|
|
2021
|
+
"timeSlots.start": "Start (HH:mm)",
|
|
2022
|
+
"timeSlots.end": "End (HH:mm)",
|
|
2023
|
+
"timeSlots.days": "Days",
|
|
2024
|
+
"timeSlots.days.hint": "None selected = every day; may wrap midnight",
|
|
2025
|
+
"timeSlots.preset.name": "Preset",
|
|
2026
|
+
"timeSlots.preset.windowLabel": "Window (read-only)",
|
|
2027
|
+
"timeSlots.preset.chainsOnly": "Preset windows are frozen: only the model chain is editable",
|
|
2028
|
+
"timeSlots.preset.liang-peak.label": "Liang Peak",
|
|
2029
|
+
"timeSlots.preset.liang-peak.window": "09:00–12:00 & 14:00–18:00 (Monday–Friday, UTC+8)",
|
|
2030
|
+
"timeSlots.preset.liang-valley.label": "Liang Valley",
|
|
2031
|
+
"timeSlots.preset.liang-valley.window": "All times outside Liang Peak (UTC+8)",
|
|
2032
|
+
"timeSlots.preset.glm-peak.label": "GLM Peak",
|
|
2033
|
+
"timeSlots.preset.glm-peak.window": "Monday–Friday 14:00–18:00 (UTC+8)",
|
|
2034
|
+
"timeSlots.preset.glm-valley.label": "GLM Valley",
|
|
2035
|
+
"timeSlots.preset.glm-valley.window": "All times outside GLM Peak (UTC+8)",
|
|
2036
|
+
"timeSlots.preset.glm.note": "Only effective when zai-coding-cn is configured",
|
|
2037
|
+
"timeSlots.preset.highCost": "High Cost",
|
|
2038
|
+
"timeSlots.preset.multiplier": "x{n}",
|
|
2039
|
+
"timeSlots.active": "Active",
|
|
2040
|
+
"timeSlots.preset.glm.unconfigured": " (requires zai-coding-cn)",
|
|
2041
|
+
"timeSlots.day.sun": "Sun",
|
|
2042
|
+
"timeSlots.day.mon": "Mon",
|
|
2043
|
+
"timeSlots.day.tue": "Tue",
|
|
2044
|
+
"timeSlots.day.wed": "Wed",
|
|
2045
|
+
"timeSlots.day.thu": "Thu",
|
|
2046
|
+
"timeSlots.day.fri": "Fri",
|
|
2047
|
+
"timeSlots.day.sat": "Sat",
|
|
2048
|
+
"timeSlots.selector.add": "Add selector",
|
|
2049
|
+
"allDay.hint": "Last-resort fallback of the all-day chain: official Flash or Pro (pick exactly one)",
|
|
2050
|
+
"allDay.flash": "Official Flash (deepseek-official/deepseek-flash)",
|
|
2051
|
+
"allDay.pro": "Official Pro (deepseek-official/deepseek-v4-pro)",
|
|
2052
|
+
"allDay.nonconforming": "The current default model is not valid: pick official Flash or Pro before saving",
|
|
2053
|
+
"roles.list.label": "Declared roles",
|
|
2054
|
+
"roles.list.hint": "Declare roles before rules can reference them",
|
|
2055
|
+
"roles.list.tooltip": "Role ids must match /^[a-z0-9-]{1,32}$/ and be unique; \"inherit\" is reserved and cannot be used as a role id.",
|
|
2056
|
+
"roles.id": "ID",
|
|
2057
|
+
"roles.id.hint": "lowercase letters, digits, hyphens; 1–32 chars",
|
|
2058
|
+
"roles.idPlaceholder": "e.g. reviewer",
|
|
2059
|
+
"roles.persona": "Persona",
|
|
2060
|
+
"roles.personaPlaceholder": "e.g. you are a senior code reviewer",
|
|
2061
|
+
"roles.persona.expand": "Expand persona",
|
|
2062
|
+
"roles.persona.collapse": "Collapse persona",
|
|
2063
|
+
"roles.persona.empty": "(not set)",
|
|
2064
|
+
"roles.seedSource.bundled": "bundled",
|
|
2065
|
+
"roles.seedSource.external": "external",
|
|
2066
|
+
"roles.seedSource.user": "User",
|
|
2067
|
+
"roles.seedChainOptional": "Role \"{id}\" is a seed role: the chain may stay empty",
|
|
2068
|
+
"roles.fallback": "Chain append",
|
|
2069
|
+
"roles.fallback.inherit-root": "Inherit root (append rootChain after the role chain)",
|
|
2070
|
+
"roles.fallback.none": "Role chain only (no rootChain)",
|
|
2071
|
+
"roles.add": "Add role",
|
|
2072
|
+
"roles.remove": "Remove this role",
|
|
2073
|
+
"roles.expand": "Expand this role",
|
|
2074
|
+
"roles.collapse": "Collapse this role",
|
|
2075
|
+
"roles.selector.add": "Add selector",
|
|
2076
|
+
"roles.rules": "Role rules",
|
|
2077
|
+
"roles.rules.hint": "Subagents only: matches provider/model in order; no match → inherit (root chain)",
|
|
2078
|
+
"roles.rules.tooltip": "Rules apply to subagents only (root requests never match): a matched rule uses that role's chain; no match uses the built-in inherit (rootChain).",
|
|
2079
|
+
"roles.rule.provider": "provider",
|
|
2080
|
+
"roles.rule.provider.any": "Any",
|
|
2081
|
+
"roles.rule.model": "model",
|
|
2082
|
+
"roles.rule.model.any": "Any",
|
|
2083
|
+
"roles.rule.role": "role",
|
|
2084
|
+
"roles.rule.role.inherit": "inherit (built-in: root chain)",
|
|
2085
|
+
"roles.rule.roleSelectPlaceholder": "Select role",
|
|
2086
|
+
"roles.rule.roleUndeclared.short": " (undeclared)",
|
|
2087
|
+
"roles.addRule": "Add rule",
|
|
2088
|
+
"roles.removeRule": "Remove this rule",
|
|
2089
|
+
"validation.blocked": "Configuration validation failed; save was blocked: ",
|
|
2090
|
+
"validation.roleIdFormat": "Role id \"{id}\" does not match /^[a-z0-9-]{1,32}$/",
|
|
2091
|
+
"validation.roleIdReserved": "\"inherit\" is a reserved role id and cannot be declared",
|
|
2092
|
+
"validation.roleIdDuplicate": "Duplicate role id \"{id}\"",
|
|
2093
|
+
"validation.ruleRoleUndeclared": "Rule references undeclared role \"{role}\"",
|
|
2094
|
+
"validation.ruleRoleRequired": "Rule has no role selected: pick a target role, or remove the row",
|
|
2095
|
+
"validation.roleChainRequired": "Role \"{id}\" has no model config: add at least one chain entry",
|
|
2096
|
+
"validation.allDayRequired": "The default model must be exactly one official model (Flash or Pro)",
|
|
2097
|
+
"validation.slotChainRequired": "Time-slot row has no models: add at least one chain entry",
|
|
2098
|
+
"validation.slotWindow": "Time-slot start/end must use HH:mm format",
|
|
2099
|
+
"validation.slotDays": "Days must be integers 0–6",
|
|
2100
|
+
"validation.slotKind": "Time-slot kind must be \"preset\" or \"custom\"",
|
|
2101
|
+
"validation.slotPresetUnknown": "Unknown time-slot preset \"{preset}\"",
|
|
2102
|
+
"validation.slotPresetDuplicate": "Preset \"{preset}\" already exists: at most one row per preset",
|
|
2103
|
+
"validation.slotPresetFrozen": "Preset windows are frozen code constants: a preset row cannot carry start/end/days",
|
|
2104
|
+
"validation.selector": "Invalid selector \"{entry}\": {message}",
|
|
2105
|
+
"legacy.banner": "Legacy config fields detected ({keys}): now shown in the new model — rewrite them manually following the migration table in docs/configuration.md (the plugin will not rewrite them automatically).",
|
|
2106
|
+
"catalog.empty": "No models yet: add a model on the Models page first; options will appear here automatically.",
|
|
2107
|
+
"catalog.error": "Model catalog read failed: {message}",
|
|
2108
|
+
"catalog.partial": "Some provider model lookups failed: {message}",
|
|
2109
|
+
"catalog.outside.hint": "Outside catalog; the value can be kept",
|
|
2110
|
+
"catalog.outside.tooltip": "Not in the current model catalog; you can keep the original value and save it (new entries are restricted to the catalog).",
|
|
2111
|
+
"catalog.outside.short": " (outside catalog)",
|
|
2112
|
+
"catalog.unconfigured.short": " (not configured)",
|
|
2113
|
+
"status.title": "Runtime status (read-only)",
|
|
2114
|
+
"status.switches.label": "Recent switches: ",
|
|
2115
|
+
"status.switches.empty": "No fallback switches in this session yet.",
|
|
2116
|
+
"status.switches.error": "Switch history read failed: {message}",
|
|
2117
|
+
"status.switches.compact": "last {count} · {from} → {to} ({role} · {reason})",
|
|
2118
|
+
"status.switches.compact.roleInject": "last {count} · {role} → {to} ({reason})",
|
|
2119
|
+
"status.switches.reason.trigger-code": "trigger code",
|
|
2120
|
+
"status.switches.reason.always-cap": "always-mode cap",
|
|
2121
|
+
"status.switches.reason.role-inject": "role inject",
|
|
2122
|
+
"general.title": "Model failover",
|
|
2123
|
+
"general.enabled": "Enabled",
|
|
2124
|
+
"general.disabled": "Disabled",
|
|
2125
|
+
"general.unknown": "Unknown",
|
|
2126
|
+
"general.unavailable": "Status channel unavailable",
|
|
2127
|
+
"general.switch": "Last switch: {from} → {to} ({role} · {reason})",
|
|
2128
|
+
"general.switch.roleInject": "Last switch: {role} → {to} ({reason})",
|
|
2129
|
+
"general.switch.empty": "No switches this session",
|
|
2130
|
+
"general.error": "Status read failed: {message}",
|
|
2131
|
+
"chat.switch.title": "Model downgraded",
|
|
2132
|
+
"chat.switch.summary": "{from} → {to} ({reason})",
|
|
2133
|
+
"chat.switch.summary.roleInject": "({reason})",
|
|
2134
|
+
"chat.switch.roleMap": "{role} → {model}",
|
|
2135
|
+
"subagentRole.hover": "{role} → {model} (request route)",
|
|
2136
|
+
"defaults.prefix": "Default",
|
|
2137
|
+
"save": "Save",
|
|
2138
|
+
"save.saving": "Saving…",
|
|
2139
|
+
"save.error": "Save failed: {message}",
|
|
2140
|
+
"close": "Close",
|
|
2141
|
+
"loading": "Loading…",
|
|
2142
|
+
"unavailable": "The fallbacks config channel is unreachable: showing the default configuration (or the last read value). You can try to save; failures will be reported here.",
|
|
2143
|
+
"error.generic": "Error: {message}"
|
|
2144
|
+
};
|
|
2145
|
+
/** The settings section's dictionary namespace. */
|
|
2146
|
+
const NS = "fallbacks";
|
|
2147
|
+
/**
|
|
2148
|
+
* Reason → locale key map for switch summaries (S-c; shared by the card's
|
|
2149
|
+
* status block, the General page status row, and the conversation node). All
|
|
2150
|
+
* reasons resolve from ONE key family (`status.switches.reason.*`) — the
|
|
2151
|
+
* shared reason vocabulary must not mix dictionary families (qc1 F-004). The
|
|
2152
|
+
* session log is durable and forward-compatible: a reason value outside the
|
|
2153
|
+
* current union (a newer plugin wrote it) renders raw instead of falling
|
|
2154
|
+
* into a binary else branch.
|
|
2155
|
+
*/
|
|
2156
|
+
const SWITCH_REASON_KEYS = {
|
|
2157
|
+
"trigger-code": "status.switches.reason.trigger-code",
|
|
2158
|
+
"always-cap": "status.switches.reason.always-cap",
|
|
2159
|
+
"role-inject": "status.switches.reason.role-inject"
|
|
2160
|
+
};
|
|
2161
|
+
[...defaultFallbacksConfig.triggerCodes];
|
|
2162
|
+
//#endregion
|
|
2163
|
+
//#region \0dsh-css:D:\Repos\dsh-llm-router\src\client\GeneralFallbacksRow.module.css.mjs
|
|
2164
|
+
const css$2 = "\r\n\r\n._ca8f2965_row {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n padding: 16px 0;\r\n border-bottom: 1px solid var(--dsw-alias-border-l2);\r\n}\r\n\r\n._c8d611be_rowText {\r\n flex: 1;\r\n min-width: 0;\r\n display: flex;\r\n flex-direction: column;\r\n gap: 4px;\r\n padding-right: 48px;\r\n}\r\n\r\n._6c90d81f_title {\r\n font-size: 14px;\r\n font-weight: 400;\r\n line-height: 22px;\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n\r\n._71e34951_summary {\r\n font-size: 12px;\r\n line-height: 18px;\r\n color: var(--dsw-alias-label-tertiary);\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n}\r\n\r\n\r\n._dbfcb0f6_badge {\r\n flex: none;\r\n padding: 2px 10px;\r\n border-radius: 9px;\r\n font-size: 12px;\r\n line-height: 18px;\r\n background: var(--dsw-alias-bg-module-platform);\r\n color: var(--dsw-alias-label-tertiary);\r\n}\r\n\r\n._e0b4af03_badgeEnabled {\r\n color: var(--dsw-alias-state-success-primary);\r\n}\r\n";
|
|
2165
|
+
const tagId$2 = "dsh-fallback-router/GeneralFallbacksRow.module.css";
|
|
2166
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
|
|
2167
|
+
const tag = document.createElement("style");
|
|
2168
|
+
tag.dataset.plugin = "dsh-fallback-router";
|
|
2169
|
+
tag.dataset.pluginCss = tagId$2;
|
|
2170
|
+
tag.textContent = css$2;
|
|
2171
|
+
document.head.appendChild(tag);
|
|
2172
|
+
}
|
|
2173
|
+
var GeneralFallbacksRow_module_css_default = {
|
|
2174
|
+
"row": "_ca8f2965_row",
|
|
2175
|
+
"rowText": "_c8d611be_rowText",
|
|
2176
|
+
"title": "_6c90d81f_title",
|
|
2177
|
+
"summary": "_71e34951_summary",
|
|
2178
|
+
"badge": "_dbfcb0f6_badge",
|
|
2179
|
+
"badgeEnabled": "_e0b4af03_badgeEnabled"
|
|
2180
|
+
};
|
|
2181
|
+
//#endregion
|
|
2182
|
+
//#region src/client/GeneralFallbacksRow.tsx
|
|
2183
|
+
/**
|
|
2184
|
+
* Fallbacks status row — the `fallbacks` read-only row on the dsh General
|
|
2185
|
+
* settings page (plan fallbacks-aux-seams, task 1). Registered into the
|
|
2186
|
+
* `settings.general.item` slot (id `fallbacks`, order 100 — after every
|
|
2187
|
+
* upstream preference row: agent-preset -25 / permission -20 / language 0 /
|
|
2188
|
+
* appearance 10 / composer-enter 20, so the informational row renders at the
|
|
2189
|
+
* column end). Owner props are intentionally empty (`children?: never`,
|
|
2190
|
+
* dsh-private ui-settings slots.ts:81-84 — the section column only stacks),
|
|
2191
|
+
* so all data flows through the shared {@link FallbacksSettingsController}
|
|
2192
|
+
* (the same instance the plugin-config card consumes): the row triggers the
|
|
2193
|
+
* first read on mount when the store is still idle, and the pushed
|
|
2194
|
+
* invalidations wired in `apply` (`settings/document-updated` fallbacks-ns +
|
|
2195
|
+
* `connection/reset`, which refresh only already-read stores) keep it fresh
|
|
2196
|
+
* afterwards — no new data path, no store API change.
|
|
2197
|
+
*
|
|
2198
|
+
* The row is read-only by design (偏好位语义: a General preference row is not
|
|
2199
|
+
* a control surface): an active/inactive badge (content presence — the
|
|
2200
|
+
* removed config-level `enabled` switch is re-keyed to `isFallbackActive`,
|
|
2201
|
+
* plan fallbacks-web-ux-alignment T2) + a compact last-switch summary.
|
|
2202
|
+
* Honest degraded states: a hard load error or an unreachable gateway
|
|
2203
|
+
* channel (`ready && !present`) render the neutral 'unknown' badge — a
|
|
2204
|
+
* channel-down read must never masquerade as 'disabled' (KD-G5); the
|
|
2205
|
+
* switches face keeps its own error/empty states (D-5 semantics unchanged).
|
|
2206
|
+
*
|
|
2207
|
+
* Geometry follows the upstream Setting-Cell (figma 501:30011 — gap 8,
|
|
2208
|
+
* pad 16/0, hairline separator, title over subtitle in the text column, a
|
|
2209
|
+
* small non-interactive pill on the right); every color resolves through a
|
|
2210
|
+
* `--dsw-alias-*` token (light/dark adaptive).
|
|
2211
|
+
*/
|
|
2212
|
+
/**
|
|
2213
|
+
* Render the Fallbacks status row.
|
|
2214
|
+
* @param props - composed slot props.
|
|
2215
|
+
* @returns the row element tree.
|
|
2216
|
+
*/
|
|
2217
|
+
function GeneralFallbacksRow({ controller, useSnapshot, t }) {
|
|
2218
|
+
const state = useSnapshot((snapshot) => snapshot);
|
|
2219
|
+
(0, react.useEffect)(() => {
|
|
2220
|
+
const snapshot = controller.store.getSnapshot();
|
|
2221
|
+
if (snapshot.status === "idle") controller.load();
|
|
2222
|
+
if (snapshot.switchesStatus === "idle") controller.loadSwitches();
|
|
2223
|
+
}, [controller]);
|
|
2224
|
+
const settled = state.status === "ready";
|
|
2225
|
+
const badgeKey = settled && state.present ? isFallbackActive(state.config) ? "general.enabled" : "general.disabled" : "general.unknown";
|
|
2226
|
+
const latestSwitch = state.switches[0];
|
|
2227
|
+
let summary;
|
|
2228
|
+
if (state.status === "error") summary = t("general.error", { message: state.error ?? "" });
|
|
2229
|
+
else if (!settled) summary = t("loading");
|
|
2230
|
+
else if (!state.present) summary = t("general.unavailable");
|
|
2231
|
+
else if (state.switchesStatus === "error") summary = t("status.switches.error", { message: state.switchesError ?? "" });
|
|
2232
|
+
else if (state.switchesStatus === "loading") summary = t("loading");
|
|
2233
|
+
else if (latestSwitch === void 0) summary = t("general.switch.empty");
|
|
2234
|
+
else {
|
|
2235
|
+
const reasonKey = SWITCH_REASON_KEYS[latestSwitch.reason];
|
|
2236
|
+
const params = {
|
|
2237
|
+
from: `${latestSwitch.from.provider}/${latestSwitch.from.model}`,
|
|
2238
|
+
to: `${latestSwitch.to.provider}/${latestSwitch.to.model}`,
|
|
2239
|
+
role: latestSwitch.role,
|
|
2240
|
+
reason: reasonKey === void 0 ? latestSwitch.reason : t(reasonKey)
|
|
2241
|
+
};
|
|
2242
|
+
summary = latestSwitch.reason === "role-inject" ? t("general.switch.roleInject", params) : t("general.switch", params);
|
|
2243
|
+
}
|
|
2244
|
+
const alert = state.status === "error" || state.switchesStatus === "error";
|
|
2245
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2246
|
+
className: GeneralFallbacksRow_module_css_default.row,
|
|
2247
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2248
|
+
className: GeneralFallbacksRow_module_css_default.rowText,
|
|
2249
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2250
|
+
className: GeneralFallbacksRow_module_css_default.title,
|
|
2251
|
+
children: t("general.title")
|
|
2252
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2253
|
+
className: GeneralFallbacksRow_module_css_default.summary,
|
|
2254
|
+
role: alert ? "alert" : void 0,
|
|
2255
|
+
children: summary
|
|
2256
|
+
})]
|
|
2257
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2258
|
+
className: `${GeneralFallbacksRow_module_css_default.badge} ${badgeKey === "general.enabled" ? GeneralFallbacksRow_module_css_default.badgeEnabled : ""}`,
|
|
2259
|
+
children: t(badgeKey)
|
|
2260
|
+
})]
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
//#endregion
|
|
2264
|
+
//#region src/client/switch-guard.ts
|
|
2265
|
+
/**
|
|
2266
|
+
* True when `value` is a well-formed `fallbacks/switch` payload — the ONE
|
|
2267
|
+
* client-side shape guard, shared by the conversation node definition's
|
|
2268
|
+
* `match`/`start` and the renderer's degrade check (both in
|
|
2269
|
+
* `src/client/ConversationFallbackSwitch.tsx`).
|
|
2270
|
+
*
|
|
2271
|
+
* The durable session log is append-only and survives plugin/host upgrades,
|
|
2272
|
+
* so a `fallbacks/switch` event or node payload may carry a stale or
|
|
2273
|
+
* corrupted shape — version skew must degrade the transcript line (a
|
|
2274
|
+
* title-only notice), never crash the session assembly or the renderer.
|
|
2275
|
+
*
|
|
2276
|
+
* The HOST-side mirror (`src/commands.ts` `isFallbacksSwitchData`) lives in
|
|
2277
|
+
* a DIFFERENT bundle (host vs client) — it intentionally stays separate; do
|
|
2278
|
+
* not merge the two guards across the bundle boundary.
|
|
2279
|
+
*/
|
|
2280
|
+
function isFallbacksSwitchData(value) {
|
|
2281
|
+
if (typeof value !== "object" || value === null) return false;
|
|
2282
|
+
const payload = value;
|
|
2283
|
+
if (typeof payload.turn !== "number" || typeof payload.step !== "number") return false;
|
|
2284
|
+
if (typeof payload.role !== "string" || typeof payload.reason !== "string") return false;
|
|
2285
|
+
const from = payload.from;
|
|
2286
|
+
const to = payload.to;
|
|
2287
|
+
return typeof from?.provider === "string" && typeof from?.model === "string" && typeof to?.provider === "string" && typeof to?.model === "string";
|
|
2288
|
+
}
|
|
2289
|
+
//#endregion
|
|
2290
|
+
//#region \0dsh-css:D:\Repos\dsh-llm-router\src\client\ConversationFallbackSwitch.module.css.mjs
|
|
2291
|
+
const css$1 = "\r\n\r\n._ccce8bff_switchRow {\r\n display: flex;\r\n align-items: center;\r\n padding: 2px 0;\r\n font-size: 14px;\r\n line-height: 24px;\r\n}\r\n\r\n\r\n._b5489dcd_switchTitle {\r\n flex: none;\r\n color: var(--dsw-alias-state-warn-primary);\r\n}\r\n\r\n._690b095b_switchSep {\r\n flex: none;\r\n width: 2px;\r\n height: 2px;\r\n margin: 0 8px;\r\n border-radius: 1px;\r\n background: var(--dsw-alias-label-caption);\r\n}\r\n\r\n\r\n._8749463f_switchSummary {\r\n flex: 1 1 auto;\r\n min-width: 0;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n color: var(--dsw-alias-label-tertiary);\r\n}\r\n\r\n\r\n._11cf2c8c_roleBadge {\r\n flex: none;\r\n max-width: 96px;\r\n padding: 0 8px;\r\n border-radius: 999px;\r\n font-size: 12px;\r\n line-height: 20px;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n background: var(--dsw-alias-bg-module-platform);\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n\r\n._39c00738_roleModelMap {\r\n flex: 0 1 auto;\r\n min-width: 0;\r\n margin-left: 8px;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n";
|
|
2292
|
+
const tagId$1 = "dsh-fallback-router/ConversationFallbackSwitch.module.css";
|
|
2293
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
2294
|
+
const tag = document.createElement("style");
|
|
2295
|
+
tag.dataset.plugin = "dsh-fallback-router";
|
|
2296
|
+
tag.dataset.pluginCss = tagId$1;
|
|
2297
|
+
tag.textContent = css$1;
|
|
2298
|
+
document.head.appendChild(tag);
|
|
2299
|
+
}
|
|
2300
|
+
var ConversationFallbackSwitch_module_css_default = {
|
|
2301
|
+
"switchRow": "_ccce8bff_switchRow",
|
|
2302
|
+
"switchTitle": "_b5489dcd_switchTitle",
|
|
2303
|
+
"switchSep": "_690b095b_switchSep",
|
|
2304
|
+
"switchSummary": "_8749463f_switchSummary",
|
|
2305
|
+
"roleBadge": "_11cf2c8c_roleBadge",
|
|
2306
|
+
"roleModelMap": "_39c00738_roleModelMap"
|
|
2307
|
+
};
|
|
2308
|
+
//#endregion
|
|
2309
|
+
//#region src/client/ConversationFallbackSwitch.tsx
|
|
2310
|
+
/**
|
|
2311
|
+
* One switch event → one chat node. Each `fallbacks/switch` event is its own
|
|
2312
|
+
* Context (id = event seq — the durable unique key), so every match is a
|
|
2313
|
+
* `start`; `update` is a passthrough (no aggregation — D3's per-Turn
|
|
2314
|
+
* counting is a separate, unselected seam).
|
|
2315
|
+
*/
|
|
2316
|
+
const fallbackSwitchDefinition = {
|
|
2317
|
+
kind: "fallbacks-switch",
|
|
2318
|
+
target: "chat",
|
|
2319
|
+
match: (event) => event.type === "fallbacks/switch" && Number.isInteger(event.seq) && isFallbacksSwitchData(event.data) ? {
|
|
2320
|
+
id: String(event.seq),
|
|
2321
|
+
role: "start"
|
|
2322
|
+
} : null,
|
|
2323
|
+
start: (_context, match) => {
|
|
2324
|
+
if (match.event.type !== "fallbacks/switch") throw new Error("fallbacks-switch start requires a fallbacks/switch event");
|
|
2325
|
+
const { seq, time } = match.event;
|
|
2326
|
+
if (!Number.isInteger(seq) || !isFallbacksSwitchData(match.event.data)) return {
|
|
2327
|
+
seq,
|
|
2328
|
+
time
|
|
2329
|
+
};
|
|
2330
|
+
const { turn, step, from, to, role, reason } = match.event.data;
|
|
2331
|
+
return {
|
|
2332
|
+
seq,
|
|
2333
|
+
time,
|
|
2334
|
+
turn,
|
|
2335
|
+
step,
|
|
2336
|
+
from,
|
|
2337
|
+
to,
|
|
2338
|
+
role,
|
|
2339
|
+
reason
|
|
2340
|
+
};
|
|
2341
|
+
},
|
|
2342
|
+
update: (context) => context.state,
|
|
2343
|
+
buildViewNode: (context) => {
|
|
2344
|
+
if (context.start === void 0 || context.state === void 0) return null;
|
|
2345
|
+
return {
|
|
2346
|
+
key: context.key,
|
|
2347
|
+
kind: "fallbacks-switch",
|
|
2348
|
+
id: context.id,
|
|
2349
|
+
target: "chat",
|
|
2350
|
+
anchorSeq: context.start.event.seq,
|
|
2351
|
+
location: context.start.location,
|
|
2352
|
+
visibility: "visible",
|
|
2353
|
+
data: context.state
|
|
2354
|
+
};
|
|
2355
|
+
}
|
|
2356
|
+
};
|
|
2357
|
+
/**
|
|
2358
|
+
* Render one fallback switch as a compact system-style transcript line.
|
|
2359
|
+
*
|
|
2360
|
+
* Geometry follows the upstream chat system rows (the compaction boundary
|
|
2361
|
+
* notice: warning-toned title + separator + ellipsized summary —
|
|
2362
|
+
* `chat/MessageItem .module.css:38-122`); every color resolves through a
|
|
2363
|
+
* `--dsw-alias-*` token. A reason outside the current union renders raw (forward-compatible
|
|
2364
|
+
* durable log, same rule as the card/general row summaries). A malformed or
|
|
2365
|
+
* partial payload (version skew) degrades to the title-only line instead of
|
|
2366
|
+
* throwing during interpolation — the transcript slot stays visible with the
|
|
2367
|
+
* warning-toned "model downgraded" title (T1 copy) and no summary details.
|
|
2368
|
+
* @param props - composed keyed seat props.
|
|
2369
|
+
* @returns the switch line element tree.
|
|
2370
|
+
*/
|
|
2371
|
+
function ConversationFallbackSwitch({ node, t }) {
|
|
2372
|
+
const data = node.data;
|
|
2373
|
+
if (!isFallbacksSwitchData(data)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2374
|
+
className: ConversationFallbackSwitch_module_css_default.switchRow,
|
|
2375
|
+
role: "status",
|
|
2376
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2377
|
+
className: ConversationFallbackSwitch_module_css_default.switchTitle,
|
|
2378
|
+
children: t("chat.switch.title")
|
|
2379
|
+
})
|
|
2380
|
+
});
|
|
2381
|
+
const reasonKey = SWITCH_REASON_KEYS[data.reason];
|
|
2382
|
+
const reason = reasonKey === void 0 ? data.reason : t(reasonKey);
|
|
2383
|
+
const isRoleMapped = data.role !== "inherit";
|
|
2384
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2385
|
+
className: ConversationFallbackSwitch_module_css_default.switchRow,
|
|
2386
|
+
role: "status",
|
|
2387
|
+
children: [
|
|
2388
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2389
|
+
className: ConversationFallbackSwitch_module_css_default.switchTitle,
|
|
2390
|
+
children: t("chat.switch.title")
|
|
2391
|
+
}),
|
|
2392
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2393
|
+
className: ConversationFallbackSwitch_module_css_default.switchSep,
|
|
2394
|
+
"aria-hidden": "true"
|
|
2395
|
+
}),
|
|
2396
|
+
isRoleMapped ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2397
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2398
|
+
className: ConversationFallbackSwitch_module_css_default.roleBadge,
|
|
2399
|
+
title: data.role,
|
|
2400
|
+
children: data.role
|
|
2401
|
+
}),
|
|
2402
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2403
|
+
className: ConversationFallbackSwitch_module_css_default.roleModelMap,
|
|
2404
|
+
children: t("chat.switch.roleMap", {
|
|
2405
|
+
role: data.role,
|
|
2406
|
+
model: `${data.to.provider}/${data.to.model}`
|
|
2407
|
+
})
|
|
2408
|
+
}),
|
|
2409
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2410
|
+
className: ConversationFallbackSwitch_module_css_default.switchSep,
|
|
2411
|
+
"aria-hidden": "true"
|
|
2412
|
+
}),
|
|
2413
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2414
|
+
className: ConversationFallbackSwitch_module_css_default.switchSummary,
|
|
2415
|
+
children: t("chat.switch.summary.roleInject", { reason })
|
|
2416
|
+
})
|
|
2417
|
+
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2418
|
+
className: ConversationFallbackSwitch_module_css_default.switchSummary,
|
|
2419
|
+
children: t("chat.switch.summary", {
|
|
2420
|
+
from: `${data.from.provider}/${data.from.model}`,
|
|
2421
|
+
to: `${data.to.provider}/${data.to.model}`,
|
|
2422
|
+
reason
|
|
2423
|
+
})
|
|
2424
|
+
})
|
|
2425
|
+
]
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
//#endregion
|
|
2429
|
+
//#region src/role-projection-key.ts
|
|
2430
|
+
/**
|
|
2431
|
+
* The session-projection contract of the subagent role pill (plan
|
|
2432
|
+
* role-based-subagent-adoption Task 3b): the ONE key the host fold
|
|
2433
|
+
* (`./role-projection.ts`) publishes and the session-header badge reads.
|
|
2434
|
+
*
|
|
2435
|
+
* PURE module — no `@deepseek-ai/*` import, no host-only dependency — because
|
|
2436
|
+
* BOTH halves import it: the host through the seam's install point, the client
|
|
2437
|
+
* through `SubagentRoleBadge`. Splitting the key (and the value guard) out of
|
|
2438
|
+
* the host module is what keeps the client half free of the fold's host
|
|
2439
|
+
* imports, and a single shared literal is what keeps the two halves from
|
|
2440
|
+
* drifting into a silent "no pill".
|
|
2441
|
+
*
|
|
2442
|
+
* @module dsh-fallback-router/role-projection-key
|
|
2443
|
+
*/
|
|
2444
|
+
/**
|
|
2445
|
+
* The projection key the role pill reads (`useProjection(ROLE_PROJECTION_KEY)`).
|
|
2446
|
+
* Lower-camel like the host's own session-scoped keys (`modelSelection`,
|
|
2447
|
+
* `sessionListMetadata`); the `fallbacks` prefix keeps a third-party key
|
|
2448
|
+
* unambiguous inside the shared `SessionProjectionMap`.
|
|
2449
|
+
*/
|
|
2450
|
+
const ROLE_PROJECTION_KEY = "fallbacksSubagentRole";
|
|
2451
|
+
/**
|
|
2452
|
+
* Read a projection value defensively (degrade-never-crash): only a non-blank
|
|
2453
|
+
* string is a role. `undefined` — the key is not registered on this host, or no
|
|
2454
|
+
* baseline/frame has carried it yet — and every foreign value read as "no
|
|
2455
|
+
* role", so the pill collapses to nothing instead of naming something wrong.
|
|
2456
|
+
*
|
|
2457
|
+
* @param value - the raw `useProjection('<key>')` value.
|
|
2458
|
+
*/
|
|
2459
|
+
function readRoleProjectionValue(value) {
|
|
2460
|
+
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
2461
|
+
}
|
|
2462
|
+
//#endregion
|
|
2463
|
+
//#region \0dsh-css:D:\Repos\dsh-llm-router\src\client\SubagentRoleBadge.module.css.mjs
|
|
2464
|
+
const css = "\r\n\r\n._041c72bb_badge {\r\n display: inline-block;\r\n max-width: 240px;\r\n padding: 0 8px;\r\n border-radius: 999px;\r\n font-size: 12px;\r\n line-height: 20px;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n vertical-align: middle;\r\n background: var(--dsw-alias-bg-module-platform);\r\n color: var(--dsw-alias-label-primary);\r\n}\r\n\r\n\r\n._a23785cd_route {\r\n color: var(--dsw-alias-label-tertiary);\r\n}\r\n";
|
|
2465
|
+
const tagId = "dsh-fallback-router/SubagentRoleBadge.module.css";
|
|
2466
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
2467
|
+
const tag = document.createElement("style");
|
|
2468
|
+
tag.dataset.plugin = "dsh-fallback-router";
|
|
2469
|
+
tag.dataset.pluginCss = tagId;
|
|
2470
|
+
tag.textContent = css;
|
|
2471
|
+
document.head.appendChild(tag);
|
|
2472
|
+
}
|
|
2473
|
+
var SubagentRoleBadge_module_css_default = {
|
|
2474
|
+
"badge": "_041c72bb_badge",
|
|
2475
|
+
"route": "_a23785cd_route"
|
|
2476
|
+
};
|
|
2477
|
+
//#endregion
|
|
2478
|
+
//#region src/client/SubagentRoleBadge.tsx
|
|
2479
|
+
/**
|
|
2480
|
+
* The host's own durable model-selection projection key (`dsh-api-session-
|
|
2481
|
+
* controller`, merged into `SessionProjectionMap`): its client value carries
|
|
2482
|
+
* `next` (the route the next request will use) and `lastUsed` (the route the
|
|
2483
|
+
* latest recorded request ran on). Read through the same structural seat as the
|
|
2484
|
+
* role key.
|
|
2485
|
+
*/
|
|
2486
|
+
const MODEL_SELECTION_PROJECTION_KEY = "modelSelection";
|
|
2487
|
+
/**
|
|
2488
|
+
* `provider/model` of one model selection, or `undefined` when the value's
|
|
2489
|
+
* fields are absent or foreign.
|
|
2490
|
+
*/
|
|
2491
|
+
function selectionRoute(value) {
|
|
2492
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
2493
|
+
const { provider, model } = value;
|
|
2494
|
+
if (typeof provider !== "string" || typeof model !== "string") return void 0;
|
|
2495
|
+
const trimmedProvider = provider.trim();
|
|
2496
|
+
const trimmedModel = model.trim();
|
|
2497
|
+
if (trimmedProvider === "" || trimmedModel === "") return void 0;
|
|
2498
|
+
return `${trimmedProvider}/${trimmedModel}`;
|
|
2499
|
+
}
|
|
2500
|
+
/** Display form of a route in the pill body; the title keeps the full route. */
|
|
2501
|
+
function displayRoute(route) {
|
|
2502
|
+
return route.length > 120 ? `${route.slice(0, 119)}…` : route;
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* `provider/model` the child's NEXT request will use, falling back to the route
|
|
2506
|
+
* its latest recorded request ran on (`modelSelection.next` → `lastUsed`), or
|
|
2507
|
+
* `undefined` when neither carries a route — the badge then renders the role
|
|
2508
|
+
* alone instead of a wrong route.
|
|
2509
|
+
*/
|
|
2510
|
+
function modelSelectionRoute(value) {
|
|
2511
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
2512
|
+
const { next, lastUsed } = value;
|
|
2513
|
+
return selectionRoute(next) ?? selectionRoute(lastUsed);
|
|
2514
|
+
}
|
|
2515
|
+
/**
|
|
2516
|
+
* Render the viewed SUBAGENT session's role and model.
|
|
2517
|
+
* @param props - composed slot props (the session-kit `useProjection` /
|
|
2518
|
+
* `useSessions` seats are read structurally — see the module docblock).
|
|
2519
|
+
* @returns the badge element, or `null` when there is nothing to show.
|
|
2520
|
+
*/
|
|
2521
|
+
function SubagentRoleBadge(props) {
|
|
2522
|
+
const { t } = props;
|
|
2523
|
+
const readProjection = props.useProjection;
|
|
2524
|
+
const useSessions = props.useSessions;
|
|
2525
|
+
const sessionId = props.sessionId;
|
|
2526
|
+
if (typeof readProjection !== "function" || typeof useSessions !== "function") return null;
|
|
2527
|
+
if (typeof sessionId !== "string") return null;
|
|
2528
|
+
const isChild = useSessions((state) => state.byId?.[sessionId]?.origin === "subagent");
|
|
2529
|
+
const rawRole = readProjection(ROLE_PROJECTION_KEY);
|
|
2530
|
+
const rawModelSelection = readProjection(MODEL_SELECTION_PROJECTION_KEY);
|
|
2531
|
+
if (!isChild) return null;
|
|
2532
|
+
const declared = readRoleProjectionValue(rawRole);
|
|
2533
|
+
const role = declared === "inherit" ? void 0 : declared;
|
|
2534
|
+
const model = modelSelectionRoute(rawModelSelection);
|
|
2535
|
+
if (role === void 0 && model === void 0) return null;
|
|
2536
|
+
const title = role !== void 0 && model !== void 0 ? t("subagentRole.hover", {
|
|
2537
|
+
role,
|
|
2538
|
+
model
|
|
2539
|
+
}) : role ?? model;
|
|
2540
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2541
|
+
className: SubagentRoleBadge_module_css_default.badge,
|
|
2542
|
+
title,
|
|
2543
|
+
children: [
|
|
2544
|
+
role,
|
|
2545
|
+
role !== void 0 && model !== void 0 && " · ",
|
|
2546
|
+
model !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2547
|
+
className: SubagentRoleBadge_module_css_default.route,
|
|
2548
|
+
children: displayRoute(model)
|
|
2549
|
+
})
|
|
2550
|
+
]
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
//#endregion
|
|
2554
|
+
//#region src/client/fallbacks-store.ts
|
|
2555
|
+
/** The plugin's settings namespace on the host wire (settings/document-updated ns filter). */
|
|
2556
|
+
const FALLBACKS_SETTINGS_NS = "fallbacks";
|
|
2557
|
+
function messageOf(error) {
|
|
2558
|
+
return error instanceof Error ? error.message : String(error);
|
|
2559
|
+
}
|
|
2560
|
+
function isRecord(value) {
|
|
2561
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2564
|
+
* Read a nested value by path — the upstream `dsh-client-schema-form`
|
|
2565
|
+
* `getPath` semantics, copied locally so the provider-configured join needs no
|
|
2566
|
+
* new dependency (array indexes as numeric keys, `undefined` along a missing
|
|
2567
|
+
* branch).
|
|
2568
|
+
*/
|
|
2569
|
+
function getPath(value, path) {
|
|
2570
|
+
let current = value;
|
|
2571
|
+
for (const key of path) {
|
|
2572
|
+
if (Array.isArray(current)) {
|
|
2573
|
+
current = current[Number(key)];
|
|
2574
|
+
continue;
|
|
2575
|
+
}
|
|
2576
|
+
if (typeof current !== "object" || current === null) return void 0;
|
|
2577
|
+
current = current[key];
|
|
2578
|
+
}
|
|
2579
|
+
return current;
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* Shape-guard the wire `seeds` badge field (spec §9.4): only `{ id,
|
|
2583
|
+
* overridden }` entries survive — the `legacyKeys` element-filter
|
|
2584
|
+
* precedent. `source` is optional on the wire (gateway version skew): a
|
|
2585
|
+
* present-and-string label is kept, an absent/malformed one drops the
|
|
2586
|
+
* field while the entry itself still parses — consumers treat a missing
|
|
2587
|
+
* label as "no badge" (the degradation path, never an error). A blank or
|
|
2588
|
+
* whitespace-only label counts as malformed (it would render a textless
|
|
2589
|
+
* badge). Entries are
|
|
2590
|
+
* NORMALIZED to the known keys, so a wire entry can never smuggle a
|
|
2591
|
+
* non-string `source` past the guard's type. A non-array value resolves
|
|
2592
|
+
* to `[]`; malformed entries are dropped, so an all-bad array also lands
|
|
2593
|
+
* `[]`. The store never trusts a misshapen badge field.
|
|
2594
|
+
*/
|
|
2595
|
+
function parseSeedsWire(value) {
|
|
2596
|
+
if (!Array.isArray(value)) return [];
|
|
2597
|
+
const entries = [];
|
|
2598
|
+
for (const entry of value) {
|
|
2599
|
+
if (!isRecord(entry)) continue;
|
|
2600
|
+
if (typeof entry.id !== "string" || typeof entry.overridden !== "boolean") continue;
|
|
2601
|
+
entries.push({
|
|
2602
|
+
id: entry.id,
|
|
2603
|
+
overridden: entry.overridden,
|
|
2604
|
+
...typeof entry.source === "string" && entry.source.trim() !== "" ? { source: entry.source } : {}
|
|
2605
|
+
});
|
|
2606
|
+
}
|
|
2607
|
+
return entries;
|
|
2608
|
+
}
|
|
2609
|
+
function parsePolicyRoute(value) {
|
|
2610
|
+
if (!isRecord(value)) return void 0;
|
|
2611
|
+
if (typeof value.provider !== "string" || value.provider.length === 0) return void 0;
|
|
2612
|
+
if (typeof value.model !== "string" || value.model.length === 0) return void 0;
|
|
2613
|
+
return {
|
|
2614
|
+
provider: value.provider,
|
|
2615
|
+
model: value.model
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
/**
|
|
2619
|
+
* Shape-guard the additive `subagentPolicy` wire field (T5). Malformed
|
|
2620
|
+
* payloads resolve to `undefined` (hide the status area) — the store never
|
|
2621
|
+
* throws on an old or misshapen field (old-payload tolerance).
|
|
2622
|
+
*/
|
|
2623
|
+
function parseSubagentPolicyWire(value) {
|
|
2624
|
+
if (!isRecord(value) || typeof value.state !== "string") return void 0;
|
|
2625
|
+
if (value.state === "disabled" || value.state === "unprovable") return { state: value.state };
|
|
2626
|
+
if (value.state !== "enabled") return void 0;
|
|
2627
|
+
if (!Array.isArray(value.allowedModels)) return void 0;
|
|
2628
|
+
const allowedModels = [];
|
|
2629
|
+
for (const entry of value.allowedModels) {
|
|
2630
|
+
const route = parsePolicyRoute(entry);
|
|
2631
|
+
if (route === void 0) return void 0;
|
|
2632
|
+
allowedModels.push(route);
|
|
2633
|
+
}
|
|
2634
|
+
const view = {
|
|
2635
|
+
state: "enabled",
|
|
2636
|
+
allowedModels
|
|
2637
|
+
};
|
|
2638
|
+
if (isRecord(value.head) && (value.head.source === "authorized" || value.head.source === "injected")) {
|
|
2639
|
+
const route = parsePolicyRoute(value.head.route);
|
|
2640
|
+
if (route !== void 0) view.head = {
|
|
2641
|
+
route,
|
|
2642
|
+
source: value.head.source
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
2645
|
+
if (isRecord(value.blockedAttempt) && typeof value.blockedAttempt.at === "number") {
|
|
2646
|
+
const route = parsePolicyRoute(value.blockedAttempt.route);
|
|
2647
|
+
if (route !== void 0) view.blockedAttempt = {
|
|
2648
|
+
at: value.blockedAttempt.at,
|
|
2649
|
+
route,
|
|
2650
|
+
reason: typeof value.blockedAttempt.reason === "string" ? value.blockedAttempt.reason : ""
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
return view;
|
|
2654
|
+
}
|
|
2655
|
+
function subagentPolicyFromWire(value, fallback) {
|
|
2656
|
+
if (!isRecord(value) || !("subagentPolicy" in value)) return fallback;
|
|
2657
|
+
return parseSubagentPolicyWire(value.subagentPolicy);
|
|
2658
|
+
}
|
|
2659
|
+
/**
|
|
2660
|
+
* The provider dropdown's offer set (spec §2.5 D-4): catalog providers whose
|
|
2661
|
+
* settings profile resolves in the describe namespaces — the Models page's
|
|
2662
|
+
* `configured` predicate (`ui-models` store.ts): a provider is configured
|
|
2663
|
+
* when its settings namespace exists AND either it addresses the whole
|
|
2664
|
+
* section (`settingsPath` empty) or its profile path resolves in the resolved
|
|
2665
|
+
* value. Directory-only (unconfigured) providers never become options; the
|
|
2666
|
+
* section still renders existing values for them (read-back + annotation) so
|
|
2667
|
+
* nothing is lost on save.
|
|
2668
|
+
*/
|
|
2669
|
+
function configuredProvidersOf(providers, namespaces) {
|
|
2670
|
+
return providers.filter((entry) => {
|
|
2671
|
+
const namespace = namespaces.get(entry.settingsNs);
|
|
2672
|
+
return namespace !== void 0 && (entry.settingsPath.length === 0 || getPath(namespace.value, entry.settingsPath) !== void 0);
|
|
2673
|
+
});
|
|
2674
|
+
}
|
|
2675
|
+
/** The signed-in DeepSeek account route (no settings namespace of its own). */
|
|
2676
|
+
const ACCOUNT_PROVIDER = "deepseek-account";
|
|
2677
|
+
/**
|
|
2678
|
+
* The models a provider's own settings profile declares — the same list the
|
|
2679
|
+
* Models page edits, so the picker offers exactly the models the user enabled.
|
|
2680
|
+
* `undefined` means "the profile says nothing", which lets the caller fall back
|
|
2681
|
+
* to the runtime catalog instead of showing an empty dropdown.
|
|
2682
|
+
* @param entry - one configurable-provider directory row.
|
|
2683
|
+
* @param namespaces - the settings mirror the row's `settingsNs` addresses.
|
|
2684
|
+
* @returns the declared models, or undefined when the profile declares none.
|
|
2685
|
+
*/
|
|
2686
|
+
function declaredModelsOf(entry, namespaces) {
|
|
2687
|
+
const namespace = namespaces.get(entry.settingsNs);
|
|
2688
|
+
if (namespace === void 0) return void 0;
|
|
2689
|
+
const path = entry.settingsPath.length === 0 ? ["models"] : [...entry.settingsPath, "models"];
|
|
2690
|
+
const raw = getPath(namespace.value, path);
|
|
2691
|
+
if (!Array.isArray(raw)) return void 0;
|
|
2692
|
+
const models = [];
|
|
2693
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2694
|
+
for (const item of raw) {
|
|
2695
|
+
const record = isRecord(item) ? item : void 0;
|
|
2696
|
+
const id = typeof item === "string" ? item : typeof record?.id === "string" ? record.id : "";
|
|
2697
|
+
if (id === "" || seen.has(id)) continue;
|
|
2698
|
+
seen.add(id);
|
|
2699
|
+
const name = typeof record?.name === "string" && record.name !== "" ? record.name : id;
|
|
2700
|
+
models.push({
|
|
2701
|
+
id,
|
|
2702
|
+
name
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
return models;
|
|
2706
|
+
}
|
|
2707
|
+
/**
|
|
2708
|
+
* Build the picker catalog: configured providers only, each carrying the models
|
|
2709
|
+
* its settings profile declares, else the runtime catalog's list, else nothing
|
|
2710
|
+
* (the picker then degrades to free text for that provider). The signed-in
|
|
2711
|
+
* DeepSeek account has no settings namespace of its own, so it is offered when
|
|
2712
|
+
* — and only when — the runtime catalog reports models for it, which is exactly
|
|
2713
|
+
* the Models page's own `accountAvailable` rule.
|
|
2714
|
+
* @param providers - configured-provider rows, in directory order.
|
|
2715
|
+
* @param namespaces - the settings mirror backing {@link declaredModelsOf}.
|
|
2716
|
+
* @param groups - runtime model catalog groups (`session/modelCatalog`).
|
|
2717
|
+
* @returns the catalog offered to the panel.
|
|
2718
|
+
*/
|
|
2719
|
+
function catalogOf(providers, namespaces, groups) {
|
|
2720
|
+
const runtime = /* @__PURE__ */ new Map();
|
|
2721
|
+
for (const group of groups) runtime.set(group.id, group.models.map((model) => {
|
|
2722
|
+
const efforts = (model.reasoning?.efforts ?? []).map((effort) => ({
|
|
2723
|
+
id: effort.id,
|
|
2724
|
+
name: effort.name
|
|
2725
|
+
}));
|
|
2726
|
+
const defaultEffort = model.reasoning?.defaultEffort;
|
|
2727
|
+
return {
|
|
2728
|
+
id: model.id,
|
|
2729
|
+
name: model.name ?? model.id,
|
|
2730
|
+
efforts,
|
|
2731
|
+
...defaultEffort === void 0 ? {} : { defaultEffort }
|
|
2732
|
+
};
|
|
2733
|
+
}));
|
|
2734
|
+
const catalog = providers.map((entry) => {
|
|
2735
|
+
const declared = declaredModelsOf(entry, namespaces);
|
|
2736
|
+
if (declared === void 0) return {
|
|
2737
|
+
id: entry.provider,
|
|
2738
|
+
models: runtime.get(entry.provider) ?? []
|
|
2739
|
+
};
|
|
2740
|
+
const known = new Map((runtime.get(entry.provider) ?? []).map((model) => [model.id, model]));
|
|
2741
|
+
return {
|
|
2742
|
+
id: entry.provider,
|
|
2743
|
+
models: declared.map((model) => known.get(model.id) ?? {
|
|
2744
|
+
id: model.id,
|
|
2745
|
+
name: model.name,
|
|
2746
|
+
efforts: []
|
|
2747
|
+
})
|
|
2748
|
+
};
|
|
2749
|
+
});
|
|
2750
|
+
const account = runtime.get(ACCOUNT_PROVIDER);
|
|
2751
|
+
if (account !== void 0 && account.length > 0 && !catalog.some((entry) => entry.id === ACCOUNT_PROVIDER)) catalog.unshift({
|
|
2752
|
+
id: ACCOUNT_PROVIDER,
|
|
2753
|
+
models: account
|
|
2754
|
+
});
|
|
2755
|
+
return catalog;
|
|
2756
|
+
}
|
|
2757
|
+
function parseFallbacksConfig(value) {
|
|
2758
|
+
if (!isRecord(value)) throw new TypeError(`fallbacks descriptor value is not an object: ${String(value)}`);
|
|
2759
|
+
const triggerCodes = value.triggerCodes;
|
|
2760
|
+
if (triggerCodes !== void 0 && (!Array.isArray(triggerCodes) || triggerCodes.some((code) => typeof code !== "string"))) throw new TypeError("fallbacks descriptor triggerCodes must be a string array");
|
|
2761
|
+
const rootChain = value.rootChain;
|
|
2762
|
+
if (rootChain !== void 0 && (!Array.isArray(rootChain) || rootChain.some((entry) => typeof entry !== "string"))) throw new TypeError("fallbacks descriptor rootChain must be a string array");
|
|
2763
|
+
const namedChains = value.namedChains;
|
|
2764
|
+
if (namedChains !== void 0 && (!Array.isArray(namedChains) || namedChains.some((chain) => !isRecord(chain) || typeof chain.id !== "string" || typeof chain.name !== "string" || !Array.isArray(chain.chain) || chain.chain.some((entry) => typeof entry !== "string")))) throw new TypeError("fallbacks descriptor namedChains must contain id/name/string-array chain rows");
|
|
2765
|
+
const roles = isRecord(value.roles) ? value.roles : {};
|
|
2766
|
+
const parsedList = (Array.isArray(roles.list) ? roles.list : []).map((role, index) => {
|
|
2767
|
+
if (!isRecord(role) || typeof role.id !== "string") throw new TypeError(`fallbacks descriptor roles.list[${String(index)}] must have a string id`);
|
|
2768
|
+
const persona = role.persona;
|
|
2769
|
+
if (persona !== void 0 && typeof persona !== "string") throw new TypeError(`fallbacks descriptor roles.list[${String(index)}].persona must be a string`);
|
|
2770
|
+
const prompt = role.prompt;
|
|
2771
|
+
if (prompt !== void 0 && typeof prompt !== "string") throw new TypeError(`fallbacks descriptor roles.list[${String(index)}].prompt must be a string`);
|
|
2772
|
+
const permissions = role.permissions;
|
|
2773
|
+
if (permissions !== void 0 && (!isRecord(permissions) || permissions.allow !== void 0 && (!Array.isArray(permissions.allow) || permissions.allow.some((item) => typeof item !== "string")) || permissions.deny !== void 0 && (!Array.isArray(permissions.deny) || permissions.deny.some((item) => typeof item !== "string")))) throw new TypeError(`fallbacks descriptor roles.list[${String(index)}].permissions must be an allow/deny string-array object`);
|
|
2774
|
+
const chain = role.chain;
|
|
2775
|
+
if (chain !== void 0 && (!Array.isArray(chain) || chain.some((entry) => typeof entry !== "string"))) throw new TypeError(`fallbacks descriptor roles.list[${String(index)}].chain must be a string array`);
|
|
2776
|
+
const fallback = role.fallback;
|
|
2777
|
+
if (fallback !== void 0 && fallback !== "inherit-root" && fallback !== "none") throw new TypeError(`fallbacks descriptor roles.list[${String(index)}].fallback must be inherit-root|none`);
|
|
2778
|
+
return {
|
|
2779
|
+
id: role.id,
|
|
2780
|
+
persona: persona ?? "",
|
|
2781
|
+
...prompt === void 0 ? {} : { prompt },
|
|
2782
|
+
...permissions === void 0 ? {} : { permissions },
|
|
2783
|
+
chain: chain ?? [],
|
|
2784
|
+
fallback: fallback ?? "inherit-root"
|
|
2785
|
+
};
|
|
2786
|
+
});
|
|
2787
|
+
const parsedRules = (Array.isArray(roles.rules) ? roles.rules : []).map((rule, index) => {
|
|
2788
|
+
if (!isRecord(rule) || typeof rule.role !== "string") throw new TypeError(`fallbacks descriptor roles.rules[${String(index)}] must have a string role`);
|
|
2789
|
+
const origin = rule.origin;
|
|
2790
|
+
if (origin !== void 0 && origin !== "root" && origin !== "subagent") throw new TypeError(`fallbacks descriptor roles.rules[${String(index)}].origin must be root|subagent`);
|
|
2791
|
+
const provider = rule.provider;
|
|
2792
|
+
const model = rule.model;
|
|
2793
|
+
if (provider !== void 0 && typeof provider !== "string") throw new TypeError(`fallbacks descriptor roles.rules[${String(index)}].provider must be a string`);
|
|
2794
|
+
if (model !== void 0 && typeof model !== "string") throw new TypeError(`fallbacks descriptor roles.rules[${String(index)}].model must be a string`);
|
|
2795
|
+
return {
|
|
2796
|
+
...origin === void 0 ? {} : { origin },
|
|
2797
|
+
...provider === void 0 ? {} : { provider },
|
|
2798
|
+
...model === void 0 ? {} : { model },
|
|
2799
|
+
role: rule.role
|
|
2800
|
+
};
|
|
2801
|
+
});
|
|
2802
|
+
const cooldownMs = value.cooldownMs;
|
|
2803
|
+
const maxSwitchesPerStep = value.maxSwitchesPerStep;
|
|
2804
|
+
const alwaysModeRetryCap = value.alwaysModeRetryCap;
|
|
2805
|
+
for (const [field, raw] of [
|
|
2806
|
+
["cooldownMs", cooldownMs],
|
|
2807
|
+
["maxSwitchesPerStep", maxSwitchesPerStep],
|
|
2808
|
+
["alwaysModeRetryCap", alwaysModeRetryCap]
|
|
2809
|
+
]) if (raw !== void 0 && typeof raw !== "number") throw new TypeError(`fallbacks descriptor ${field} must be a number`);
|
|
2810
|
+
const revertPolicy = value.revertPolicy;
|
|
2811
|
+
if (revertPolicy !== void 0 && revertPolicy !== "cooldown-expiry" && revertPolicy !== "never") throw new TypeError("fallbacks descriptor revertPolicy must be cooldown-expiry|never");
|
|
2812
|
+
const presets = value.presets;
|
|
2813
|
+
if (presets !== void 0 && presets !== "bundled" && presets !== "none") throw new TypeError("fallbacks descriptor presets must be bundled|none");
|
|
2814
|
+
const roleAutoMatch = value.roleAutoMatch;
|
|
2815
|
+
if (roleAutoMatch !== void 0 && typeof roleAutoMatch !== "boolean") throw new TypeError("fallbacks descriptor roleAutoMatch must be a boolean");
|
|
2816
|
+
const timeSlots = value.timeSlots;
|
|
2817
|
+
if (timeSlots !== void 0 && (!Array.isArray(timeSlots) || timeSlots.some((row) => {
|
|
2818
|
+
if (!isRecord(row)) return true;
|
|
2819
|
+
for (const field of [
|
|
2820
|
+
"kind",
|
|
2821
|
+
"preset",
|
|
2822
|
+
"start",
|
|
2823
|
+
"end"
|
|
2824
|
+
]) if (row[field] !== void 0 && typeof row[field] !== "string") return true;
|
|
2825
|
+
const chain = row.chain;
|
|
2826
|
+
if (chain !== void 0 && (!Array.isArray(chain) || chain.some((entry) => typeof entry !== "string"))) return true;
|
|
2827
|
+
const days = row.days;
|
|
2828
|
+
if (days !== void 0 && (!Array.isArray(days) || days.some((day) => typeof day !== "number"))) return true;
|
|
2829
|
+
return false;
|
|
2830
|
+
}))) throw new TypeError("fallbacks descriptor timeSlots must be an array of slot rows (kind/preset/start/end strings, chain string array, days number array)");
|
|
2831
|
+
const tz = value.tz;
|
|
2832
|
+
if (tz !== void 0 && typeof tz !== "string") throw new TypeError("fallbacks descriptor tz must be a string");
|
|
2833
|
+
const recovery = value.recovery;
|
|
2834
|
+
if (recovery !== void 0 && recovery !== "timer" && recovery !== "half-open") throw new TypeError("fallbacks descriptor recovery must be timer|half-open");
|
|
2835
|
+
return {
|
|
2836
|
+
models: Array.isArray(value.models) ? value.models : [],
|
|
2837
|
+
providers: Array.isArray(value.providers) ? value.providers : [],
|
|
2838
|
+
triggerCodes: triggerCodes ?? [...defaultFallbacksConfig.triggerCodes],
|
|
2839
|
+
rootChain: rootChain ?? [...defaultFallbacksConfig.rootChain],
|
|
2840
|
+
namedChains: namedChains ?? [],
|
|
2841
|
+
roles: {
|
|
2842
|
+
list: parsedList,
|
|
2843
|
+
rules: parsedRules
|
|
2844
|
+
},
|
|
2845
|
+
cooldownMs: cooldownMs ?? defaultFallbacksConfig.cooldownMs,
|
|
2846
|
+
revertPolicy: revertPolicy ?? defaultFallbacksConfig.revertPolicy,
|
|
2847
|
+
maxSwitchesPerStep: maxSwitchesPerStep ?? defaultFallbacksConfig.maxSwitchesPerStep,
|
|
2848
|
+
alwaysModeRetryCap: alwaysModeRetryCap ?? defaultFallbacksConfig.alwaysModeRetryCap,
|
|
2849
|
+
presets: presets ?? defaultFallbacksConfig.presets,
|
|
2850
|
+
roleAutoMatch: roleAutoMatch ?? defaultFallbacksConfig.roleAutoMatch,
|
|
2851
|
+
timeSlots: timeSlots ?? [...defaultFallbacksConfig.timeSlots ?? []],
|
|
2852
|
+
tz: tz ?? defaultFallbacksConfig.tz,
|
|
2853
|
+
recovery: recovery ?? defaultFallbacksConfig.recovery
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Extract the most recent `fallbacks/switch` events from one history page
|
|
2858
|
+
* (spec §2.5 D-5): drop packed chunk runs, filter by event type, order by
|
|
2859
|
+
* `seq` descending, take at most `limit`. Single-page read — fewer than
|
|
2860
|
+
* `limit` events show as-is; no multi-page backfill (Non-Goal).
|
|
2861
|
+
*/
|
|
2862
|
+
function extractRecentSwitches(entries, limit = 5) {
|
|
2863
|
+
const switches = [];
|
|
2864
|
+
for (const entry of entries) {
|
|
2865
|
+
if (entry.type !== "event") continue;
|
|
2866
|
+
const event = entry.event;
|
|
2867
|
+
if (event.type !== "fallbacks/switch") continue;
|
|
2868
|
+
switches.push({
|
|
2869
|
+
...event.data,
|
|
2870
|
+
seq: event.seq,
|
|
2871
|
+
time: event.time
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
switches.sort((a, b) => b.seq - a.seq);
|
|
2875
|
+
return switches.slice(0, limit);
|
|
2876
|
+
}
|
|
2877
|
+
/** Controller joining Settings reads, writes, and pushed invalidations. */
|
|
2878
|
+
var FallbacksSettingsController = class {
|
|
2879
|
+
api;
|
|
2880
|
+
rpc;
|
|
2881
|
+
/** Snapshot consumed by the section through `useSyncExternalStore`. */
|
|
2882
|
+
store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
2883
|
+
status: "idle",
|
|
2884
|
+
error: null,
|
|
2885
|
+
writable: false,
|
|
2886
|
+
config: defaultFallbacksConfig,
|
|
2887
|
+
present: false,
|
|
2888
|
+
legacyKeys: [],
|
|
2889
|
+
seeds: [],
|
|
2890
|
+
catalogStatus: "idle",
|
|
2891
|
+
catalogError: null,
|
|
2892
|
+
providers: [],
|
|
2893
|
+
configuredProviders: [],
|
|
2894
|
+
catalogProviders: [],
|
|
2895
|
+
groups: [],
|
|
2896
|
+
catalogEpoch: 0,
|
|
2897
|
+
switchesStatus: "idle",
|
|
2898
|
+
switchesError: null,
|
|
2899
|
+
switches: [],
|
|
2900
|
+
subagentPolicy: void 0
|
|
2901
|
+
});
|
|
2902
|
+
/** Read guard: a newer load() supersedes an older one's publish. */
|
|
2903
|
+
readGeneration = 0;
|
|
2904
|
+
/**
|
|
2905
|
+
* Write guard: save()/resetToDefaults() completions ALWAYS publish unless
|
|
2906
|
+
* dispose() invalidated them — an overlapping read must never discard a
|
|
2907
|
+
* successful write's accept() (audit F1).
|
|
2908
|
+
*/
|
|
2909
|
+
writeGeneration = 0;
|
|
2910
|
+
catalogGeneration = 0;
|
|
2911
|
+
switchesGeneration = 0;
|
|
2912
|
+
/** Every settings namespace from the last describe, keyed by ns — the configured-provider join's other input. */
|
|
2913
|
+
namespaces = /* @__PURE__ */ new Map();
|
|
2914
|
+
currentSession;
|
|
2915
|
+
/**
|
|
2916
|
+
* The store's dispose signal (qc3 F-003): created alongside the store
|
|
2917
|
+
* lifecycle, threaded into every `session.follow` call, aborted once in
|
|
2918
|
+
* {@link dispose} — a follow opening still mid-await at plugin unload
|
|
2919
|
+
* (HMR / fiber dispose, or a wedged gateway stream) is cancelled promptly
|
|
2920
|
+
* instead of staying open until the mount abort or socket failure.
|
|
2921
|
+
*/
|
|
2922
|
+
followAbort = new AbortController();
|
|
2923
|
+
/**
|
|
2924
|
+
* @param api - the Remote namespace faces the store reads (settings
|
|
2925
|
+
* describe `writable` + namespace directory, llm provider directory,
|
|
2926
|
+
* session model catalog + follow tail page) — `ctx.remote` cast once at
|
|
2927
|
+
* the mount boundary.
|
|
2928
|
+
* @param rpc - the connection's generic RPC caller for the host gateway
|
|
2929
|
+
* channel (`/api`), injected from the connection handle.
|
|
2930
|
+
*/
|
|
2931
|
+
constructor(api, rpc) {
|
|
2932
|
+
this.api = api;
|
|
2933
|
+
this.rpc = rpc;
|
|
2934
|
+
}
|
|
2935
|
+
/**
|
|
2936
|
+
* Refresh the page snapshot. Latest request wins. `settings.describe`
|
|
2937
|
+
* still runs — it supplies the top-level `writable` flag (host read-only
|
|
2938
|
+
* mode) and the namespace directory (the configured-provider join's other
|
|
2939
|
+
* input) — but the fallbacks config itself rides the gateway channel:
|
|
2940
|
+
* `rpc.call('/api', 'fallbacks/get', { args: {} })`. The two reads are
|
|
2941
|
+
* independent and run in PARALLEL (Promise.all — one round trip per
|
|
2942
|
+
* refresh, not two). The `fallbacks` namespace is NOT expected in describe
|
|
2943
|
+
* anymore (it is off the apiproxy boundary post-patch); a describe failure
|
|
2944
|
+
* remains a hard `error` (the form cannot render provider/model options
|
|
2945
|
+
* without the directory), while a get failure is NOT a page error —
|
|
2946
|
+
* `present` goes false and the section keeps the usable skeleton (KD-G5).
|
|
2947
|
+
* @returns nothing; {@link store} carries success or failure.
|
|
2948
|
+
*/
|
|
2949
|
+
async load() {
|
|
2950
|
+
const generation = ++this.readGeneration;
|
|
2951
|
+
const writeGenerationAtStart = this.writeGeneration;
|
|
2952
|
+
this.store.update((state) => {
|
|
2953
|
+
state.status = "loading";
|
|
2954
|
+
state.error = null;
|
|
2955
|
+
});
|
|
2956
|
+
try {
|
|
2957
|
+
const [describeResult, getResult] = await Promise.all([this.api.settings.describe(), this.rpc.call("/api", "fallbacks/get", { args: {} }).catch(() => void 0)]);
|
|
2958
|
+
if (generation !== this.readGeneration) return;
|
|
2959
|
+
if (writeGenerationAtStart !== this.writeGeneration) return;
|
|
2960
|
+
if (!describeResult.ok) throw describeResult.error;
|
|
2961
|
+
this.namespaces = new Map(describeResult.value.namespaces.map((entry) => [entry.ns, entry]));
|
|
2962
|
+
const writable = describeResult.value.writable;
|
|
2963
|
+
let config;
|
|
2964
|
+
let legacyKeys = [];
|
|
2965
|
+
let seeds = [];
|
|
2966
|
+
if (getResult !== void 0 && getResult.ok && getResult.value !== null && typeof getResult.value === "object") {
|
|
2967
|
+
if ("config" in getResult.value) config = getResult.value.config;
|
|
2968
|
+
if ("legacyKeys" in getResult.value) {
|
|
2969
|
+
const wireLegacyKeys = getResult.value.legacyKeys;
|
|
2970
|
+
if (Array.isArray(wireLegacyKeys)) legacyKeys = wireLegacyKeys.filter((key) => typeof key === "string");
|
|
2971
|
+
}
|
|
2972
|
+
if ("seeds" in getResult.value) seeds = parseSeedsWire(getResult.value.seeds);
|
|
2973
|
+
}
|
|
2974
|
+
const subagentPolicy = getResult !== void 0 && getResult.ok ? subagentPolicyFromWire(getResult.value, void 0) : void 0;
|
|
2975
|
+
this.accept(config, writable, legacyKeys, seeds, subagentPolicy);
|
|
2976
|
+
} catch (error) {
|
|
2977
|
+
if (generation !== this.readGeneration) return;
|
|
2978
|
+
if (writeGenerationAtStart !== this.writeGeneration) return;
|
|
2979
|
+
this.fail(error);
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
/**
|
|
2983
|
+
* Refresh the provider/model catalog (`llm/listConfigurableProviders` +
|
|
2984
|
+
* `session/modelCatalog`), an
|
|
2985
|
+
* independent read path with its own generation guard so it can run
|
|
2986
|
+
* parallel to {@link load} without clobbering it (spec §2.5 D-4).
|
|
2987
|
+
* Per-provider lookup failures ride `catalogError` as a diagnostic without
|
|
2988
|
+
* failing the sound groups; a whole-load failure lands `catalogStatus:
|
|
2989
|
+
* 'error'` and never blocks the rest of the form.
|
|
2990
|
+
* @returns nothing; {@link store} carries success or failure.
|
|
2991
|
+
*/
|
|
2992
|
+
async loadCatalog() {
|
|
2993
|
+
const generation = ++this.catalogGeneration;
|
|
2994
|
+
this.store.update((state) => {
|
|
2995
|
+
state.catalogStatus = "loading";
|
|
2996
|
+
state.catalogError = null;
|
|
2997
|
+
});
|
|
2998
|
+
try {
|
|
2999
|
+
const [providersResponse, catalogResponse] = await Promise.all([this.api.llm.listConfigurableProviders(), this.api.session.modelCatalog()]);
|
|
3000
|
+
if (generation !== this.catalogGeneration) return;
|
|
3001
|
+
if (!providersResponse.ok) throw providersResponse.error;
|
|
3002
|
+
if (!catalogResponse.ok) throw catalogResponse.error;
|
|
3003
|
+
const providers = providersResponse.value;
|
|
3004
|
+
const groups = catalogResponse.value.groups;
|
|
3005
|
+
const failures = catalogResponse.value.failures;
|
|
3006
|
+
this.store.update((state) => {
|
|
3007
|
+
state.catalogStatus = "ready";
|
|
3008
|
+
state.catalogError = failures.length > 0 ? failures.map((failure) => `${failure.name}: ${failure.message}`).join("; ") : null;
|
|
3009
|
+
state.providers = providers;
|
|
3010
|
+
state.configuredProviders = configuredProvidersOf(providers, this.namespaces);
|
|
3011
|
+
state.catalogProviders = catalogOf(state.configuredProviders, this.namespaces, groups);
|
|
3012
|
+
state.groups = groups;
|
|
3013
|
+
state.catalogEpoch += 1;
|
|
3014
|
+
});
|
|
3015
|
+
} catch (error) {
|
|
3016
|
+
if (generation !== this.catalogGeneration) return;
|
|
3017
|
+
const wire = error;
|
|
3018
|
+
this.store.update((state) => {
|
|
3019
|
+
state.catalogStatus = "error";
|
|
3020
|
+
state.catalogError = typeof wire?.message === "string" ? wire.message : messageOf(error);
|
|
3021
|
+
});
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
/**
|
|
3025
|
+
* Record the current session the status block reads (spec §2.5 D-5). Once
|
|
3026
|
+
* the block has been read once, its summary follows session switches
|
|
3027
|
+
* immediately; an idle block only records the id — the section's mount
|
|
3028
|
+
* effect performs the first read.
|
|
3029
|
+
* @param sessionId - the session whose history is summarized; undefined
|
|
3030
|
+
* (no current session) resolves to the empty state.
|
|
3031
|
+
*/
|
|
3032
|
+
setCurrentSession(sessionId) {
|
|
3033
|
+
if (sessionId === this.currentSession) return;
|
|
3034
|
+
this.currentSession = sessionId;
|
|
3035
|
+
if (this.store.getSnapshot().switchesStatus !== "idle") this.loadSwitches();
|
|
3036
|
+
}
|
|
3037
|
+
/**
|
|
3038
|
+
* Read the recent-switch summary for the current session (spec §2.5 D-5):
|
|
3039
|
+
* one tail page (`maxMessages` = {@link SWITCHES_HISTORY_PAGE}) read from
|
|
3040
|
+
* the `session/follow` opening snapshot — the host has no unary tail-page
|
|
3041
|
+
* read (`session/page` needs the follow opening frame's cursor), so the
|
|
3042
|
+
* stream is cancelled right after its first frame —
|
|
3043
|
+
* `fallbacks/switch` events extracted newest-first capped at
|
|
3044
|
+
* {@link RECENT_SWITCH_LIMIT}. No current session → honest empty ready
|
|
3045
|
+
* state (no RPC); a read failure lands `switchesStatus: 'error'` and never
|
|
3046
|
+
* touches the settings state (the form keeps editing/saving normally).
|
|
3047
|
+
* @returns nothing; {@link store} carries success or failure.
|
|
3048
|
+
*/
|
|
3049
|
+
async loadSwitches() {
|
|
3050
|
+
const generation = ++this.switchesGeneration;
|
|
3051
|
+
const sessionId = this.currentSession;
|
|
3052
|
+
if (sessionId === void 0) {
|
|
3053
|
+
this.store.update((state) => {
|
|
3054
|
+
state.switchesStatus = "ready";
|
|
3055
|
+
state.switchesError = null;
|
|
3056
|
+
state.switches = [];
|
|
3057
|
+
});
|
|
3058
|
+
return;
|
|
3059
|
+
}
|
|
3060
|
+
this.store.update((state) => {
|
|
3061
|
+
state.switchesStatus = "loading";
|
|
3062
|
+
state.switchesError = null;
|
|
3063
|
+
});
|
|
3064
|
+
try {
|
|
3065
|
+
const iterator = this.api.session.follow({
|
|
3066
|
+
address: {
|
|
3067
|
+
kind: "session",
|
|
3068
|
+
sessionId
|
|
3069
|
+
},
|
|
3070
|
+
maxMessages: 50
|
|
3071
|
+
}, this.followAbort.signal)[Symbol.asyncIterator]();
|
|
3072
|
+
let first;
|
|
3073
|
+
try {
|
|
3074
|
+
first = await iterator.next();
|
|
3075
|
+
} finally {
|
|
3076
|
+
await iterator.return?.();
|
|
3077
|
+
}
|
|
3078
|
+
if (generation !== this.switchesGeneration) return;
|
|
3079
|
+
if (first.done || first.value.type !== "snapshot") throw new Error("session follow closed before its opening snapshot");
|
|
3080
|
+
const switches = extractRecentSwitches(first.value.records);
|
|
3081
|
+
this.store.update((state) => {
|
|
3082
|
+
state.switchesStatus = "ready";
|
|
3083
|
+
state.switchesError = null;
|
|
3084
|
+
state.switches = switches;
|
|
3085
|
+
});
|
|
3086
|
+
} catch (error) {
|
|
3087
|
+
if (generation !== this.switchesGeneration) return;
|
|
3088
|
+
const wire = error;
|
|
3089
|
+
this.store.update((state) => {
|
|
3090
|
+
state.switchesStatus = "error";
|
|
3091
|
+
state.switchesError = typeof wire?.message === "string" ? wire.message : messageOf(error);
|
|
3092
|
+
});
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
/**
|
|
3096
|
+
* Persist the full edited configuration through the gateway channel
|
|
3097
|
+
* (`/api/fallbacks/set`). The full config is sent as a MERGE patch (guide
|
|
3098
|
+
* §9) — keys the new schema cannot express (legacy `chains` /
|
|
3099
|
+
* `roles.default` in the user layer) survive the write, which is why the
|
|
3100
|
+
* gateway returns POST-WRITE `legacyKeys` and the banner stays honest
|
|
3101
|
+
* (W-1/F-1). The merge has no revision guard: any failure (business
|
|
3102
|
+
* rejection or transport) surfaces its message in `state.error` for the
|
|
3103
|
+
* section's error banner and the form stays editable for retry (KD-G3).
|
|
3104
|
+
* @param next - the complete edited configuration.
|
|
3105
|
+
*/
|
|
3106
|
+
async save(next) {
|
|
3107
|
+
const state = this.store.getSnapshot();
|
|
3108
|
+
if (!state.writable || state.status === "saving") return;
|
|
3109
|
+
const generation = ++this.writeGeneration;
|
|
3110
|
+
this.store.update((draft) => {
|
|
3111
|
+
draft.status = "saving";
|
|
3112
|
+
draft.error = null;
|
|
3113
|
+
});
|
|
3114
|
+
try {
|
|
3115
|
+
const result = await this.rpc.call("/api", "fallbacks/set", { args: { patch: next } });
|
|
3116
|
+
if (generation !== this.writeGeneration) return;
|
|
3117
|
+
if (!result.ok) throw result.error;
|
|
3118
|
+
this.acceptWire(result.value);
|
|
3119
|
+
} catch (error) {
|
|
3120
|
+
if (generation !== this.writeGeneration) return;
|
|
3121
|
+
this.fail(error);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
/**
|
|
3125
|
+
* Explicit "sync to host allowlist" write (plan
|
|
3126
|
+
* role-chain-allowlist-visibility T2): the gateway endpoint merges the
|
|
3127
|
+
* CURRENT allowlist with this plugin's exact chain routes plus the virtual
|
|
3128
|
+
* `FallbacksChain/Auto` route and writes only `allowedModels`. The button
|
|
3129
|
+
* click is the ONLY trigger — the store never syncs on its own.
|
|
3130
|
+
* @returns true when the write landed (the card then reads the fresh
|
|
3131
|
+
* snapshot from the store); false on a refused/failed call, leaving the
|
|
3132
|
+
* last accepted state untouched. A response discarded by the write
|
|
3133
|
+
* generation guard is still a landed write — dispose() is the only
|
|
3134
|
+
* invalidator, so it must not report failure.
|
|
3135
|
+
*/
|
|
3136
|
+
async syncAllowlist() {
|
|
3137
|
+
if (!this.store.getSnapshot().writable) return false;
|
|
3138
|
+
const generation = ++this.writeGeneration;
|
|
3139
|
+
try {
|
|
3140
|
+
const result = await this.rpc.call("/api", "fallbacks/sync-allowlist", { args: {} });
|
|
3141
|
+
if (!result.ok) return false;
|
|
3142
|
+
if (generation === this.writeGeneration) this.acceptWire(result.value);
|
|
3143
|
+
return true;
|
|
3144
|
+
} catch {
|
|
3145
|
+
return false;
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
/**
|
|
3149
|
+
* Reset to composition defaults through the gateway channel
|
|
3150
|
+
* (`/api/fallbacks/reset` — the fallbacks-specific third method; the host
|
|
3151
|
+
* clears the user layer via `settings.replace(ns, {})`, the removal path a
|
|
3152
|
+
* merge cannot express). Same error handling as {@link save} (KD-G3).
|
|
3153
|
+
*/
|
|
3154
|
+
async resetToDefaults() {
|
|
3155
|
+
const state = this.store.getSnapshot();
|
|
3156
|
+
if (!state.writable || state.status === "saving") return;
|
|
3157
|
+
const generation = ++this.writeGeneration;
|
|
3158
|
+
this.store.update((draft) => {
|
|
3159
|
+
draft.status = "saving";
|
|
3160
|
+
draft.error = null;
|
|
3161
|
+
});
|
|
3162
|
+
try {
|
|
3163
|
+
const result = await this.rpc.call("/api", "fallbacks/reset", { args: {} });
|
|
3164
|
+
if (generation !== this.writeGeneration) return;
|
|
3165
|
+
if (!result.ok) throw result.error;
|
|
3166
|
+
this.acceptWire(result.value);
|
|
3167
|
+
} catch (error) {
|
|
3168
|
+
if (generation !== this.writeGeneration) return;
|
|
3169
|
+
this.fail(error);
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
/** Stop in-flight responses from publishing after plugin disposal. */
|
|
3173
|
+
dispose() {
|
|
3174
|
+
this.readGeneration += 1;
|
|
3175
|
+
this.writeGeneration += 1;
|
|
3176
|
+
this.catalogGeneration += 1;
|
|
3177
|
+
this.switchesGeneration += 1;
|
|
3178
|
+
this.namespaces = /* @__PURE__ */ new Map();
|
|
3179
|
+
this.followAbort.abort();
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Unpack one write response (set / reset / sync-allowlist) into the store
|
|
3183
|
+
* snapshot. The additive fields (legacyKeys §9, seeds §9.4, subagentPolicy
|
|
3184
|
+
* D4) follow the W-1/F-1 rule: absent on the wire keeps the last accepted
|
|
3185
|
+
* value — only a `get` may settle server truth.
|
|
3186
|
+
*/
|
|
3187
|
+
acceptWire(value) {
|
|
3188
|
+
const config = value !== null && typeof value === "object" && "config" in value ? value.config : void 0;
|
|
3189
|
+
let legacyKeys = this.store.getSnapshot().legacyKeys;
|
|
3190
|
+
if (value !== null && typeof value === "object" && "legacyKeys" in value) {
|
|
3191
|
+
const wireLegacyKeys = value.legacyKeys;
|
|
3192
|
+
if (Array.isArray(wireLegacyKeys)) legacyKeys = wireLegacyKeys.filter((key) => typeof key === "string");
|
|
3193
|
+
}
|
|
3194
|
+
let seeds = this.store.getSnapshot().seeds;
|
|
3195
|
+
if (value !== null && typeof value === "object" && "seeds" in value) {
|
|
3196
|
+
const wireSeeds = value.seeds;
|
|
3197
|
+
if (Array.isArray(wireSeeds)) seeds = parseSeedsWire(wireSeeds);
|
|
3198
|
+
}
|
|
3199
|
+
const subagentPolicy = subagentPolicyFromWire(value, this.store.getSnapshot().subagentPolicy);
|
|
3200
|
+
this.accept(config, true, legacyKeys, seeds, subagentPolicy);
|
|
3201
|
+
}
|
|
3202
|
+
/**
|
|
3203
|
+
* Publish a settled load: `status` ready, `writable` from describe, and —
|
|
3204
|
+
* only when the gateway returned a REAL config — `present` true and
|
|
3205
|
+
* `state.config` replaced with the parsed value. A get that did not
|
|
3206
|
+
* resolve (`config === undefined`) lands `present` false and keeps the
|
|
3207
|
+
* last accepted config (the defaults skeleton on a first load) — the
|
|
3208
|
+
* draft seed invariant (I-1): a transient channel-down must never seed
|
|
3209
|
+
* the form with defaults over real server truth. `legacyKeys` rides the
|
|
3210
|
+
* same publish: the wire field drives the migration banner. save/reset
|
|
3211
|
+
* pass the POST-WRITE value (W-1/F-1) — or the previous value when the
|
|
3212
|
+
* response omits the field, so a write can never clear the banner
|
|
3213
|
+
* against server truth; only a real `get` may. `seeds` (spec §9.4)
|
|
3214
|
+
* follows the same honest rule: the wire badge field is authoritative
|
|
3215
|
+
* only when a real config resolved — a transient channel-down keeps the
|
|
3216
|
+
* last accepted badge state.
|
|
3217
|
+
*/
|
|
3218
|
+
accept(config, writable, legacyKeys, seeds, subagentPolicy) {
|
|
3219
|
+
const parsed = config === void 0 ? void 0 : parseFallbacksConfig(config);
|
|
3220
|
+
this.store.update((state) => {
|
|
3221
|
+
state.status = "ready";
|
|
3222
|
+
state.error = null;
|
|
3223
|
+
state.writable = writable;
|
|
3224
|
+
state.present = parsed !== void 0;
|
|
3225
|
+
state.legacyKeys = parsed === void 0 ? state.legacyKeys : legacyKeys;
|
|
3226
|
+
state.seeds = parsed === void 0 ? state.seeds : seeds;
|
|
3227
|
+
state.subagentPolicy = parsed === void 0 ? state.subagentPolicy : subagentPolicy;
|
|
3228
|
+
if (parsed !== void 0) state.config = parsed;
|
|
3229
|
+
state.configuredProviders = configuredProvidersOf(state.providers, this.namespaces);
|
|
3230
|
+
state.catalogProviders = catalogOf(state.configuredProviders, this.namespaces, state.groups);
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3233
|
+
fail(error) {
|
|
3234
|
+
const wire = error;
|
|
3235
|
+
this.store.update((state) => {
|
|
3236
|
+
state.status = "error";
|
|
3237
|
+
state.error = typeof wire?.message === "string" ? wire.message : messageOf(error);
|
|
3238
|
+
});
|
|
3239
|
+
}
|
|
3240
|
+
};
|
|
3241
|
+
/**
|
|
3242
|
+
* Refetch after reconnect / settings change only when the section has already
|
|
3243
|
+
* opened once.
|
|
3244
|
+
* @param controller - the fallbacks settings controller.
|
|
3245
|
+
*/
|
|
3246
|
+
function refreshFallbacksIfLoaded(controller) {
|
|
3247
|
+
if (controller.store.getSnapshot().status === "idle") return;
|
|
3248
|
+
controller.load();
|
|
3249
|
+
}
|
|
3250
|
+
/**
|
|
3251
|
+
* Refetch the catalog after `llm/adapters-updated` only when it has already
|
|
3252
|
+
* been opened once (the catalog twin of {@link refreshFallbacksIfLoaded}).
|
|
3253
|
+
* @param controller - the fallbacks settings controller.
|
|
3254
|
+
*/
|
|
3255
|
+
function refreshCatalogIfLoaded(controller) {
|
|
3256
|
+
if (controller.store.getSnapshot().catalogStatus === "idle") return;
|
|
3257
|
+
controller.loadCatalog();
|
|
3258
|
+
}
|
|
3259
|
+
/**
|
|
3260
|
+
* Refetch the recent-switch summary after `settings/document-updated`
|
|
3261
|
+
* (fallbacks ns) / `connection/reset` only when the status block has already
|
|
3262
|
+
* been read once
|
|
3263
|
+
* (the switches twin of {@link refreshFallbacksIfLoaded}).
|
|
3264
|
+
* @param controller - the fallbacks settings controller.
|
|
3265
|
+
*/
|
|
3266
|
+
function refreshSwitchesIfLoaded(controller) {
|
|
3267
|
+
if (controller.store.getSnapshot().switchesStatus === "idle") return;
|
|
3268
|
+
controller.loadSwitches();
|
|
3269
|
+
}
|
|
3270
|
+
//#endregion
|
|
3271
|
+
//#region src/client/index.ts
|
|
3272
|
+
/**
|
|
3273
|
+
* Required services (cordis fiber inject); registrations wait on the slot
|
|
3274
|
+
* declaration. `uiConversation` is declared because the D1 Definition
|
|
3275
|
+
* registration reads the service directly (`ctx.uiConversation.events.register`
|
|
3276
|
+
* at the bottom of `apply` — explicit fiber-ordering parity with the
|
|
3277
|
+
* ui-workflow-run precedent, whose inject list includes it for the same
|
|
3278
|
+
* direct read). Cordis would still provide the service synchronously on
|
|
3279
|
+
* apply, but the declaration makes the dependency honest. `sessions` is
|
|
3280
|
+
* deliberately NOT injected (S-g): a non-web host without the dsh-session
|
|
3281
|
+
* client service must not hang the fiber waiting for it — the wiring reads
|
|
3282
|
+
* it reflectively and degrades to the switches empty state when absent
|
|
3283
|
+
* (`setCurrentSession` never called, `loadSwitches` ready with an empty
|
|
3284
|
+
* array, which the store already supports).
|
|
3285
|
+
*
|
|
3286
|
+
* The host's dotted-namespace contract: each client Remote namespace is a
|
|
3287
|
+
* child-fiber service named `remote.<ns>` (upstream `remoteServiceKey`), and
|
|
3288
|
+
* the traceable proxy forwards `ctx.remote.llm` / `.settings` / `.session`
|
|
3289
|
+
* to those context properties — consumers MUST declare the dotted names
|
|
3290
|
+
* here or the fiber walk throws `cannot get property "remote.llm" without
|
|
3291
|
+
* inject`. `remote` stays for the `$on` invalidation face.
|
|
3292
|
+
*/
|
|
3293
|
+
const inject = [
|
|
3294
|
+
"slots",
|
|
3295
|
+
"locale",
|
|
3296
|
+
"connection",
|
|
3297
|
+
"remote",
|
|
3298
|
+
"uiConversation",
|
|
3299
|
+
"remote.llm",
|
|
3300
|
+
"remote.settings",
|
|
3301
|
+
"remote.session"
|
|
3302
|
+
];
|
|
3303
|
+
/**
|
|
3304
|
+
* The session the client is LOOKING at, derived from the sessions-list
|
|
3305
|
+
* snapshot. The host moved view ownership out of `SessionListState` (the
|
|
3306
|
+
* `current` field is gone — "navigation belongs to view owners"): the viewed
|
|
3307
|
+
* session is the one the shell retains under the `mainView` reference source,
|
|
3308
|
+
* surfaced as a positive `retainedBy.mainView` count on the row
|
|
3309
|
+
* (`SessionSummary.retainedBy`, the same signal `ui-session`'s main-view
|
|
3310
|
+
* derivation reads). First match in host list order; `undefined` while no
|
|
3311
|
+
* session is open — the switches face degrades to its empty state.
|
|
3312
|
+
*/
|
|
3313
|
+
function viewedSessionId(state) {
|
|
3314
|
+
if (!Array.isArray(state?.ids)) return void 0;
|
|
3315
|
+
for (const id of state.ids) {
|
|
3316
|
+
const row = state.byId[id];
|
|
3317
|
+
const mainView = (row?.retainedBy)?.mainView ?? 0;
|
|
3318
|
+
if (row !== void 0 && mainView > 0) return id;
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
/**
|
|
3322
|
+
* Register the `fallbacks` dictionaries and the plugin-config card once the
|
|
3323
|
+
* `plugins.bundle.config` declaration is on the ledger.
|
|
3324
|
+
* @param ctx - client root context.
|
|
3325
|
+
*/
|
|
3326
|
+
function apply(ctx) {
|
|
3327
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
3328
|
+
zh,
|
|
3329
|
+
en
|
|
3330
|
+
}), "llm-router: dictionaries");
|
|
3331
|
+
const connection = ctx.get("connection");
|
|
3332
|
+
const sessions = ctx.get("sessions");
|
|
3333
|
+
const controller = new FallbacksSettingsController(ctx.remote, connection.rpc);
|
|
3334
|
+
const useSnapshot = bindSnapshotSelector(controller.store);
|
|
3335
|
+
ctx.effect(() => {
|
|
3336
|
+
const syncSession = () => {
|
|
3337
|
+
controller.setCurrentSession(sessions === void 0 ? void 0 : viewedSessionId(sessions.list.getSnapshot()));
|
|
3338
|
+
};
|
|
3339
|
+
if (sessions !== void 0) syncSession();
|
|
3340
|
+
const refresh = (ns) => {
|
|
3341
|
+
if (ns !== void 0 && ns !== "fallbacks") return;
|
|
3342
|
+
refreshFallbacksIfLoaded(controller);
|
|
3343
|
+
refreshSwitchesIfLoaded(controller);
|
|
3344
|
+
};
|
|
3345
|
+
const refreshCatalog = () => {
|
|
3346
|
+
refreshCatalogIfLoaded(controller);
|
|
3347
|
+
};
|
|
3348
|
+
let pendingReset = false;
|
|
3349
|
+
let disposed = false;
|
|
3350
|
+
const refreshAll = () => {
|
|
3351
|
+
if (pendingReset) return;
|
|
3352
|
+
pendingReset = true;
|
|
3353
|
+
queueMicrotask(() => {
|
|
3354
|
+
pendingReset = false;
|
|
3355
|
+
if (disposed) return;
|
|
3356
|
+
refresh();
|
|
3357
|
+
refreshCatalog();
|
|
3358
|
+
});
|
|
3359
|
+
};
|
|
3360
|
+
const disposers = [
|
|
3361
|
+
ctx.remote.$on("settings/document-updated", refresh),
|
|
3362
|
+
ctx.remote.$on("llm/adapters-updated", refreshCatalog),
|
|
3363
|
+
ctx.on("connection/reset", refreshAll),
|
|
3364
|
+
...sessions === void 0 ? [] : [sessions.list.subscribe(syncSession)]
|
|
3365
|
+
];
|
|
3366
|
+
return () => {
|
|
3367
|
+
disposed = true;
|
|
3368
|
+
for (const dispose of disposers) dispose();
|
|
3369
|
+
controller.dispose();
|
|
3370
|
+
};
|
|
3371
|
+
}, "llm-router: pushed invalidations");
|
|
3372
|
+
const BUNDLE_NAME = "dsh-fallback-router";
|
|
3373
|
+
ctx.slots.inject("plugins.bundle.config", function* () {
|
|
3374
|
+
yield ctx.slots.register({
|
|
3375
|
+
name: "plugins.bundle.config",
|
|
3376
|
+
key: BUNDLE_NAME,
|
|
3377
|
+
locale: NS,
|
|
3378
|
+
inject: () => ({
|
|
3379
|
+
controller,
|
|
3380
|
+
hooks: { snapshot: controller.store }
|
|
3381
|
+
})
|
|
3382
|
+
}, FallbacksCard);
|
|
3383
|
+
});
|
|
3384
|
+
ctx.slots.inject("settings.general.item", function* () {
|
|
3385
|
+
yield ctx.slots.register({
|
|
3386
|
+
name: "settings.general.item",
|
|
3387
|
+
id: "fallbacks",
|
|
3388
|
+
order: 100,
|
|
3389
|
+
locale: NS,
|
|
3390
|
+
inject: () => ({
|
|
3391
|
+
controller,
|
|
3392
|
+
useSnapshot
|
|
3393
|
+
})
|
|
3394
|
+
}, GeneralFallbacksRow);
|
|
3395
|
+
});
|
|
3396
|
+
ctx.effect(() => ctx.uiConversation.events.register(fallbackSwitchDefinition), "llm-router: conversation node definition");
|
|
3397
|
+
ctx.slots.inject("conversation.chat.node", function* () {
|
|
3398
|
+
yield ctx.slots.register({
|
|
3399
|
+
name: "conversation.chat.node",
|
|
3400
|
+
key: "fallbacks-switch",
|
|
3401
|
+
locale: NS
|
|
3402
|
+
}, ConversationFallbackSwitch);
|
|
3403
|
+
});
|
|
3404
|
+
ctx.slots.inject("conversation.session.header.actions", function* () {
|
|
3405
|
+
yield ctx.slots.register({
|
|
3406
|
+
name: "conversation.session.header.actions",
|
|
3407
|
+
id: "fallbacks-subagent-role",
|
|
3408
|
+
order: -5,
|
|
3409
|
+
locale: NS
|
|
3410
|
+
}, SubagentRoleBadge);
|
|
3411
|
+
});
|
|
3412
|
+
}
|
|
3413
|
+
//#endregion
|
|
3414
|
+
exports.FALLBACKS_SETTINGS_NS = FALLBACKS_SETTINGS_NS;
|
|
3415
|
+
exports.FallbacksSettingsController = FallbacksSettingsController;
|
|
3416
|
+
exports.apply = apply;
|
|
3417
|
+
exports.inject = inject;
|
|
3418
|
+
return module.exports;
|
|
3419
|
+
}
|
|
3420
|
+
});
|