dsh-daruma 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/StatusDock.js +2 -11
- package/lib/client/StatusDock.js.map +1 -1
- package/lib/client/api.d.ts +2 -0
- package/lib/client/api.js.map +1 -1
- package/lib/client/health.d.ts +20 -0
- package/lib/client/health.js +27 -0
- package/lib/client/health.js.map +1 -0
- package/lib/client.js +26 -8
- package/lib/client.js.map +1 -1
- package/lib/engine.d.ts +6 -0
- package/lib/engine.js +9 -0
- package/lib/engine.js.map +1 -1
- package/lib/failover-events.d.ts +56 -0
- package/lib/failover-events.js +37 -0
- package/lib/failover-events.js.map +1 -0
- package/lib/index.d.ts +2 -7
- package/lib/index.js +15 -3
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/client/StatusDock.js
CHANGED
|
@@ -6,6 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
6
6
|
*/
|
|
7
7
|
import { useCallback, useEffect, useState } from 'react';
|
|
8
8
|
import { Button, IconCheckOutline16, IconWarningOutline16 } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
9
|
+
import { overallState } from "./health.js";
|
|
9
10
|
import { BackupPanel } from "./BackupPanel.js";
|
|
10
11
|
const controlStyle = {
|
|
11
12
|
display: 'inline-flex',
|
|
@@ -16,16 +17,6 @@ const controlStyle = {
|
|
|
16
17
|
textOverflow: 'ellipsis',
|
|
17
18
|
whiteSpace: 'nowrap',
|
|
18
19
|
};
|
|
19
|
-
/** Overall health: any cooling channel → error, any probe → warning, else done. */
|
|
20
|
-
function overallState(status) {
|
|
21
|
-
if (status === null)
|
|
22
|
-
return 'ongoing';
|
|
23
|
-
if (status.channels.some((c) => c.state === 'COOLDOWN'))
|
|
24
|
-
return 'error';
|
|
25
|
-
if (status.channels.some((c) => c.state === 'PROBE'))
|
|
26
|
-
return 'warning';
|
|
27
|
-
return 'done';
|
|
28
|
-
}
|
|
29
20
|
const iconColor = {
|
|
30
21
|
done: 'var(--dsw-text-success, #30a46c)',
|
|
31
22
|
warning: 'var(--dsw-text-warning, #f5a524)',
|
|
@@ -59,7 +50,7 @@ export function StatusDock(props) {
|
|
|
59
50
|
const backupLabel = status?.backup !== null && status?.backup !== undefined
|
|
60
51
|
? `${status.backup.provider}/${status.backup.model}`
|
|
61
52
|
: t('backupNone');
|
|
62
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Button, { size: "sm", variant: "ghost", title: t('backupManageHint'), onClick: () => setPanelOpen(true), style: controlStyle, children: [_jsx(StatusIcon, { state: overallState(status) }), _jsxs("span", { style: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: [t('backup'), ": ", backupLabel] })] }), panelOpen && (_jsx(BackupPanel, { api: props.api, t: t, status: status, onClose: () => {
|
|
53
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Button, { size: "sm", variant: "ghost", title: t('backupManageHint'), onClick: () => setPanelOpen(true), style: controlStyle, children: [_jsx(StatusIcon, { state: overallState(status?.channels ?? null, Date.now()) }), _jsxs("span", { style: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: [t('backup'), ": ", backupLabel] })] }), panelOpen && (_jsx(BackupPanel, { api: props.api, t: t, status: status, onClose: () => {
|
|
63
54
|
setPanelOpen(false);
|
|
64
55
|
void load();
|
|
65
56
|
} }))] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusDock.js","sourceRoot":"","sources":["../../src/client/StatusDock.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAExG,OAAO,EAAE,WAAW,EAAE,MAA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AC,GAAI,EACzE,gBAAM,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,aAC7F,CAAC,CAAC,QAAQ,CAAC,QAAI,WAAW,IACtB,IACA,EACR,SAAS,IAAI,CACZ,KAAC,WAAW,IACV,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,CAAC,EAAE,CAAC,EACJ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;oBACZ,YAAY,CAAC,KAAK,CAAC,CAAA;oBACnB,KAAK,IAAI,EAAE,CAAA;gBACb,CAAC,GACD,CACH,IACA,CACJ,CAAA;AACH,CAAC"}
|
package/lib/client/api.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface ChannelHealthView {
|
|
|
7
7
|
channel: string;
|
|
8
8
|
state: ChannelState;
|
|
9
9
|
failures: number;
|
|
10
|
+
/** Epoch ms when the channel's cooldown ends; `0` when not cooling. */
|
|
11
|
+
cooldownUntilMs: number;
|
|
10
12
|
}
|
|
11
13
|
export interface StatusView {
|
|
12
14
|
current: string | null;
|
package/lib/client/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0CH,MAAM,UAAU,SAAS,CAAC,GAAQ;IAChC,MAAM,IAAI,GAAG,KAAK,EAAK,QAAgB,EAAE,OAAiB,EAAc,EAAE;QACxE,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAiB,CAAA;QAC7D,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,cAAc,QAAQ,SAAS,CAAC,CAAA;QAC3E,CAAC;QACD,OAAO,MAAM,CAAC,KAAU,CAAA;IAC1B,CAAC,CAAA;IAED,OAAO;QACL,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAa,QAAQ,CAAC;QACxC,cAAc,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAkB,gBAAgB,EAAE,EAAE,QAAQ,EAAE,CAAC;QACnF,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;YACnC,MAAM,IAAI,CAAkB,WAAW,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;QAC/D,CAAC;QACD,WAAW,EAAE,KAAK,IAAI,EAAE;YACtB,MAAM,IAAI,CAAkB,aAAa,CAAC,CAAA;QAC5C,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time-aware channel-health classification for the status dock.
|
|
3
|
+
*
|
|
4
|
+
* The host exposes no request-success event, so a channel whose cooldown has
|
|
5
|
+
* expired keeps its `COOLDOWN` state field forever — it becomes routable again
|
|
6
|
+
* (`canRouteNow`) without ever flipping back to `HEALTHY`. The dock therefore
|
|
7
|
+
* must judge by time, not by the raw state field: only a channel that is
|
|
8
|
+
* *still* cooling (cooldown not yet expired) counts as an error.
|
|
9
|
+
*/
|
|
10
|
+
import type { ChannelHealthView } from './api.ts';
|
|
11
|
+
export type Dot = 'done' | 'warning' | 'ongoing' | 'error';
|
|
12
|
+
/**
|
|
13
|
+
* Overall dock state:
|
|
14
|
+
* - `error` — at least one channel is still cooling (`cooldownUntilMs > now`).
|
|
15
|
+
* - `warning` — a probe is in flight (kept for parity; the adapter no longer
|
|
16
|
+
* enters PROBE, but persisted legacy states may surface it).
|
|
17
|
+
* - `done` — everything routable: healthy, or cooled down long enough.
|
|
18
|
+
* - `ongoing` — no snapshot yet.
|
|
19
|
+
*/
|
|
20
|
+
export declare function overallState(channels: readonly ChannelHealthView[] | null, nowMs: number): Dot;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time-aware channel-health classification for the status dock.
|
|
3
|
+
*
|
|
4
|
+
* The host exposes no request-success event, so a channel whose cooldown has
|
|
5
|
+
* expired keeps its `COOLDOWN` state field forever — it becomes routable again
|
|
6
|
+
* (`canRouteNow`) without ever flipping back to `HEALTHY`. The dock therefore
|
|
7
|
+
* must judge by time, not by the raw state field: only a channel that is
|
|
8
|
+
* *still* cooling (cooldown not yet expired) counts as an error.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Overall dock state:
|
|
12
|
+
* - `error` — at least one channel is still cooling (`cooldownUntilMs > now`).
|
|
13
|
+
* - `warning` — a probe is in flight (kept for parity; the adapter no longer
|
|
14
|
+
* enters PROBE, but persisted legacy states may surface it).
|
|
15
|
+
* - `done` — everything routable: healthy, or cooled down long enough.
|
|
16
|
+
* - `ongoing` — no snapshot yet.
|
|
17
|
+
*/
|
|
18
|
+
export function overallState(channels, nowMs) {
|
|
19
|
+
if (channels === null)
|
|
20
|
+
return 'ongoing';
|
|
21
|
+
if (channels.some((c) => c.state === 'COOLDOWN' && c.cooldownUntilMs > nowMs))
|
|
22
|
+
return 'error';
|
|
23
|
+
if (channels.some((c) => c.state === 'PROBE'))
|
|
24
|
+
return 'warning';
|
|
25
|
+
return 'done';
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/client/health.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,QAA6C,EAC7C,KAAa;IAEb,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IACvC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,UAAU,IAAI,CAAC,CAAC,eAAe,GAAG,KAAK,CAAC;QAAE,OAAO,OAAO,CAAA;IAC7F,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC;QAAE,OAAO,SAAS,CAAA;IAC/D,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/lib/client.js
CHANGED
|
@@ -88,6 +88,31 @@ window.__ModuleLoader__.load({
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
//#endregion
|
|
91
|
+
//#region lib/client/health.js
|
|
92
|
+
/**
|
|
93
|
+
* Time-aware channel-health classification for the status dock.
|
|
94
|
+
*
|
|
95
|
+
* The host exposes no request-success event, so a channel whose cooldown has
|
|
96
|
+
* expired keeps its `COOLDOWN` state field forever — it becomes routable again
|
|
97
|
+
* (`canRouteNow`) without ever flipping back to `HEALTHY`. The dock therefore
|
|
98
|
+
* must judge by time, not by the raw state field: only a channel that is
|
|
99
|
+
* *still* cooling (cooldown not yet expired) counts as an error.
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* Overall dock state:
|
|
103
|
+
* - `error` — at least one channel is still cooling (`cooldownUntilMs > now`).
|
|
104
|
+
* - `warning` — a probe is in flight (kept for parity; the adapter no longer
|
|
105
|
+
* enters PROBE, but persisted legacy states may surface it).
|
|
106
|
+
* - `done` — everything routable: healthy, or cooled down long enough.
|
|
107
|
+
* - `ongoing` — no snapshot yet.
|
|
108
|
+
*/
|
|
109
|
+
function overallState(channels, nowMs) {
|
|
110
|
+
if (channels === null) return "ongoing";
|
|
111
|
+
if (channels.some((c) => c.state === "COOLDOWN" && c.cooldownUntilMs > nowMs)) return "error";
|
|
112
|
+
if (channels.some((c) => c.state === "PROBE")) return "warning";
|
|
113
|
+
return "done";
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
91
116
|
//#region lib/client/BackupPanel.js
|
|
92
117
|
/**
|
|
93
118
|
* BackupChannelPanel: list candidate models for a provider and pick one as
|
|
@@ -376,13 +401,6 @@ window.__ModuleLoader__.load({
|
|
|
376
401
|
textOverflow: "ellipsis",
|
|
377
402
|
whiteSpace: "nowrap"
|
|
378
403
|
};
|
|
379
|
-
/** Overall health: any cooling channel → error, any probe → warning, else done. */
|
|
380
|
-
function overallState(status) {
|
|
381
|
-
if (status === null) return "ongoing";
|
|
382
|
-
if (status.channels.some((c) => c.state === "COOLDOWN")) return "error";
|
|
383
|
-
if (status.channels.some((c) => c.state === "PROBE")) return "warning";
|
|
384
|
-
return "done";
|
|
385
|
-
}
|
|
386
404
|
const iconColor = {
|
|
387
405
|
done: "var(--dsw-text-success, #30a46c)",
|
|
388
406
|
warning: "var(--dsw-text-warning, #f5a524)",
|
|
@@ -422,7 +440,7 @@ window.__ModuleLoader__.load({
|
|
|
422
440
|
title: t("backupManageHint"),
|
|
423
441
|
onClick: () => setPanelOpen(true),
|
|
424
442
|
style: controlStyle,
|
|
425
|
-
children: [(0, react_jsx_runtime.jsx)(StatusIcon, { state: overallState(status) }), (0, react_jsx_runtime.jsxs)("span", {
|
|
443
|
+
children: [(0, react_jsx_runtime.jsx)(StatusIcon, { state: overallState(status?.channels ?? null, Date.now()) }), (0, react_jsx_runtime.jsxs)("span", {
|
|
426
444
|
style: {
|
|
427
445
|
minWidth: 0,
|
|
428
446
|
overflow: "hidden",
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["memo","_jsxs","_jsx","Pill","Button","useState","useMemo","useCallback","Modal","_Fragment","_jsx","IconCheckOutline16","IconWarningOutline16","useState","useCallback","_jsxs","_Fragment","Button","h"],"sources":["client/locales.js","client/api.js","client/BackupPanel.js","client/StatusDock.js","client/index.js"],"sourcesContent":["/** zh/en dictionaries for the daruma client UI. */\nexport const zh = {\n status: '渠道状态',\n current: '当前',\n backup: '备用',\n backupNone: '未设置',\n backupManage: '备用渠道',\n backupManageHint: '从候选列表选择备用渠道',\n failoverCount: '已切换',\n lastFailover: '上次切换',\n healthy: '健康',\n cooldown: '冷却中',\n probe: '探测中',\n refresh: '刷新',\n close: '关闭',\n clearBackup: '清除备用',\n provider: '提供方',\n providerPlaceholder: 'provider,如 mt',\n loadCandidates: '加载候选',\n loading: '加载中…',\n candidates: '候选模型',\n setBackup: '设为备用',\n currentBackup: '当前备用',\n currentBackupMark: '备用',\n noCandidates: '未加载到候选模型',\n empty: '暂无渠道数据',\n};\nexport const en = {\n status: 'Channel status',\n current: 'Current',\n backup: 'Backup',\n backupNone: 'none',\n backupManage: 'Backup channel',\n backupManageHint: 'Pick a backup channel from the candidate list',\n failoverCount: 'failovers',\n lastFailover: 'last failover',\n healthy: 'healthy',\n cooldown: 'cooling',\n probe: 'probing',\n refresh: 'Refresh',\n close: 'Close',\n clearBackup: 'Clear backup',\n provider: 'Provider',\n providerPlaceholder: 'provider, e.g. mt',\n loadCandidates: 'Load candidates',\n loading: 'Loading…',\n candidates: 'Candidate models',\n setBackup: 'Set as backup',\n currentBackup: 'Current backup',\n currentBackupMark: 'backup',\n noCandidates: 'No candidates loaded',\n empty: 'No channel data yet',\n};\n//# sourceMappingURL=locales.js.map","/**\n * Client-side wire types and RPC wrapper for the `/dsh-daruma` channel.\n * Structural types only — no monorepo-internal imports.\n */\nexport function createApi(rpc) {\n const call = async (endpoint, payload) => {\n const result = (await rpc(endpoint, payload));\n if (!result.ok) {\n throw new Error(result.error?.message ?? `daruma rpc ${endpoint} failed`);\n }\n return result.value;\n };\n return {\n status: () => call('status'),\n listCandidates: (provider) => call('listCandidates', { provider }),\n setBackup: async (provider, model) => {\n await call('setBackup', { provider, model });\n },\n clearBackup: async () => {\n await call('clearBackup');\n },\n };\n}\n//# sourceMappingURL=api.js.map","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\n/**\n * BackupChannelPanel: list candidate models for a provider and pick one as\n * the failover backup. Rendered inside a primitives Modal.\n *\n * No probing happens here anymore — the panel is a plain picker. Channel\n * health still updates from real traffic via the recovery engine.\n */\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport { Button, Modal, Pill, } from '@deepseek-ai/dsh-client-ui-primitives';\nfunction deriveProvider(status) {\n if (status === null)\n return '';\n if (status.current !== null)\n return status.current.split('::')[0] ?? '';\n if (status.backup !== null)\n return status.backup.provider;\n return status.providers[0] ?? '';\n}\nconst sectionStyle = {\n display: 'flex',\n flexDirection: 'column',\n gap: '8px',\n padding: '12px 0',\n fontSize: '13px',\n};\nconst rowStyle = {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n};\nconst noteStyle = { color: 'var(--dsw-text-tertiary, #999)', fontSize: '12px' };\n/** Clamp a long provider/model name so the row never wraps. */\nconst backupPillStyle = {\n flex: '1 1 auto',\n minWidth: 0,\n overflow: 'hidden',\n};\nconst ellipsisStyle = {\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n};\nconst listStyle = {\n maxHeight: 300,\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n gap: 4,\n contain: 'content',\n willChange: 'scroll-position',\n overscrollBehavior: 'contain',\n};\n/** Skip rendering rows outside the viewport while scrolling. */\nconst candidateRowStyle = {\n ...rowStyle,\n contentVisibility: 'auto',\n containIntrinsicSize: '28px',\n};\n/** One candidate row, memoized so selection changes only re-render it. */\nconst CandidateRow = memo(function CandidateRow(props) {\n const { candidate, isBackup, busy, t, onSetBackup } = props;\n return (_jsxs(\"div\", { style: candidateRowStyle, children: [_jsx(\"span\", { style: { width: 14, flexShrink: 0 } }), _jsx(\"span\", { style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: candidate.model }), isBackup && _jsx(Pill, { active: true, children: t('currentBackupMark') }), _jsx(Button, { size: \"sm\", variant: \"ghost\", disabled: isBackup || busy, onClick: () => onSetBackup(candidate.model), children: t('setBackup') })] }));\n});\nexport function BackupPanel(props) {\n const { api, t, status, onClose } = props;\n const [provider, setProvider] = useState(deriveProvider(status));\n const [candidates, setCandidates] = useState(null);\n const [loading, setLoading] = useState(false);\n const [busy, setBusy] = useState(null);\n const [error, setError] = useState(null);\n // Local overlay on the status-prop backup: applied optimistically after\n // set/clear so the row reflects the change without waiting for the parent\n // to re-fetch status. Cleared whenever a fresh status arrives.\n const [backupOverride, setBackupOverride] = useState(undefined);\n // The effective backup shown in the panel: local override → status prop.\n const backupShown = backupOverride !== undefined ? backupOverride : status?.backup ?? null;\n // O(1) lookup for the current backup model; re-built only when the effective backup changes.\n const backupModel = useMemo(() => (backupShown !== null && backupShown.provider === provider ? backupShown.model : null), [backupShown, provider]);\n const loadCandidates = async () => {\n if (provider === '')\n return;\n setLoading(true);\n setError(null);\n try {\n setCandidates(await api.listCandidates(provider));\n }\n catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause));\n }\n finally {\n setLoading(false);\n }\n };\n useEffect(() => {\n if (provider !== '')\n void loadCandidates();\n }, [provider]);\n // A fresh status from the parent supersedes the local override.\n useEffect(() => {\n setBackupOverride(undefined);\n }, [status]);\n const setBackup = async (model) => {\n setBusy(model);\n setError(null);\n try {\n await api.setBackup(provider, model);\n setBackupOverride({ provider, model });\n }\n catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause));\n }\n finally {\n setBusy(null);\n }\n };\n const clearBackup = async () => {\n setBusy('__clear__');\n setError(null);\n try {\n await api.clearBackup();\n setBackupOverride(null);\n }\n catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause));\n }\n finally {\n setBusy(null);\n }\n };\n // Stable callback so memoized CandidateRow props don't change every render.\n const handleSetBackup = useCallback((model) => void setBackup(model), [provider]);\n return (_jsx(Modal, { open: true, onClose: onClose, title: t('backupManage'), className: \"daruma-wide-dialog\", closeLabel: t('close'), description: t('backupManageHint'), footer: _jsx(Button, { variant: \"primary\", onClick: onClose, children: t('close') }), children: _jsxs(\"div\", { style: sectionStyle, children: [status !== null && status.failoverCount > 0 && (_jsxs(\"div\", { style: noteStyle, children: [t('failoverCount'), \": \", status.failoverCount, status.failoverHistory.length > 0 && (_jsxs(_Fragment, { children: [' · ', t('lastFailover'), \": \", status.failoverHistory.map((h) => `${h.from} → ${h.to}`).join(' · ')] }))] })), backupShown !== null && (_jsxs(\"div\", { style: rowStyle, children: [_jsxs(\"span\", { style: { flexShrink: 0 }, children: [t('currentBackup'), \":\"] }), _jsx(Pill, { active: true, style: backupPillStyle, title: `${backupShown.provider}/${backupShown.model}`, children: _jsxs(\"span\", { style: ellipsisStyle, children: [backupShown.provider, \"/\", backupShown.model] }) }), _jsx(Button, { size: \"sm\", variant: \"ghost\", style: { flexShrink: 0 }, disabled: busy !== null, onClick: () => void clearBackup(), children: t('clearBackup') })] })), _jsxs(\"div\", { style: rowStyle, children: [(status?.providers ?? []).length > 0 ? (_jsx(\"select\", { value: provider, disabled: loading, onChange: (event) => setProvider(event.currentTarget.value), style: { flex: 1, padding: '4px 8px', fontSize: 13 }, children: status?.providers.map((name) => (_jsx(\"option\", { value: name, children: name }, name))) })) : (_jsx(\"input\", { value: provider, placeholder: t('providerPlaceholder'), onChange: (event) => setProvider(event.currentTarget.value), style: { flex: 1, padding: '4px 8px', fontSize: 13 } })), _jsx(Button, { size: \"sm\", variant: \"outline\", onClick: () => void loadCandidates(), disabled: provider === '' || loading, children: loading ? t('loading') : t('loadCandidates') })] }), error !== null && _jsx(\"div\", { style: { color: 'var(--dsw-text-danger, #e5484d)' }, children: error }), candidates !== null && (_jsxs(_Fragment, { children: [_jsx(\"div\", { style: rowStyle, children: _jsxs(\"span\", { children: [t('candidates'), \" (\", candidates.length, \")\"] }) }), candidates.length === 0 && _jsx(\"div\", { style: noteStyle, children: t('noCandidates') }), _jsx(\"div\", { style: listStyle, children: candidates.map((candidate) => (_jsx(CandidateRow, { candidate: candidate, isBackup: candidate.model === backupModel, busy: busy !== null, t: t, onSetBackup: handleSetBackup }, candidate.model))) })] }))] }) }));\n}\n//# sourceMappingURL=BackupPanel.js.map","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\n/**\n * DarumaStatus: a compact control at the right end of the composer tool row,\n * next to the model selector. Shows overall channel health and the backup\n * selection; clicking it opens the backup-channel panel.\n */\nimport { useCallback, useEffect, useState } from 'react';\nimport { Button, IconCheckOutline16, IconWarningOutline16 } from '@deepseek-ai/dsh-client-ui-primitives';\nimport { BackupPanel } from \"./BackupPanel.js\";\nconst controlStyle = {\n display: 'inline-flex',\n alignItems: 'center',\n gap: 6,\n maxWidth: 220,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n};\n/** Overall health: any cooling channel → error, any probe → warning, else done. */\nfunction overallState(status) {\n if (status === null)\n return 'ongoing';\n if (status.channels.some((c) => c.state === 'COOLDOWN'))\n return 'error';\n if (status.channels.some((c) => c.state === 'PROBE'))\n return 'warning';\n return 'done';\n}\nconst iconColor = {\n done: 'var(--dsw-text-success, #30a46c)',\n warning: 'var(--dsw-text-warning, #f5a524)',\n error: 'var(--dsw-text-danger, #e5484d)',\n ongoing: 'var(--dsw-text-secondary, #888)',\n};\n/** Status glyph: a check when healthy, a warning otherwise. */\nfunction StatusIcon(props) {\n return (_jsx(\"span\", { style: { display: 'inline-flex', color: iconColor[props.state], flexShrink: 0 }, children: props.state === 'done'\n ? _jsx(IconCheckOutline16, { size: 14 })\n : _jsx(IconWarningOutline16, { size: 14 }) }));\n}\nexport function StatusDock(props) {\n const [status, setStatus] = useState(null);\n const [panelOpen, setPanelOpen] = useState(false);\n const load = useCallback(async () => {\n try {\n const value = await props.api.status();\n setStatus(value);\n }\n catch {\n // keep last good snapshot; the control stays quiet on RPC failure\n }\n }, [props.api]);\n useEffect(() => {\n void load();\n const timer = setInterval(() => void load(), 30_000);\n return () => clearInterval(timer);\n }, [load]);\n const t = props.t;\n const backupLabel = status?.backup !== null && status?.backup !== undefined\n ? `${status.backup.provider}/${status.backup.model}`\n : t('backupNone');\n return (_jsxs(_Fragment, { children: [_jsxs(Button, { size: \"sm\", variant: \"ghost\", title: t('backupManageHint'), onClick: () => setPanelOpen(true), style: controlStyle, children: [_jsx(StatusIcon, { state: overallState(status) }), _jsxs(\"span\", { style: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: [t('backup'), \": \", backupLabel] })] }), panelOpen && (_jsx(BackupPanel, { api: props.api, t: t, status: status, onClose: () => {\n setPanelOpen(false);\n void load();\n } }))] }));\n}\n//# sourceMappingURL=StatusDock.js.map","/**\n * dsh-daruma client: registers a compact channel-status dock above the\n * composer (conversation.input.dock) with a \"backup channel\" panel that\n * lists candidate models and picks a backup. Built by tsdown into the\n * __ModuleLoader__ factory bundle at lib/client.js.\n */\nimport { createElement as h } from 'react';\nimport { en, zh } from \"./locales.js\";\nimport { createApi } from \"./api.js\";\nimport { StatusDock } from \"./StatusDock.js\";\nconst NS = 'daruma';\nexport const name = 'dsh-daruma';\nexport const inject = ['slots', 'locale'];\nexport function apply(ctx) {\n // Widen the backup-panel dialog: the primitives Modal card is fixed at\n // min(380px, 100%), which truncates long provider/model names. A global\n // class (not a CSS module) outranks the module-scoped `.dialog` rule.\n if (typeof document !== 'undefined') {\n const tagId = 'daruma-panel-style';\n if (document.querySelector(`style[data-daruma=\"${tagId}\"]`) === null) {\n const style = document.createElement('style');\n style.dataset.daruma = tagId;\n style.textContent = '.daruma-wide-dialog.daruma-wide-dialog { width: min(560px, 100%); }';\n document.head.appendChild(style);\n }\n }\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-daruma: dictionaries');\n const t = ctx.locale.bind(NS);\n const connection = ctx.get('connection');\n if (connection === undefined) {\n console.warn('[dsh-daruma] web transport unavailable — client UI disabled');\n return;\n }\n const rpc = (endpoint, payload) => connection.rpc.call('/dsh-daruma', endpoint, payload ?? {});\n const api = createApi(rpc);\n ctx.slots.inject('conversation.input.right', () => ctx.slots.register({\n name: 'conversation.input.right',\n id: 'daruma-status',\n order: 0,\n inject: () => ({ api, t }),\n }, () => h(StatusDock, { api, t })));\n}\n//# sourceMappingURL=index.js.map"],"mappings":";;;;;;;;;;;EACA,MAAa,KAAK;GACd,QAAQ;GACR,SAAS;GACT,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,kBAAkB;GAClB,eAAe;GACf,cAAc;GACd,SAAS;GACT,UAAU;GACV,OAAO;GACP,SAAS;GACT,OAAO;GACP,aAAa;GACb,UAAU;GACV,qBAAqB;GACrB,gBAAgB;GAChB,SAAS;GACT,YAAY;GACZ,WAAW;GACX,eAAe;GACf,mBAAmB;GACnB,cAAc;GACd,OAAO;EACX;EACA,MAAa,KAAK;GACd,QAAQ;GACR,SAAS;GACT,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,kBAAkB;GAClB,eAAe;GACf,cAAc;GACd,SAAS;GACT,UAAU;GACV,OAAO;GACP,SAAS;GACT,OAAO;GACP,aAAa;GACb,UAAU;GACV,qBAAqB;GACrB,gBAAgB;GAChB,SAAS;GACT,YAAY;GACZ,WAAW;GACX,eAAe;GACf,mBAAmB;GACnB,cAAc;GACd,OAAO;EACX;;;;;;;EChDA,SAAgB,UAAU,KAAK;GAC3B,MAAM,OAAO,OAAO,UAAU,YAAY;IACtC,MAAM,SAAU,MAAM,IAAI,UAAU,OAAO;IAC3C,IAAI,CAAC,OAAO,IACR,MAAM,IAAI,MAAM,OAAO,OAAO,WAAW,cAAc,SAAS,QAAQ;IAE5E,OAAO,OAAO;GAClB;GACA,OAAO;IACH,cAAc,KAAK,QAAQ;IAC3B,iBAAiB,aAAa,KAAK,kBAAkB,EAAE,SAAS,CAAC;IACjE,WAAW,OAAO,UAAU,UAAU;KAClC,MAAM,KAAK,aAAa;MAAE;MAAU;KAAM,CAAC;IAC/C;IACA,aAAa,YAAY;KACrB,MAAM,KAAK,aAAa;IAC5B;GACJ;EACJ;;;;;;;;;;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e,KAAA,GAAW;IAC1B,QAAQ,KAAK,6DAA6D;IAC1E;GACJ;GACA,MAAM,OAAO,UAAU,YAAY,WAAW,IAAI,KAAK,eAAe,UAAU,WAAW,CAAC,CAAC;GAC7F,MAAM,MAAM,UAAU,GAAG;GACzB,IAAI,MAAM,OAAO,kCAAkC,IAAI,MAAM,SAAS;IAClE,MAAM;IACN,IAAI;IACJ,OAAO;IACP,eAAe;KAAE;KAAK;IAAE;GAC5B,UAAA,GAASQ,MAAAA,cAAAA,CAAE,YAAY;IAAE;IAAK;GAAE,CAAC,CAAC,CAAC;EACvC"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["memo","_jsxs","_jsx","Pill","Button","useState","useMemo","useCallback","Modal","_Fragment","_jsx","IconCheckOutline16","IconWarningOutline16","useState","useCallback","_jsxs","_Fragment","Button","h"],"sources":["client/locales.js","client/api.js","client/health.js","client/BackupPanel.js","client/StatusDock.js","client/index.js"],"sourcesContent":["/** zh/en dictionaries for the daruma client UI. */\nexport const zh = {\n status: '渠道状态',\n current: '当前',\n backup: '备用',\n backupNone: '未设置',\n backupManage: '备用渠道',\n backupManageHint: '从候选列表选择备用渠道',\n failoverCount: '已切换',\n lastFailover: '上次切换',\n healthy: '健康',\n cooldown: '冷却中',\n probe: '探测中',\n refresh: '刷新',\n close: '关闭',\n clearBackup: '清除备用',\n provider: '提供方',\n providerPlaceholder: 'provider,如 mt',\n loadCandidates: '加载候选',\n loading: '加载中…',\n candidates: '候选模型',\n setBackup: '设为备用',\n currentBackup: '当前备用',\n currentBackupMark: '备用',\n noCandidates: '未加载到候选模型',\n empty: '暂无渠道数据',\n};\nexport const en = {\n status: 'Channel status',\n current: 'Current',\n backup: 'Backup',\n backupNone: 'none',\n backupManage: 'Backup channel',\n backupManageHint: 'Pick a backup channel from the candidate list',\n failoverCount: 'failovers',\n lastFailover: 'last failover',\n healthy: 'healthy',\n cooldown: 'cooling',\n probe: 'probing',\n refresh: 'Refresh',\n close: 'Close',\n clearBackup: 'Clear backup',\n provider: 'Provider',\n providerPlaceholder: 'provider, e.g. mt',\n loadCandidates: 'Load candidates',\n loading: 'Loading…',\n candidates: 'Candidate models',\n setBackup: 'Set as backup',\n currentBackup: 'Current backup',\n currentBackupMark: 'backup',\n noCandidates: 'No candidates loaded',\n empty: 'No channel data yet',\n};\n//# sourceMappingURL=locales.js.map","/**\n * Client-side wire types and RPC wrapper for the `/dsh-daruma` channel.\n * Structural types only — no monorepo-internal imports.\n */\nexport function createApi(rpc) {\n const call = async (endpoint, payload) => {\n const result = (await rpc(endpoint, payload));\n if (!result.ok) {\n throw new Error(result.error?.message ?? `daruma rpc ${endpoint} failed`);\n }\n return result.value;\n };\n return {\n status: () => call('status'),\n listCandidates: (provider) => call('listCandidates', { provider }),\n setBackup: async (provider, model) => {\n await call('setBackup', { provider, model });\n },\n clearBackup: async () => {\n await call('clearBackup');\n },\n };\n}\n//# sourceMappingURL=api.js.map","/**\n * Time-aware channel-health classification for the status dock.\n *\n * The host exposes no request-success event, so a channel whose cooldown has\n * expired keeps its `COOLDOWN` state field forever — it becomes routable again\n * (`canRouteNow`) without ever flipping back to `HEALTHY`. The dock therefore\n * must judge by time, not by the raw state field: only a channel that is\n * *still* cooling (cooldown not yet expired) counts as an error.\n */\n/**\n * Overall dock state:\n * - `error` — at least one channel is still cooling (`cooldownUntilMs > now`).\n * - `warning` — a probe is in flight (kept for parity; the adapter no longer\n * enters PROBE, but persisted legacy states may surface it).\n * - `done` — everything routable: healthy, or cooled down long enough.\n * - `ongoing` — no snapshot yet.\n */\nexport function overallState(channels, nowMs) {\n if (channels === null)\n return 'ongoing';\n if (channels.some((c) => c.state === 'COOLDOWN' && c.cooldownUntilMs > nowMs))\n return 'error';\n if (channels.some((c) => c.state === 'PROBE'))\n return 'warning';\n return 'done';\n}\n//# sourceMappingURL=health.js.map","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\n/**\n * BackupChannelPanel: list candidate models for a provider and pick one as\n * the failover backup. Rendered inside a primitives Modal.\n *\n * No probing happens here anymore — the panel is a plain picker. Channel\n * health still updates from real traffic via the recovery engine.\n */\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport { Button, Modal, Pill, } from '@deepseek-ai/dsh-client-ui-primitives';\nfunction deriveProvider(status) {\n if (status === null)\n return '';\n if (status.current !== null)\n return status.current.split('::')[0] ?? '';\n if (status.backup !== null)\n return status.backup.provider;\n return status.providers[0] ?? '';\n}\nconst sectionStyle = {\n display: 'flex',\n flexDirection: 'column',\n gap: '8px',\n padding: '12px 0',\n fontSize: '13px',\n};\nconst rowStyle = {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n};\nconst noteStyle = { color: 'var(--dsw-text-tertiary, #999)', fontSize: '12px' };\n/** Clamp a long provider/model name so the row never wraps. */\nconst backupPillStyle = {\n flex: '1 1 auto',\n minWidth: 0,\n overflow: 'hidden',\n};\nconst ellipsisStyle = {\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n};\nconst listStyle = {\n maxHeight: 300,\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n gap: 4,\n contain: 'content',\n willChange: 'scroll-position',\n overscrollBehavior: 'contain',\n};\n/** Skip rendering rows outside the viewport while scrolling. */\nconst candidateRowStyle = {\n ...rowStyle,\n contentVisibility: 'auto',\n containIntrinsicSize: '28px',\n};\n/** One candidate row, memoized so selection changes only re-render it. */\nconst CandidateRow = memo(function CandidateRow(props) {\n const { candidate, isBackup, busy, t, onSetBackup } = props;\n return (_jsxs(\"div\", { style: candidateRowStyle, children: [_jsx(\"span\", { style: { width: 14, flexShrink: 0 } }), _jsx(\"span\", { style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: candidate.model }), isBackup && _jsx(Pill, { active: true, children: t('currentBackupMark') }), _jsx(Button, { size: \"sm\", variant: \"ghost\", disabled: isBackup || busy, onClick: () => onSetBackup(candidate.model), children: t('setBackup') })] }));\n});\nexport function BackupPanel(props) {\n const { api, t, status, onClose } = props;\n const [provider, setProvider] = useState(deriveProvider(status));\n const [candidates, setCandidates] = useState(null);\n const [loading, setLoading] = useState(false);\n const [busy, setBusy] = useState(null);\n const [error, setError] = useState(null);\n // Local overlay on the status-prop backup: applied optimistically after\n // set/clear so the row reflects the change without waiting for the parent\n // to re-fetch status. Cleared whenever a fresh status arrives.\n const [backupOverride, setBackupOverride] = useState(undefined);\n // The effective backup shown in the panel: local override → status prop.\n const backupShown = backupOverride !== undefined ? backupOverride : status?.backup ?? null;\n // O(1) lookup for the current backup model; re-built only when the effective backup changes.\n const backupModel = useMemo(() => (backupShown !== null && backupShown.provider === provider ? backupShown.model : null), [backupShown, provider]);\n const loadCandidates = async () => {\n if (provider === '')\n return;\n setLoading(true);\n setError(null);\n try {\n setCandidates(await api.listCandidates(provider));\n }\n catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause));\n }\n finally {\n setLoading(false);\n }\n };\n useEffect(() => {\n if (provider !== '')\n void loadCandidates();\n }, [provider]);\n // A fresh status from the parent supersedes the local override.\n useEffect(() => {\n setBackupOverride(undefined);\n }, [status]);\n const setBackup = async (model) => {\n setBusy(model);\n setError(null);\n try {\n await api.setBackup(provider, model);\n setBackupOverride({ provider, model });\n }\n catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause));\n }\n finally {\n setBusy(null);\n }\n };\n const clearBackup = async () => {\n setBusy('__clear__');\n setError(null);\n try {\n await api.clearBackup();\n setBackupOverride(null);\n }\n catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause));\n }\n finally {\n setBusy(null);\n }\n };\n // Stable callback so memoized CandidateRow props don't change every render.\n const handleSetBackup = useCallback((model) => void setBackup(model), [provider]);\n return (_jsx(Modal, { open: true, onClose: onClose, title: t('backupManage'), className: \"daruma-wide-dialog\", closeLabel: t('close'), description: t('backupManageHint'), footer: _jsx(Button, { variant: \"primary\", onClick: onClose, children: t('close') }), children: _jsxs(\"div\", { style: sectionStyle, children: [status !== null && status.failoverCount > 0 && (_jsxs(\"div\", { style: noteStyle, children: [t('failoverCount'), \": \", status.failoverCount, status.failoverHistory.length > 0 && (_jsxs(_Fragment, { children: [' · ', t('lastFailover'), \": \", status.failoverHistory.map((h) => `${h.from} → ${h.to}`).join(' · ')] }))] })), backupShown !== null && (_jsxs(\"div\", { style: rowStyle, children: [_jsxs(\"span\", { style: { flexShrink: 0 }, children: [t('currentBackup'), \":\"] }), _jsx(Pill, { active: true, style: backupPillStyle, title: `${backupShown.provider}/${backupShown.model}`, children: _jsxs(\"span\", { style: ellipsisStyle, children: [backupShown.provider, \"/\", backupShown.model] }) }), _jsx(Button, { size: \"sm\", variant: \"ghost\", style: { flexShrink: 0 }, disabled: busy !== null, onClick: () => void clearBackup(), children: t('clearBackup') })] })), _jsxs(\"div\", { style: rowStyle, children: [(status?.providers ?? []).length > 0 ? (_jsx(\"select\", { value: provider, disabled: loading, onChange: (event) => setProvider(event.currentTarget.value), style: { flex: 1, padding: '4px 8px', fontSize: 13 }, children: status?.providers.map((name) => (_jsx(\"option\", { value: name, children: name }, name))) })) : (_jsx(\"input\", { value: provider, placeholder: t('providerPlaceholder'), onChange: (event) => setProvider(event.currentTarget.value), style: { flex: 1, padding: '4px 8px', fontSize: 13 } })), _jsx(Button, { size: \"sm\", variant: \"outline\", onClick: () => void loadCandidates(), disabled: provider === '' || loading, children: loading ? t('loading') : t('loadCandidates') })] }), error !== null && _jsx(\"div\", { style: { color: 'var(--dsw-text-danger, #e5484d)' }, children: error }), candidates !== null && (_jsxs(_Fragment, { children: [_jsx(\"div\", { style: rowStyle, children: _jsxs(\"span\", { children: [t('candidates'), \" (\", candidates.length, \")\"] }) }), candidates.length === 0 && _jsx(\"div\", { style: noteStyle, children: t('noCandidates') }), _jsx(\"div\", { style: listStyle, children: candidates.map((candidate) => (_jsx(CandidateRow, { candidate: candidate, isBackup: candidate.model === backupModel, busy: busy !== null, t: t, onSetBackup: handleSetBackup }, candidate.model))) })] }))] }) }));\n}\n//# sourceMappingURL=BackupPanel.js.map","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\n/**\n * DarumaStatus: a compact control at the right end of the composer tool row,\n * next to the model selector. Shows overall channel health and the backup\n * selection; clicking it opens the backup-channel panel.\n */\nimport { useCallback, useEffect, useState } from 'react';\nimport { Button, IconCheckOutline16, IconWarningOutline16 } from '@deepseek-ai/dsh-client-ui-primitives';\nimport { overallState } from \"./health.js\";\nimport { BackupPanel } from \"./BackupPanel.js\";\nconst controlStyle = {\n display: 'inline-flex',\n alignItems: 'center',\n gap: 6,\n maxWidth: 220,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n};\nconst iconColor = {\n done: 'var(--dsw-text-success, #30a46c)',\n warning: 'var(--dsw-text-warning, #f5a524)',\n error: 'var(--dsw-text-danger, #e5484d)',\n ongoing: 'var(--dsw-text-secondary, #888)',\n};\n/** Status glyph: a check when healthy, a warning otherwise. */\nfunction StatusIcon(props) {\n return (_jsx(\"span\", { style: { display: 'inline-flex', color: iconColor[props.state], flexShrink: 0 }, children: props.state === 'done'\n ? _jsx(IconCheckOutline16, { size: 14 })\n : _jsx(IconWarningOutline16, { size: 14 }) }));\n}\nexport function StatusDock(props) {\n const [status, setStatus] = useState(null);\n const [panelOpen, setPanelOpen] = useState(false);\n const load = useCallback(async () => {\n try {\n const value = await props.api.status();\n setStatus(value);\n }\n catch {\n // keep last good snapshot; the control stays quiet on RPC failure\n }\n }, [props.api]);\n useEffect(() => {\n void load();\n const timer = setInterval(() => void load(), 30_000);\n return () => clearInterval(timer);\n }, [load]);\n const t = props.t;\n const backupLabel = status?.backup !== null && status?.backup !== undefined\n ? `${status.backup.provider}/${status.backup.model}`\n : t('backupNone');\n return (_jsxs(_Fragment, { children: [_jsxs(Button, { size: \"sm\", variant: \"ghost\", title: t('backupManageHint'), onClick: () => setPanelOpen(true), style: controlStyle, children: [_jsx(StatusIcon, { state: overallState(status?.channels ?? null, Date.now()) }), _jsxs(\"span\", { style: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: [t('backup'), \": \", backupLabel] })] }), panelOpen && (_jsx(BackupPanel, { api: props.api, t: t, status: status, onClose: () => {\n setPanelOpen(false);\n void load();\n } }))] }));\n}\n//# sourceMappingURL=StatusDock.js.map","/**\n * dsh-daruma client: registers a compact channel-status dock above the\n * composer (conversation.input.dock) with a \"backup channel\" panel that\n * lists candidate models and picks a backup. Built by tsdown into the\n * __ModuleLoader__ factory bundle at lib/client.js.\n */\nimport { createElement as h } from 'react';\nimport { en, zh } from \"./locales.js\";\nimport { createApi } from \"./api.js\";\nimport { StatusDock } from \"./StatusDock.js\";\nconst NS = 'daruma';\nexport const name = 'dsh-daruma';\nexport const inject = ['slots', 'locale'];\nexport function apply(ctx) {\n // Widen the backup-panel dialog: the primitives Modal card is fixed at\n // min(380px, 100%), which truncates long provider/model names. A global\n // class (not a CSS module) outranks the module-scoped `.dialog` rule.\n if (typeof document !== 'undefined') {\n const tagId = 'daruma-panel-style';\n if (document.querySelector(`style[data-daruma=\"${tagId}\"]`) === null) {\n const style = document.createElement('style');\n style.dataset.daruma = tagId;\n style.textContent = '.daruma-wide-dialog.daruma-wide-dialog { width: min(560px, 100%); }';\n document.head.appendChild(style);\n }\n }\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-daruma: dictionaries');\n const t = ctx.locale.bind(NS);\n const connection = ctx.get('connection');\n if (connection === undefined) {\n console.warn('[dsh-daruma] web transport unavailable — client UI disabled');\n return;\n }\n const rpc = (endpoint, payload) => connection.rpc.call('/dsh-daruma', endpoint, payload ?? {});\n const api = createApi(rpc);\n ctx.slots.inject('conversation.input.right', () => ctx.slots.register({\n name: 'conversation.input.right',\n id: 'daruma-status',\n order: 0,\n inject: () => ({ api, t }),\n }, () => h(StatusDock, { api, t })));\n}\n//# sourceMappingURL=index.js.map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AAU,YAAY,WAAW,IAAI,KAAK,eAAe,UAAU,WAAW,CAAC,CAAC;GAC7F,MAAM,MAAM,UAAU,GAAG;GACzB,IAAI,MAAM,OAAO,kCAAkC,IAAI,MAAM,SAAS;IAClE,MAAM;IACN,IAAI;IACJ,OAAO;IACP,eAAe;KAAE;KAAK;IAAE;GAC5B,UAAA,GAASQ,MAAAA,cAAAA,CAAE,YAAY;IAAE;IAAK;GAAE,CAAC,CAAC,CAAC;EACvC"}
|
package/lib/engine.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface ChannelHealthView {
|
|
|
11
11
|
readonly channel: ChannelId;
|
|
12
12
|
readonly state: ChannelState;
|
|
13
13
|
readonly failures: number;
|
|
14
|
+
/** Epoch ms when the channel's cooldown ends; `0` when not cooling. */
|
|
15
|
+
readonly cooldownUntilMs: number;
|
|
14
16
|
}
|
|
15
17
|
export interface FailoverRecord {
|
|
16
18
|
readonly from: string;
|
|
@@ -34,6 +36,10 @@ export declare class RecoveryEngine {
|
|
|
34
36
|
onFailure(signal: FailureSignal, preferred?: Channel, scope?: string): RecoveryPlan;
|
|
35
37
|
/** Release per-agent/session counters when the host disposes the scope. */
|
|
36
38
|
clearScope(scope: string): void;
|
|
39
|
+
/** Scope's failover count so far (0 when never failed over). */
|
|
40
|
+
failoverCountFor(scope: string): number;
|
|
41
|
+
/** Per-scope give-up budget from config. */
|
|
42
|
+
get giveUpBudget(): number;
|
|
37
43
|
/** Snapshot of every tracked channel's health, for the status UI. */
|
|
38
44
|
listHealth(): ChannelHealthView[];
|
|
39
45
|
get failoverCount(): number;
|
package/lib/engine.js
CHANGED
|
@@ -65,12 +65,21 @@ export class RecoveryEngine {
|
|
|
65
65
|
clearScope(scope) {
|
|
66
66
|
this.failoversByScope.delete(scope);
|
|
67
67
|
}
|
|
68
|
+
/** Scope's failover count so far (0 when never failed over). */
|
|
69
|
+
failoverCountFor(scope) {
|
|
70
|
+
return this.failoversByScope.get(scope) ?? 0;
|
|
71
|
+
}
|
|
72
|
+
/** Per-scope give-up budget from config. */
|
|
73
|
+
get giveUpBudget() {
|
|
74
|
+
return this.config.giveUpBudget;
|
|
75
|
+
}
|
|
68
76
|
/** Snapshot of every tracked channel's health, for the status UI. */
|
|
69
77
|
listHealth() {
|
|
70
78
|
return [...this.healths.values()].map((health) => ({
|
|
71
79
|
channel: health.channel,
|
|
72
80
|
state: health.state,
|
|
73
81
|
failures: health.consecutiveFailures,
|
|
82
|
+
cooldownUntilMs: health.cooldownUntilMs,
|
|
74
83
|
}));
|
|
75
84
|
}
|
|
76
85
|
get failoverCount() {
|
package/lib/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,MAAM,EACN,WAAW,GAUZ,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,GAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,MAAM,EACN,WAAW,GAUZ,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,GAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAA;AAiBtD,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEhC,MAAM,OAAO,cAAc;IAQN;IACA;IARF,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAA;IACtD,aAAa,GAAG,CAAC,CAAA;IACR,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC5C,eAAe,GAAqB,EAAE,CAAA;IACtC,KAAK,CAAO;IAE7B,YACmB,MAA4B,EAC5B,KAAyB,EAC1C,KAAa;QAFI,WAAM,GAAN,MAAM,CAAsB;QAC5B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C,mBAAmB;YACpC,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC,CAAC,CAAC,CAAA;IACL,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,6DAA6D;IAC7D,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAA;IAC7B,CAAC;IAED,+CAA+C;IAC/C,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,eAAe,CAAA;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable `daruma/failover` session-event assembly.
|
|
3
|
+
*
|
|
4
|
+
* Kept a pure, framework-free module so the event contract is unit-testable
|
|
5
|
+
* without mounting the host runtime. The event is appended to the agent's
|
|
6
|
+
* session log at failover-decision time and survives in the zstd session
|
|
7
|
+
* archive, giving every channel switch a traceable record (agent, turn, step,
|
|
8
|
+
* failure detail, and budget state at the moment of the decision).
|
|
9
|
+
*/
|
|
10
|
+
import type { LlmFailure } from '@deepseek-ai/dsh-llm';
|
|
11
|
+
/** Durable session event appended on every channel switch. */
|
|
12
|
+
export interface DarumaFailoverEvent {
|
|
13
|
+
/** Channel id the request failed on, e.g. `mt::glm-5.3`. */
|
|
14
|
+
readonly from: string;
|
|
15
|
+
/** Channel id recovery switched to. */
|
|
16
|
+
readonly to: string;
|
|
17
|
+
/** Stable failure code, e.g. `RATE_LIMIT`. */
|
|
18
|
+
readonly reason: string;
|
|
19
|
+
/** Epoch ms of the failover decision. */
|
|
20
|
+
readonly at: number;
|
|
21
|
+
/** Agent that triggered the failover (its scope id). */
|
|
22
|
+
readonly agentId: string;
|
|
23
|
+
/** Turn containing the failed request (1-based). */
|
|
24
|
+
readonly turn: number;
|
|
25
|
+
/** Step containing the failed request attempt (1-based). */
|
|
26
|
+
readonly step: number;
|
|
27
|
+
/** HTTP status of the failed request, when available. */
|
|
28
|
+
readonly status?: number;
|
|
29
|
+
/** Provider-issued request id, when available (opaque diagnostic token). */
|
|
30
|
+
readonly requestId?: string;
|
|
31
|
+
/** Human-readable failure detail, truncated for event size. */
|
|
32
|
+
readonly message?: string;
|
|
33
|
+
/** Scope failover count AFTER this decision (1-based on first failover). */
|
|
34
|
+
readonly failoverCount: number;
|
|
35
|
+
/** Scope give-up budget the count counts against. */
|
|
36
|
+
readonly giveUpBudget: number;
|
|
37
|
+
}
|
|
38
|
+
/** Cap on the failure-message detail stored in a session event. */
|
|
39
|
+
export declare const FAILOVER_MESSAGE_LIMIT = 300;
|
|
40
|
+
/** Event data required from the decision site. */
|
|
41
|
+
export interface FailoverEventInput {
|
|
42
|
+
readonly from: string;
|
|
43
|
+
readonly to: string;
|
|
44
|
+
readonly reason: string;
|
|
45
|
+
readonly at: number;
|
|
46
|
+
readonly agentId: string;
|
|
47
|
+
readonly turn: number;
|
|
48
|
+
readonly step: number;
|
|
49
|
+
readonly failure: Pick<LlmFailure, 'message'> & Partial<Pick<LlmFailure, 'status' | 'requestId'>>;
|
|
50
|
+
/** Scope failover count after the decision. */
|
|
51
|
+
readonly failoverCount: number;
|
|
52
|
+
/** Scope give-up budget. */
|
|
53
|
+
readonly giveUpBudget: number;
|
|
54
|
+
}
|
|
55
|
+
/** Assemble the durable failover event from decision-site facts. */
|
|
56
|
+
export declare function buildDarumaFailoverEvent(input: FailoverEventInput): DarumaFailoverEvent;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable `daruma/failover` session-event assembly.
|
|
3
|
+
*
|
|
4
|
+
* Kept a pure, framework-free module so the event contract is unit-testable
|
|
5
|
+
* without mounting the host runtime. The event is appended to the agent's
|
|
6
|
+
* session log at failover-decision time and survives in the zstd session
|
|
7
|
+
* archive, giving every channel switch a traceable record (agent, turn, step,
|
|
8
|
+
* failure detail, and budget state at the moment of the decision).
|
|
9
|
+
*/
|
|
10
|
+
/** Cap on the failure-message detail stored in a session event. */
|
|
11
|
+
export const FAILOVER_MESSAGE_LIMIT = 300;
|
|
12
|
+
function clip(value, limit) {
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
if (value.length <= limit)
|
|
16
|
+
return value;
|
|
17
|
+
return `${value.slice(0, limit)}…`;
|
|
18
|
+
}
|
|
19
|
+
/** Assemble the durable failover event from decision-site facts. */
|
|
20
|
+
export function buildDarumaFailoverEvent(input) {
|
|
21
|
+
const { failure } = input;
|
|
22
|
+
return {
|
|
23
|
+
from: input.from,
|
|
24
|
+
to: input.to,
|
|
25
|
+
reason: input.reason,
|
|
26
|
+
at: input.at,
|
|
27
|
+
agentId: input.agentId,
|
|
28
|
+
turn: input.turn,
|
|
29
|
+
step: input.step,
|
|
30
|
+
status: failure.status,
|
|
31
|
+
requestId: failure.requestId,
|
|
32
|
+
message: clip(failure.message, FAILOVER_MESSAGE_LIMIT),
|
|
33
|
+
failoverCount: input.failoverCount,
|
|
34
|
+
giveUpBudget: input.giveUpBudget,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=failover-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failover-events.js","sourceRoot":"","sources":["../src/failover-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgCH,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAkBzC,SAAS,IAAI,CAAC,KAAyB,EAAE,KAAa;IACpD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK;QAAE,OAAO,KAAK,CAAA;IACvC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAA;AACpC,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,wBAAwB,CAAC,KAAyB;IAChE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;IACzB,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,sBAAsB,CAAC;QACtD,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAA;AACH,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -18,15 +18,10 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import type { Context } from '@deepseek-ai/cordis';
|
|
20
20
|
import { type PluginConfig } from './config.ts';
|
|
21
|
+
import { type DarumaFailoverEvent } from './failover-events.ts';
|
|
21
22
|
export declare const name = "dsh-daruma";
|
|
22
23
|
export declare const inject: readonly ["agents", "settings", "llm"];
|
|
23
|
-
|
|
24
|
-
export interface DarumaFailoverEvent {
|
|
25
|
-
from: string;
|
|
26
|
-
to: string;
|
|
27
|
-
reason: string;
|
|
28
|
-
at: number;
|
|
29
|
-
}
|
|
24
|
+
export type { DarumaFailoverEvent };
|
|
30
25
|
declare module '@deepseek-ai/dsh-session/types' {
|
|
31
26
|
interface SessionEventMap {
|
|
32
27
|
'daruma/failover': DarumaFailoverEvent;
|
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { channelIdOf, channelIdOfConfig, toCallConfig, toFailureSignal } from ".
|
|
|
20
20
|
import { resolveConfig } from "./config.js";
|
|
21
21
|
import { RecoveryEngine } from "./engine.js";
|
|
22
22
|
import { JsonFileChannelHealthStore } from "./store.js";
|
|
23
|
+
import { buildDarumaFailoverEvent } from "./failover-events.js";
|
|
23
24
|
import { mountStatus } from "./status.js";
|
|
24
25
|
import { mountRpc } from "./rpc.js";
|
|
25
26
|
import { modelId } from 'daruma-core';
|
|
@@ -60,9 +61,20 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
60
61
|
const plan = engine.onFailure(signal, backupChannel(), payload.agent.id);
|
|
61
62
|
if (plan.verdict.kind === 'FAILOVER') {
|
|
62
63
|
pending.set(payload.agent.id, plan.verdict.target);
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const event = buildDarumaFailoverEvent({
|
|
65
|
+
from: channel,
|
|
66
|
+
to: plan.verdict.target.id,
|
|
67
|
+
reason: signal.code,
|
|
68
|
+
at: Date.now(),
|
|
69
|
+
agentId: payload.agent.id,
|
|
70
|
+
turn: payload.turn,
|
|
71
|
+
step: payload.step,
|
|
72
|
+
failure: payload.failure,
|
|
73
|
+
failoverCount: plan.failoverCount,
|
|
74
|
+
giveUpBudget: engine.giveUpBudget,
|
|
75
|
+
});
|
|
76
|
+
payload.agent.session.append('daruma/failover', event);
|
|
77
|
+
ctx.logger.warn(`dsh-daruma: failover ${channel} -> ${plan.verdict.target.id} (${signal.code}) agent=${payload.agent.id} turn=${payload.turn} step=${payload.step}`);
|
|
66
78
|
return { kind: 'retry' };
|
|
67
79
|
}
|
|
68
80
|
if (plan.verdict.kind === 'GIVE_UP') {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC5F,OAAO,EAAE,aAAa,EAAqB,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM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ruma",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Daruma resilience plugin for DeepSeek Harness — detects model-request failures and fails over to another channel to keep long tasks alive.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|