dsh-keys-manager 0.0.0 → 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 +164 -16
- package/README.zh-CN.md +114 -0
- package/bundle/cordis.patch.yml +5 -0
- package/icon.svg +12 -0
- package/lib/client/format.d.ts +8 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/locales.d.ts +4 -0
- package/lib/client/runtime.d.ts +21 -0
- package/lib/client/store.d.ts +4 -0
- package/lib/client/styles.d.ts +2 -0
- package/lib/client/types.d.ts +87 -0
- package/lib/client/ui.d.ts +18 -0
- package/lib/client.js +1594 -0
- package/lib/core.d.ts +71 -0
- package/lib/core.js +238 -0
- package/lib/core.js.map +1 -0
- package/lib/domain.d.ts +171 -0
- package/lib/domain.js +9 -0
- package/lib/domain.js.map +1 -0
- package/lib/host-types.d.ts +178 -0
- package/lib/host-types.js +2 -0
- package/lib/host-types.js.map +1 -0
- package/lib/index.d.ts +181 -0
- package/lib/index.js +1782 -0
- package/lib/index.js.map +1 -0
- package/lib/providers.d.ts +28 -0
- package/lib/providers.js +1308 -0
- package/lib/providers.js.map +1 -0
- package/lib/store.d.ts +62 -0
- package/lib/store.js +398 -0
- package/lib/store.js.map +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +79 -14
- package/scripts/build-client.mjs +53 -0
- package/scripts/prepare-release.mjs +243 -0
- package/scripts/verify-dist.mjs +30 -0
- package/index.js +0 -30
package/lib/client.js
ADDED
|
@@ -0,0 +1,1594 @@
|
|
|
1
|
+
/* Keys Manager Client bundle; generated by scripts/build-client.mjs. */
|
|
2
|
+
window.__ModuleLoader__.load({ id: "dsh-keys-manager", factory: (require) => {
|
|
3
|
+
var module = { exports: {} }; var exports = module.exports;
|
|
4
|
+
"use strict";
|
|
5
|
+
var __create = Object.create;
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/client/index.ts
|
|
34
|
+
var index_exports = {};
|
|
35
|
+
__export(index_exports, {
|
|
36
|
+
apply: () => apply,
|
|
37
|
+
inject: () => inject
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(index_exports);
|
|
40
|
+
|
|
41
|
+
// src/client/locales.ts
|
|
42
|
+
var zh = {
|
|
43
|
+
nav: "\u5BC6\u94A5\u7BA1\u7406",
|
|
44
|
+
title: "\u5BC6\u94A5\u7BA1\u7406",
|
|
45
|
+
subtitle: "\u4E3A\u540C\u4E00\u4E2A Provider \u914D\u7F6E\u591A\u4E2A API Key\u3002\u5355\u4F1A\u8BDD\u56FA\u5B9A\u4F7F\u7528\u4E00\u4E2A Key\uFF0C\u65B0\u4F1A\u8BDD\u8F6E\u6362\uFF1B\u5931\u8D25\u540E\u81EA\u52A8\u51B7\u5374\u5E76\u6062\u590D\u3002",
|
|
46
|
+
search: "\u641C\u7D22 Provider\uFF08\u540D\u79F0\u3001ID \u6216\u73AF\u5883\u53D8\u91CF\uFF09",
|
|
47
|
+
managed: "\u5DF2\u63A5\u7BA1",
|
|
48
|
+
available: "\u53EF\u6DFB\u52A0 Providers",
|
|
49
|
+
managedEmpty: "\u8FD8\u6CA1\u6709\u63A5\u7BA1\u7684 Provider\u3002\u4ECE\u4E0B\u65B9\u9009\u62E9\u4E00\u4E2A\u5F00\u59CB\u3002",
|
|
50
|
+
availableEmpty: "\u6CA1\u6709\u5339\u914D\u7684 Provider\u3002",
|
|
51
|
+
keys: "\u5BC6\u94A5",
|
|
52
|
+
healthy: "\u53EF\u7528",
|
|
53
|
+
cooling: "\u51B7\u5374\u4E2D",
|
|
54
|
+
paused: "\u5DF2\u6682\u505C",
|
|
55
|
+
missing: "\u51ED\u8BC1\u7F3A\u5931",
|
|
56
|
+
active: "\u6B63\u5E38",
|
|
57
|
+
unmanaged: "\u672A\u63A5\u7BA1",
|
|
58
|
+
dshBuiltin: "DSH \u5185\u7F6E",
|
|
59
|
+
pluginBuiltin: "\u63D2\u4EF6\u5185\u7F6E",
|
|
60
|
+
customProvider: "\u81EA\u5B9A\u4E49",
|
|
61
|
+
configured: "\u5DF2\u914D\u7F6E",
|
|
62
|
+
notConfigured: "\u672A\u914D\u7F6E",
|
|
63
|
+
adopt: "\u63A5\u7BA1 Provider",
|
|
64
|
+
adopting: "\u63A5\u7BA1\u4E2D\u2026",
|
|
65
|
+
release: "\u505C\u6B62\u63A5\u7BA1",
|
|
66
|
+
releasing: "\u6B63\u5728\u91CA\u653E\u2026",
|
|
67
|
+
addKey: "\u6DFB\u52A0\u5BC6\u94A5",
|
|
68
|
+
addKeyTitle: "\u6DFB\u52A0 API Key",
|
|
69
|
+
alias: "\u522B\u540D",
|
|
70
|
+
aliasPlaceholder: "\u4F8B\u5982\uFF1A\u4E3B\u7528\u3001\u5907\u7528\u3001Team B",
|
|
71
|
+
secret: "API Key",
|
|
72
|
+
secretPlaceholder: "\u7C98\u8D34 Key\uFF1B\u5B83\u5C06\u4FDD\u5B58\u5728\u51ED\u8BC1\u5E93\u4E2D",
|
|
73
|
+
addKeyHint: "Key \u4F1A\u4FDD\u5B58\u5728 DSH \u51ED\u8BC1\u5E93\u4E2D\uFF0C\u4E4B\u540E\u4E0D\u4F1A\u518D\u663E\u793A\u660E\u6587\u3002",
|
|
74
|
+
show: "\u663E\u793A",
|
|
75
|
+
hide: "\u9690\u85CF",
|
|
76
|
+
save: "\u4FDD\u5B58",
|
|
77
|
+
saving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
78
|
+
cancel: "\u53D6\u6D88",
|
|
79
|
+
rename: "\u6539\u522B\u540D",
|
|
80
|
+
pause: "\u6682\u505C",
|
|
81
|
+
resume: "\u6062\u590D",
|
|
82
|
+
delete: "\u5220\u9664",
|
|
83
|
+
deleting: "\u5220\u9664\u4E2D\u2026",
|
|
84
|
+
deleteTitle: "\u5220\u9664\u5BC6\u94A5\u201C{alias}\u201D\uFF1F",
|
|
85
|
+
deleteBody: "\u5220\u9664\u540E\u8BE5 Key \u4F1A\u4ECE\u51ED\u8BC1\u5E93\u79FB\u9664\u3002\u5982\u679C\u8FD9\u662F\u6700\u540E\u4E00\u4E2A Key\uFF0C\u8BE5 Provider \u5C06\u505C\u6B62\u63A5\u7BA1\u5E76\u6062\u590D\u539F\u6765\u7684 Key \u5F15\u7528\u3002",
|
|
86
|
+
deleteConfirm: "\u5220\u9664\u5BC6\u94A5",
|
|
87
|
+
releaseTitle: "\u505C\u6B62\u63A5\u7BA1\u201C{provider}\u201D\uFF1F",
|
|
88
|
+
releaseBody: "\u63D2\u4EF6\u4F1A\u6062\u590D\u8BE5 Provider \u539F\u6765\u7684 Key \u5F15\u7528\uFF0C\u5E76\u4ECE\u51ED\u8BC1\u5E93\u79FB\u9664\u6240\u6709\u6258\u7BA1 Key\u3002Provider \u914D\u7F6E\u4ECD\u4FDD\u7559\u5728\u6A21\u578B\u8BBE\u7F6E\u4E2D\u3002",
|
|
89
|
+
releaseBodyCreated: "\u63D2\u4EF6\u4F1A\u79FB\u9664\u5B83\u521B\u5EFA\u7684 Provider \u8DEF\u7531\uFF08\u5305\u62EC\u4E4B\u540E\u5728 Models \u4E2D\u505A\u7684\u4FEE\u6539\uFF09\uFF0C\u5E76\u4ECE\u51ED\u8BC1\u5E93\u79FB\u9664\u6240\u6709\u6258\u7BA1 Key\u3002",
|
|
90
|
+
releaseConfirm: "\u505C\u6B62\u63A5\u7BA1",
|
|
91
|
+
lastUsed: "\u6700\u540E\u4F7F\u7528",
|
|
92
|
+
never: "\u4ECE\u672A\u4F7F\u7528",
|
|
93
|
+
coolingUntil: "{time} \u6062\u590D",
|
|
94
|
+
remaining: "\u5269\u4F59 {time}",
|
|
95
|
+
imported: "\u5DF2\u5BFC\u5165",
|
|
96
|
+
uses: "\u4F7F\u7528 {n} \u6B21",
|
|
97
|
+
failures: "\u5931\u8D25 {n} \u6B21",
|
|
98
|
+
adoptHint: "\u63A5\u7BA1\u540E\uFF0C\u8BE5 Provider \u7684 API Key \u5C06\u7531\u5BC6\u94A5\u7BA1\u7406\u5668\u7EDF\u4E00\u63D0\u4F9B\u3002\u5F53\u524D\u51ED\u8BC1\u4F1A\u5BFC\u5165\u4E3A\u7B2C\u4E00\u4E2A Key\uFF0C\u539F\u5F15\u7528\u4F1A\u4FDD\u7559\u4EE5\u4FBF\u505C\u6B62\u63A5\u7BA1\u65F6\u6062\u590D\u3002",
|
|
99
|
+
adoptExtraHint: "\u8FD9\u4E2A\u6269\u5C55 Provider \u5C1A\u672A\u914D\u7F6E\u3002\u6DFB\u52A0 Key \u540E\uFF0C\u63D2\u4EF6\u4F1A\u81EA\u52A8\u5B89\u88C5 llm-pi-ai \u8DEF\u7531\uFF0C\u5E76\u4F7F\u7528\u81EA\u52A8\u53D1\u73B0\u6216\u5185\u7F6E\u6A21\u578B\u5217\u8868\u3002",
|
|
100
|
+
unsupported: "\u6682\u4E0D\u652F\u6301\u5BC6\u94A5\u6C60",
|
|
101
|
+
bindingBroken: "Provider \u914D\u7F6E\u5DF2\u4E0D\u518D\u6307\u5411\u5BC6\u94A5\u7BA1\u7406\u5668\u3002\u8BF7\u5148\u505C\u6B62\u63A5\u7BA1\u518D\u91CD\u65B0\u63A5\u7BA1\uFF0C\u6216\u5728\u6A21\u578B\u8BBE\u7F6E\u4E2D\u4FEE\u590D\u8BE5 Provider\u3002",
|
|
102
|
+
noKeys: "\u8FD8\u6CA1\u6709\u5BC6\u94A5\u3002\u6DFB\u52A0\u4E00\u4E2A\u540E\u5373\u53EF\u4F7F\u7528\u8BE5 Provider\u3002",
|
|
103
|
+
warning: "\u6CE8\u610F",
|
|
104
|
+
settingsTitle: "\u7B56\u7565",
|
|
105
|
+
settingsIntro: "\u4EE5\u4E0B\u8BBE\u7F6E\u5BF9\u6240\u6709\u5DF2\u63A5\u7BA1\u7684 Provider \u751F\u6548\u3002",
|
|
106
|
+
retryCount: "\u5207\u6362 Key \u524D\u91CD\u8BD5\u6B21\u6570",
|
|
107
|
+
retryHint: "\u540C\u4E00\u4E2A Key \u6700\u591A\u91CD\u8BD5\u8FD9\u4E48\u591A\u6B21\uFF1B\u4E4B\u540E\u8BE5 Key \u8FDB\u5165\u5F02\u5E38\u72B6\u6001\uFF0C\u4F1A\u8BDD\u5207\u6362\u5230\u53E6\u4E00\u4E2A Key\u3002",
|
|
108
|
+
baseCooldown: "\u521D\u59CB\u51B7\u5374\uFF08\u5206\u949F\uFF09",
|
|
109
|
+
baseHint: "\u9996\u6B21\u5931\u8D25\u51B7\u5374\u8FD9\u4E48\u4E45\uFF1B\u6062\u590D\u540E\u77ED\u65F6\u95F4\u5185\u518D\u6B21\u5931\u8D25\u4F1A\u7FFB\u500D\u3002",
|
|
110
|
+
grace: "\u6062\u590D\u89C2\u5BDF\u671F\uFF08\u5206\u949F\uFF09",
|
|
111
|
+
graceHint: "\u5728\u6062\u590D\u540E\u7684\u8FD9\u4E2A\u65F6\u95F4\u7A97\u53E3\u5185\u518D\u6B21\u5931\u8D25\uFF0C\u4F1A\u63D0\u5347\u4E0B\u4E00\u6B21\u51B7\u5374\u3002",
|
|
112
|
+
cap: "\u51B7\u5374\u4E0A\u9650\u4E3A 7 \u5929\u3002",
|
|
113
|
+
strategy: "\u9009\u62E9\u7B56\u7565",
|
|
114
|
+
strategyBody: "\u6BCF\u4E2A\u4F1A\u8BDD\u56FA\u5B9A\u4E00\u4E2A Key\uFF1B\u65B0\u4F1A\u8BDD\u6309 Round Robin \u53D6\u4E0B\u4E00\u4E2A\u53EF\u7528 Key\u3002\u6682\u505C\u548C\u51B7\u5374\u4E2D\u7684 Key \u4F1A\u88AB\u8DF3\u8FC7\uFF1B\u51B7\u5374\u7ED3\u675F\u540E\u81EA\u52A8\u6062\u590D\u3002",
|
|
115
|
+
saveSettings: "\u4FDD\u5B58\u7B56\u7565",
|
|
116
|
+
savingSettings: "\u4FDD\u5B58\u4E2D\u2026",
|
|
117
|
+
saved: "\u5DF2\u4FDD\u5B58\u3002",
|
|
118
|
+
writableFalse: "\u5F53\u524D\u914D\u7F6E\u4E3A\u53EA\u8BFB\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u5BC6\u94A5\u53D8\u66F4\u3002",
|
|
119
|
+
reload: "\u91CD\u8BD5",
|
|
120
|
+
refresh: "\u5237\u65B0",
|
|
121
|
+
moreActions: "\u66F4\u591A\u64CD\u4F5C",
|
|
122
|
+
showAll: "\u663E\u793A\u5168\u90E8 {n} \u4E2A Providers",
|
|
123
|
+
showLess: "\u6536\u8D77",
|
|
124
|
+
dismiss: "\u5173\u95ED",
|
|
125
|
+
loading: "\u52A0\u8F7D\u4E2D\u2026",
|
|
126
|
+
loadError: "\u65E0\u6CD5\u52A0\u8F7D\u5BC6\u94A5\u7BA1\u7406\u5668\u3002",
|
|
127
|
+
actionError: "\u64CD\u4F5C\u5931\u8D25\u3002",
|
|
128
|
+
modelsBadge: "\u7531\u5BC6\u94A5\u7BA1\u7406\u5668\u63A5\u7BA1 \xB7 {n} \u4E2A\u5BC6\u94A5",
|
|
129
|
+
modelsHint: "\u5728\u63D2\u4EF6 \u2192 \u5BC6\u94A5\u7BA1\u7406\u4E2D\u7F16\u8F91\u5BC6\u94A5\u3002",
|
|
130
|
+
providerId: "Provider ID",
|
|
131
|
+
env: "\u73AF\u5883\u53D8\u91CF",
|
|
132
|
+
baseUrl: "\u7AEF\u70B9",
|
|
133
|
+
api: "\u534F\u8BAE",
|
|
134
|
+
models: "\u6A21\u578B",
|
|
135
|
+
keysSection: "\u5BC6\u94A5",
|
|
136
|
+
extraSection: "\u6269\u5C55 Providers",
|
|
137
|
+
noSearch: "\u6362\u4E2A\u5173\u952E\u8BCD\u8BD5\u8BD5\u3002",
|
|
138
|
+
managedBadge: "\u5DF2\u63A5\u7BA1",
|
|
139
|
+
timeJustNow: "\u521A\u521A",
|
|
140
|
+
timeMinutesAgo: "{n} \u5206\u949F\u524D",
|
|
141
|
+
timeHoursAgo: "{n} \u5C0F\u65F6\u524D",
|
|
142
|
+
timeDaysAgo: "{n} \u5929\u524D",
|
|
143
|
+
timeMinutes: "{n} \u5206\u949F",
|
|
144
|
+
timeHours: "{n} \u5C0F\u65F6",
|
|
145
|
+
timeDays: "{n} \u5929",
|
|
146
|
+
timeSeconds: "{n} \u79D2",
|
|
147
|
+
confirm: "\u786E\u8BA4",
|
|
148
|
+
close: "\u5173\u95ED",
|
|
149
|
+
keyStatusActive: "\u6B63\u5E38",
|
|
150
|
+
keyStatusCooling: "\u51B7\u5374\u4E2D",
|
|
151
|
+
keyStatusPaused: "\u5DF2\u6682\u505C",
|
|
152
|
+
keyStatusMissing: "\u51ED\u8BC1\u7F3A\u5931",
|
|
153
|
+
keyStatusUnmanaged: "\u672A\u63A5\u7BA1",
|
|
154
|
+
providerKeys: "{n} \u4E2A\u5BC6\u94A5",
|
|
155
|
+
providerKeyOne: "1 \u4E2A\u5BC6\u94A5",
|
|
156
|
+
countModels: "{n} \u4E2A\u6A21\u578B",
|
|
157
|
+
storageNote: "Key \u4FDD\u5B58\u5728 DSH \u51ED\u8BC1\u5E93\u4E2D\uFF1B\u5BC6\u94A5\u7BA1\u7406\u5668\u72B6\u6001\u4F4D\u4E8E $DSH_HOME/keys-manager/state.json\uFF0C\u4EC5\u542B\u975E\u654F\u611F\u5143\u6570\u636E\u3002",
|
|
158
|
+
providerAdopted: "\u5DF2\u63A5\u7BA1\u3002\u539F\u6709\u51ED\u8BC1\u5DF2\u5BFC\u5165\u4E3A\u7B2C\u4E00\u4E2A Key\u3002",
|
|
159
|
+
summaryText: "\u5DF2\u63A5\u7BA1 {providers} \u4E2A Provider\uFF0C\u5171 {keys} \u4E2A\u5BC6\u94A5 \xB7 \u5355\u4F1A\u8BDD\u56FA\u5B9A + Round Robin",
|
|
160
|
+
summaryEmpty: "\u5C1A\u672A\u63A5\u7BA1\u4EFB\u4F55 Provider\u3002\u5728\u63D2\u4EF6\u8BE6\u60C5\u4E2D\u641C\u7D22\u5E76\u63A5\u7BA1\u3002",
|
|
161
|
+
addExtra: "\u6DFB\u52A0\u5E76\u5B89\u88C5",
|
|
162
|
+
adding: "\u6B63\u5728\u6DFB\u52A0\u2026",
|
|
163
|
+
discoverHint: "\u4F1A\u81EA\u52A8\u5C1D\u8BD5\u83B7\u53D6\u6A21\u578B\u5217\u8868\uFF1B\u82E5\u7AEF\u70B9\u4E0D\u53EF\u8FBE\uFF0C\u5219\u4F7F\u7528\u5185\u7F6E\u6A21\u578B\u3002",
|
|
164
|
+
openModels: "\u6253\u5F00\u6A21\u578B\u8BBE\u7F6E",
|
|
165
|
+
searchResults: "{n} \u4E2A\u5339\u914D",
|
|
166
|
+
reset: "\u91CD\u7F6E",
|
|
167
|
+
attention: "\u9700\u8981\u5904\u7406"
|
|
168
|
+
};
|
|
169
|
+
var en = {
|
|
170
|
+
nav: "Keys Manager",
|
|
171
|
+
title: "Keys Manager",
|
|
172
|
+
subtitle: "Give one provider several API keys. A session keeps one key; new sessions rotate; failures cool down and recover automatically.",
|
|
173
|
+
search: "Search providers by name, id, or environment variable",
|
|
174
|
+
managed: "Managed",
|
|
175
|
+
available: "Available providers",
|
|
176
|
+
managedEmpty: "No managed providers yet. Adopt one below to start.",
|
|
177
|
+
availableEmpty: "No matching providers.",
|
|
178
|
+
keys: "keys",
|
|
179
|
+
healthy: "healthy",
|
|
180
|
+
cooling: "cooling",
|
|
181
|
+
paused: "paused",
|
|
182
|
+
missing: "missing",
|
|
183
|
+
active: "active",
|
|
184
|
+
unmanaged: "not managed",
|
|
185
|
+
dshBuiltin: "DSH built-in",
|
|
186
|
+
pluginBuiltin: "Plugin built-in",
|
|
187
|
+
customProvider: "Custom",
|
|
188
|
+
configured: "configured",
|
|
189
|
+
notConfigured: "not configured",
|
|
190
|
+
adopt: "Adopt provider",
|
|
191
|
+
adopting: "Adopting\u2026",
|
|
192
|
+
release: "Stop managing",
|
|
193
|
+
releasing: "Releasing\u2026",
|
|
194
|
+
addKey: "Add key",
|
|
195
|
+
addKeyTitle: "Add an API key",
|
|
196
|
+
alias: "Alias",
|
|
197
|
+
aliasPlaceholder: "e.g. Primary, Backup, Team B",
|
|
198
|
+
secret: "API key",
|
|
199
|
+
secretPlaceholder: "Paste the key; it is stored in the credential store",
|
|
200
|
+
addKeyHint: "The key is stored in the DSH credential store and is never shown again.",
|
|
201
|
+
show: "Show",
|
|
202
|
+
hide: "Hide",
|
|
203
|
+
save: "Save",
|
|
204
|
+
saving: "Saving\u2026",
|
|
205
|
+
cancel: "Cancel",
|
|
206
|
+
rename: "Rename",
|
|
207
|
+
pause: "Pause",
|
|
208
|
+
resume: "Resume",
|
|
209
|
+
delete: "Delete",
|
|
210
|
+
deleting: "Deleting\u2026",
|
|
211
|
+
deleteTitle: "Delete key \u201C{alias}\u201D?",
|
|
212
|
+
deleteBody: "This removes the stored key. If it is the last key, the provider stops being managed and its original key reference is restored.",
|
|
213
|
+
deleteConfirm: "Delete key",
|
|
214
|
+
releaseTitle: "Stop managing \u201C{provider}\u201D?",
|
|
215
|
+
releaseBody: "The plugin restores the provider\u2019s original key reference and removes every managed key from the credential store. The provider configuration stays in Models.",
|
|
216
|
+
releaseBodyCreated: "The plugin removes the provider route it created (including any later edits made in Models) and removes every managed key from the credential store.",
|
|
217
|
+
releaseConfirm: "Stop managing",
|
|
218
|
+
lastUsed: "Last used",
|
|
219
|
+
never: "Never",
|
|
220
|
+
coolingUntil: "Recovers {time}",
|
|
221
|
+
remaining: "{time} left",
|
|
222
|
+
imported: "Imported",
|
|
223
|
+
uses: "{n} uses",
|
|
224
|
+
failures: "{n} failures",
|
|
225
|
+
adoptHint: "Adopting turns this provider\u2019s API-key source over to Keys Manager. Its current credential is imported as the first key, and the original reference is kept for release.",
|
|
226
|
+
adoptExtraHint: "This extra provider is not configured yet. Add a key and the plugin installs an llm-pi-ai route with discovered or built-in models.",
|
|
227
|
+
unsupported: "Not available for key pools",
|
|
228
|
+
bindingBroken: "The provider profile no longer points at Keys Manager. Release and re-adopt it, or repair the provider in Models.",
|
|
229
|
+
noKeys: "No keys yet. Add one to make this provider usable.",
|
|
230
|
+
warning: "Warning",
|
|
231
|
+
settingsTitle: "Policy",
|
|
232
|
+
settingsIntro: "These values apply to every managed provider.",
|
|
233
|
+
retryCount: "Retries before switching key",
|
|
234
|
+
retryHint: "The same key is retried this many times; after that the key is marked abnormal and the session moves to another key.",
|
|
235
|
+
baseCooldown: "Initial cooldown (minutes)",
|
|
236
|
+
baseHint: "First failure cools a key for this long. Repeated failures shortly after recovery double it.",
|
|
237
|
+
grace: "Recovery grace (minutes)",
|
|
238
|
+
graceHint: "A failure within this window after recovery escalates the next cooldown.",
|
|
239
|
+
cap: "Cooldown is capped at 7 days.",
|
|
240
|
+
strategy: "Selection strategy",
|
|
241
|
+
strategyBody: "Each session pins one key. A new session takes the next healthy key in round-robin order. Paused and cooling keys are skipped; cooling keys become available again automatically.",
|
|
242
|
+
saveSettings: "Save policy",
|
|
243
|
+
savingSettings: "Saving\u2026",
|
|
244
|
+
saved: "Saved.",
|
|
245
|
+
writableFalse: "This profile is read-only. Key changes cannot be saved.",
|
|
246
|
+
reload: "Retry",
|
|
247
|
+
refresh: "Refresh",
|
|
248
|
+
moreActions: "More actions",
|
|
249
|
+
showAll: "Show all {n} providers",
|
|
250
|
+
showLess: "Show less",
|
|
251
|
+
dismiss: "Dismiss",
|
|
252
|
+
loading: "Loading\u2026",
|
|
253
|
+
loadError: "Could not load Keys Manager.",
|
|
254
|
+
actionError: "The operation failed.",
|
|
255
|
+
modelsBadge: "Managed by Keys Manager \xB7 {n} keys",
|
|
256
|
+
modelsHint: "Edit keys in Plugins \u2192 Keys Manager.",
|
|
257
|
+
providerId: "Provider ID",
|
|
258
|
+
env: "Env",
|
|
259
|
+
baseUrl: "Endpoint",
|
|
260
|
+
api: "Protocol",
|
|
261
|
+
models: "Models",
|
|
262
|
+
keysSection: "Keys",
|
|
263
|
+
extraSection: "Extra providers",
|
|
264
|
+
noSearch: "Try a different search.",
|
|
265
|
+
managedBadge: "Managed",
|
|
266
|
+
timeJustNow: "just now",
|
|
267
|
+
timeMinutesAgo: "{n} min ago",
|
|
268
|
+
timeHoursAgo: "{n} h ago",
|
|
269
|
+
timeDaysAgo: "{n} d ago",
|
|
270
|
+
timeMinutes: "{n} min",
|
|
271
|
+
timeHours: "{n} h",
|
|
272
|
+
timeDays: "{n} d",
|
|
273
|
+
timeSeconds: "{n} s",
|
|
274
|
+
confirm: "Confirm",
|
|
275
|
+
close: "Close",
|
|
276
|
+
keyStatusActive: "Active",
|
|
277
|
+
keyStatusCooling: "Cooling",
|
|
278
|
+
keyStatusPaused: "Paused",
|
|
279
|
+
keyStatusMissing: "Credential missing",
|
|
280
|
+
keyStatusUnmanaged: "Not managed",
|
|
281
|
+
providerKeys: "{n} keys",
|
|
282
|
+
providerKeyOne: "1 key",
|
|
283
|
+
countModels: "{n} models",
|
|
284
|
+
storageNote: "Keys live in the DSH credential store; manager state lives at $DSH_HOME/keys-manager/state.json and contains no secret values.",
|
|
285
|
+
providerAdopted: "Adopted. The existing credential was imported as the first key.",
|
|
286
|
+
summaryText: "{providers} managed providers \xB7 {keys} keys \xB7 sticky session + round robin",
|
|
287
|
+
summaryEmpty: "No providers managed yet. Search and adopt one in the plugin page.",
|
|
288
|
+
addExtra: "Add and install",
|
|
289
|
+
adding: "Adding\u2026",
|
|
290
|
+
discoverHint: "The plugin tries endpoint discovery first; if that fails it installs the built-in model list.",
|
|
291
|
+
openModels: "Open Models",
|
|
292
|
+
searchResults: "{n} matches",
|
|
293
|
+
reset: "Reset",
|
|
294
|
+
attention: "Needs attention"
|
|
295
|
+
};
|
|
296
|
+
var LOCALE_DICTS = { zh, en };
|
|
297
|
+
|
|
298
|
+
// src/client/runtime.ts
|
|
299
|
+
var import_react = __toESM(require("react"), 1);
|
|
300
|
+
|
|
301
|
+
// src/client/styles.ts
|
|
302
|
+
var CSS = `
|
|
303
|
+
.km-page{max-width:920px;margin:0 auto;padding:0 0 8px;color:var(--dsw-alias-label-primary);font-size:13.5px;line-height:1.5}
|
|
304
|
+
.km-embedded-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin:0 0 16px}
|
|
305
|
+
.km-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:0 0 16px;flex:1;min-width:0}
|
|
306
|
+
.km-embedded-head .km-summary{margin:0}
|
|
307
|
+
.km-embedded-actions{display:flex;gap:8px;flex-shrink:0;padding-top:2px}
|
|
308
|
+
.km-summary-line{color:var(--dsw-alias-label-secondary);font-size:12.5px;line-height:1.5}
|
|
309
|
+
.km-stat{display:flex;flex-direction:column;gap:2px;padding:11px 14px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}
|
|
310
|
+
.km-stat strong{font-size:19px;line-height:1.15;font-weight:650;font-variant-numeric:tabular-nums}
|
|
311
|
+
.km-stat span{color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
312
|
+
.km-search{position:relative;display:flex;align-items:center;margin:0 0 20px}
|
|
313
|
+
.km-search-icon{position:absolute;left:12px;color:var(--dsw-alias-label-secondary);pointer-events:none}
|
|
314
|
+
.km-search-input{width:100%;box-sizing:border-box;padding:10px 38px 10px 36px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;outline:none}
|
|
315
|
+
.km-search-input:focus{border-color:var(--dsw-alias-state-business-primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--dsw-alias-state-business-primary) 20%,transparent)}
|
|
316
|
+
.km-search-clear{position:absolute;right:8px;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer}
|
|
317
|
+
.km-search-clear:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}
|
|
318
|
+
.km-section{margin:0 0 22px}
|
|
319
|
+
.km-section-head{display:flex;align-items:baseline;gap:8px;margin:0 0 9px}
|
|
320
|
+
.km-section-title{font-size:14px;font-weight:650;margin:0;letter-spacing:.01em}
|
|
321
|
+
.km-section-count{font-size:12px;color:var(--dsw-alias-label-secondary)}
|
|
322
|
+
.km-provider-list{display:flex;flex-direction:column;gap:8px}
|
|
323
|
+
.km-show-more{display:flex;justify-content:center;padding:8px 0 0}
|
|
324
|
+
.km-card{border:1px solid var(--dsw-alias-border-l1);border-radius:12px;background:var(--dsw-alias-bg-layer-1);overflow:hidden}
|
|
325
|
+
.km-provider-managed{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 26%,var(--dsw-alias-border-l1))}
|
|
326
|
+
.km-provider-open{overflow:visible}
|
|
327
|
+
.km-provider-head{display:flex;align-items:center;gap:12px;width:100%;padding:12px 14px;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
|
|
328
|
+
.km-provider-head:hover{background:color-mix(in srgb,var(--dsw-alias-label-primary) 3%,transparent)}
|
|
329
|
+
.km-avatar{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;flex:0 0 32px;border-radius:9px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);font-weight:650;font-size:13px;color:var(--dsw-alias-label-secondary)}
|
|
330
|
+
.km-provider-main{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}
|
|
331
|
+
.km-provider-title-line{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0}
|
|
332
|
+
.km-provider-name{font-weight:650;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:360px}
|
|
333
|
+
.km-provider-meta{display:flex;align-items:center;gap:7px;flex-wrap:wrap;color:var(--dsw-alias-label-secondary);font-size:11.5px;min-width:0}
|
|
334
|
+
.km-provider-side{display:flex;align-items:center;gap:9px;flex-shrink:0}
|
|
335
|
+
.km-count{font-size:11.5px;color:var(--dsw-alias-label-secondary);white-space:nowrap}
|
|
336
|
+
.km-chevron{color:var(--dsw-alias-label-secondary);transition:transform .16s ease}
|
|
337
|
+
.km-chevron-open{transform:rotate(180deg)}
|
|
338
|
+
.km-provider-body{border-top:1px solid var(--dsw-alias-border-l1);padding:13px 14px 14px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-2) 40%,transparent)}
|
|
339
|
+
.km-adopt{display:flex;flex-direction:column;gap:12px}
|
|
340
|
+
.km-adopt-copy{display:flex;flex-direction:column;gap:5px;color:var(--dsw-alias-label-secondary);font-size:12.5px}
|
|
341
|
+
.km-adopt-title{color:var(--dsw-alias-label-primary);font-size:12.5px}
|
|
342
|
+
.km-adopt-actions{display:flex;gap:8px;align-items:center}
|
|
343
|
+
.km-meta-line{display:flex;gap:6px;align-items:baseline;flex-wrap:wrap;font-size:11.5px}
|
|
344
|
+
.km-managed-body{display:flex;flex-direction:column;gap:10px}
|
|
345
|
+
.km-managed-toolbar{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap}
|
|
346
|
+
.km-managed-summary{display:flex;flex-direction:column;gap:2px;min-width:0;font-size:11.5px}
|
|
347
|
+
.km-managed-actions{display:flex;gap:6px;align-items:center;flex-shrink:0}
|
|
348
|
+
.km-keys{display:flex;flex-direction:column;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-1);overflow:visible}
|
|
349
|
+
.km-key-row{position:relative;display:grid;grid-template-columns:minmax(0,1.35fr) minmax(150px,.8fr) minmax(150px,.9fr) 32px;gap:10px;align-items:center;padding:10px 11px;border-top:1px solid var(--dsw-alias-border-l1)}
|
|
350
|
+
.km-key-row:first-child{border-top:0}
|
|
351
|
+
.km-key-identity{min-width:0;display:flex;flex-direction:column;gap:2px}
|
|
352
|
+
.km-key-alias-line{display:flex;align-items:center;gap:6px;min-width:0}
|
|
353
|
+
.km-key-alias{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px}
|
|
354
|
+
.km-key-sub{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--dsw-alias-label-secondary);flex-wrap:wrap}
|
|
355
|
+
.km-key-status{display:flex;flex-direction:column;gap:2px;align-items:flex-start}
|
|
356
|
+
.km-key-last{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
357
|
+
.km-key-time{font-size:11.5px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}
|
|
358
|
+
.km-key-time.km-warn{color:var(--dsw-alias-state-warn-primary)}
|
|
359
|
+
.km-key-actions{position:relative;display:flex;justify-content:flex-end}
|
|
360
|
+
.km-status{display:inline-flex;align-items:center;gap:5px;padding:2px 7px;border-radius:999px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);font-size:11px;white-space:nowrap;color:var(--dsw-alias-label-secondary)}
|
|
361
|
+
.km-status-success{color:var(--dsw-alias-state-success-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-success-primary) 26%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 8%,transparent)}
|
|
362
|
+
.km-status-warn{color:var(--dsw-alias-state-warn-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 30%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 8%,transparent)}
|
|
363
|
+
.km-status-error{color:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 30%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,transparent)}
|
|
364
|
+
.km-status-idle{color:var(--dsw-alias-state-idle-primary)}
|
|
365
|
+
.km-dot{display:inline-block;width:6px;height:6px;border-radius:50%;flex:0 0 6px;background:var(--dsw-alias-state-idle-primary)}
|
|
366
|
+
.km-dot-success{background:var(--dsw-alias-state-success-primary)}
|
|
367
|
+
.km-dot-warn{background:var(--dsw-alias-state-warn-primary)}
|
|
368
|
+
.km-dot-error{background:var(--dsw-alias-state-error-primary)}
|
|
369
|
+
.km-dot-idle{background:var(--dsw-alias-state-idle-primary)}
|
|
370
|
+
.km-dot-sep{color:var(--dsw-alias-label-secondary)}
|
|
371
|
+
.km-tag{display:inline-flex;align-items:center;padding:1px 6px;border-radius:5px;font-size:10.5px;line-height:1.45;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);white-space:nowrap}
|
|
372
|
+
.km-tag-accent{color:var(--dsw-alias-state-business-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-business-primary) 34%,var(--dsw-alias-border-l1));background:var(--dsw-alias-state-business-tertiary)}
|
|
373
|
+
.km-tag-warn{color:var(--dsw-alias-state-warn-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 30%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 8%,transparent)}
|
|
374
|
+
.km-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:1px solid transparent;border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;flex:0 0 auto}
|
|
375
|
+
.km-icon-btn:hover{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-border-l1);color:var(--dsw-alias-label-primary)}
|
|
376
|
+
.km-icon-btn:disabled{opacity:.5;cursor:default}
|
|
377
|
+
.km-menu{position:absolute;top:32px;right:0;z-index:20;min-width:138px;padding:4px;border:1px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-overlay);box-shadow:0 7px 22px color-mix(in srgb,var(--dsw-alias-label-primary) 14%,transparent)}
|
|
378
|
+
.km-menu-item{display:flex;align-items:center;gap:8px;width:100%;padding:7px 9px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12.5px;text-align:left;cursor:pointer}
|
|
379
|
+
.km-menu-item:hover{background:var(--dsw-alias-bg-layer-2)}
|
|
380
|
+
.km-menu-item:disabled{opacity:.5;cursor:default}
|
|
381
|
+
.km-menu-danger{color:var(--dsw-alias-state-error-primary)}
|
|
382
|
+
.km-menu-sep{height:1px;margin:4px 2px;background:var(--dsw-alias-border-l1)}
|
|
383
|
+
.km-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:7px 11px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:12.5px;font-weight:550;line-height:1.2;cursor:pointer;white-space:nowrap;transition:opacity .15s ease,background .15s ease}
|
|
384
|
+
.km-btn:hover{background:var(--dsw-alias-bg-layer-2)}
|
|
385
|
+
.km-btn:disabled{opacity:.5;cursor:default}
|
|
386
|
+
.km-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-base);border-color:transparent}
|
|
387
|
+
.km-btn-primary:hover{opacity:.9;background:var(--dsw-alias-label-primary)}
|
|
388
|
+
.km-btn-ghost{background:transparent;border-color:transparent;color:var(--dsw-alias-label-secondary)}
|
|
389
|
+
.km-btn-ghost:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}
|
|
390
|
+
.km-btn-danger{background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-bg-base);border-color:transparent}
|
|
391
|
+
.km-btn-danger:hover{opacity:.9;background:var(--dsw-alias-state-error-primary)}
|
|
392
|
+
.km-btn-small{padding:5px 8px;font-size:12px;border-radius:7px}
|
|
393
|
+
.km-input{width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;outline:none}
|
|
394
|
+
.km-input:focus{border-color:var(--dsw-alias-state-business-primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--dsw-alias-state-business-primary) 18%,transparent)}
|
|
395
|
+
.km-input:disabled{opacity:.6}
|
|
396
|
+
select.km-input{appearance:auto}
|
|
397
|
+
.km-form{display:flex;flex-direction:column;gap:10px;padding:12px;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-1)}
|
|
398
|
+
.km-form-lead{display:flex;flex-direction:column;gap:2px}
|
|
399
|
+
.km-form-title{font-weight:650;font-size:12.5px}
|
|
400
|
+
.km-form-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.4fr);gap:10px}
|
|
401
|
+
.km-field{display:flex;flex-direction:column;gap:5px;min-width:0}
|
|
402
|
+
.km-field-wide{min-width:0}
|
|
403
|
+
.km-field-label{font-size:11.5px;font-weight:550;color:var(--dsw-alias-label-secondary)}
|
|
404
|
+
.km-field-hint{font-size:11px;color:var(--dsw-alias-label-secondary);line-height:1.45}
|
|
405
|
+
.km-secret{position:relative;display:flex;align-items:center}
|
|
406
|
+
.km-secret-input{padding-right:38px}
|
|
407
|
+
.km-secret-toggle{position:absolute;right:4px;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer}
|
|
408
|
+
.km-secret-toggle:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}
|
|
409
|
+
.km-form-actions{display:flex;justify-content:flex-end;gap:8px}
|
|
410
|
+
.km-rename{display:flex;align-items:center;gap:4px;min-width:0;flex:1 1 auto;max-width:100%}
|
|
411
|
+
.km-rename-input{flex:1 1 auto;width:auto;min-width:60px;padding:4px 7px;font-size:12.5px}
|
|
412
|
+
.km-inline-error{padding:7px 9px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 35%,var(--dsw-alias-border-l1));border-radius:7px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,transparent);color:var(--dsw-alias-state-error-primary);font-size:12px;word-break:break-word}
|
|
413
|
+
.km-key-error{grid-column:1/-1;margin-top:-2px}
|
|
414
|
+
.km-notice{display:flex;align-items:flex-start;gap:8px;padding:9px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
415
|
+
.km-notice-icon{flex:0 0 auto;margin-top:1px}
|
|
416
|
+
.km-notice-warn{border-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 32%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 7%,transparent)}
|
|
417
|
+
.km-notice-error{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 32%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 7%,transparent)}
|
|
418
|
+
.km-notice-body{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
419
|
+
.km-notice-title{color:var(--dsw-alias-label-primary);font-weight:600;font-size:12px}
|
|
420
|
+
.km-notice-text{line-height:1.5}
|
|
421
|
+
.km-notice-action{flex:0 0 auto}
|
|
422
|
+
.km-empty-keys{padding:12px;border:1px dashed var(--dsw-alias-border-l2);border-radius:8px;color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
423
|
+
.km-empty{display:flex;align-items:center;gap:8px;padding:14px;border:1px dashed var(--dsw-alias-border-l2);border-radius:10px;color:var(--dsw-alias-label-secondary);font-size:12.5px}
|
|
424
|
+
.km-provider-foot{display:flex;justify-content:space-between;gap:10px;align-items:center;margin-top:10px;padding-top:9px;border-top:1px dashed var(--dsw-alias-border-l1);font-size:11px;min-height:15px}
|
|
425
|
+
.km-settings{padding:14px}
|
|
426
|
+
.km-settings-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:12px}
|
|
427
|
+
.km-settings-title{font-size:14px;font-weight:650;margin:0 0 3px}
|
|
428
|
+
.km-settings-intro{margin:0;color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
429
|
+
.km-settings-icon{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:9px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-brand-primary);border:1px solid var(--dsw-alias-border-l1)}
|
|
430
|
+
.km-settings-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr);gap:12px;align-items:start}
|
|
431
|
+
.km-field-note{grid-column:1/-1}
|
|
432
|
+
.km-policy-note{padding:9px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-2)}
|
|
433
|
+
.km-policy-title{display:flex;align-items:center;gap:6px;font-size:11.5px;font-weight:600;color:var(--dsw-alias-label-primary);margin-bottom:2px}
|
|
434
|
+
.km-policy-note p{margin:0;font-size:11.5px;line-height:1.5}
|
|
435
|
+
.km-settings-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-top:12px}
|
|
436
|
+
.km-saved{display:inline-flex;align-items:center;gap:4px;color:var(--dsw-alias-state-success-primary);font-size:11.5px}
|
|
437
|
+
.km-banner{display:flex;align-items:flex-start;gap:8px;padding:9px 10px;border-radius:8px;margin:0 0 12px;font-size:12px;line-height:1.5;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}
|
|
438
|
+
.km-banner-error{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 32%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 7%,transparent)}
|
|
439
|
+
.km-banner-warn{border-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 32%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 7%,transparent)}
|
|
440
|
+
.km-banner-text{flex:1;min-width:0;word-break:break-word}
|
|
441
|
+
.km-banner-close{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer}
|
|
442
|
+
.km-banner-close:hover{background:var(--dsw-alias-bg-layer-2)}
|
|
443
|
+
.km-loading{display:flex;align-items:center;gap:8px;padding:20px 0;color:var(--dsw-alias-label-secondary);font-size:12.5px}
|
|
444
|
+
.km-load-failure{display:flex;flex-direction:column;gap:10px;align-items:flex-start;padding:18px;border:1px dashed var(--dsw-alias-border-l2);border-radius:10px;color:var(--dsw-alias-label-secondary);font-size:12.5px}
|
|
445
|
+
.km-empty-title{font-weight:600;color:var(--dsw-alias-label-primary)}
|
|
446
|
+
.km-footer{display:flex;align-items:flex-start;gap:6px;padding-top:4px;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:1.5}
|
|
447
|
+
.km-muted{color:var(--dsw-alias-label-secondary)}
|
|
448
|
+
.km-warn{color:var(--dsw-alias-state-warn-primary)}
|
|
449
|
+
.km-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}
|
|
450
|
+
.km-truncate{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
451
|
+
.km-spin{animation:km-spin 1s linear infinite}
|
|
452
|
+
.km-models-note{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin:8px 0 0;padding:7px 9px;border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary) 24%,var(--dsw-alias-border-l1));border-radius:7px;background:color-mix(in srgb,var(--dsw-alias-brand-primary) 6%,transparent);font-size:11.5px;color:var(--dsw-alias-label-primary)}
|
|
453
|
+
.km-models-note-warn{border-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 30%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 7%,transparent)}
|
|
454
|
+
.km-models-note-text{font-weight:600}
|
|
455
|
+
.km-models-note-hint{color:var(--dsw-alias-label-secondary);font-weight:400}
|
|
456
|
+
.km-modal-backdrop{position:fixed;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;padding:24px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 26%,transparent)}
|
|
457
|
+
.km-modal{width:min(440px,100%);border:1px solid var(--dsw-alias-border-l2);border-radius:12px;background:var(--dsw-alias-bg-overlay);padding:16px;box-shadow:0 18px 48px color-mix(in srgb,var(--dsw-alias-label-primary) 20%,transparent)}
|
|
458
|
+
.km-modal-title{font-weight:650;font-size:14px;margin-bottom:7px}
|
|
459
|
+
.km-modal-body{color:var(--dsw-alias-label-secondary);font-size:12.5px}
|
|
460
|
+
.km-modal-copy{margin:0;line-height:1.55}
|
|
461
|
+
.km-modal-footer{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}
|
|
462
|
+
@keyframes km-spin{to{transform:rotate(360deg)}}
|
|
463
|
+
@media(max-width:720px){
|
|
464
|
+
.km-summary{grid-template-columns:repeat(2,minmax(0,1fr))}
|
|
465
|
+
.km-key-row{grid-template-columns:minmax(0,1fr) 32px;gap:6px}
|
|
466
|
+
.km-key-status,.km-key-last{grid-column:1;padding-left:0}
|
|
467
|
+
.km-key-actions{grid-column:2;grid-row:1}
|
|
468
|
+
.km-settings-grid{grid-template-columns:1fr}
|
|
469
|
+
.km-form-grid{grid-template-columns:1fr}
|
|
470
|
+
.km-provider-side .km-status{display:none}
|
|
471
|
+
.km-embedded-head{flex-direction:column;gap:10px}
|
|
472
|
+
.km-embedded-actions{padding-top:0}
|
|
473
|
+
}
|
|
474
|
+
`;
|
|
475
|
+
|
|
476
|
+
// src/client/runtime.ts
|
|
477
|
+
var RuntimeContext = import_react.default.createContext(null);
|
|
478
|
+
function useRuntime() {
|
|
479
|
+
const runtime = import_react.default.useContext(RuntimeContext);
|
|
480
|
+
if (runtime === null) throw new Error("Keys Manager runtime is not mounted");
|
|
481
|
+
return runtime;
|
|
482
|
+
}
|
|
483
|
+
function useT() {
|
|
484
|
+
const runtime = useRuntime();
|
|
485
|
+
const ctx = runtime.ctx;
|
|
486
|
+
const subscribe = import_react.default.useCallback((listener) => ctx.locale.subscribe(listener), [ctx]);
|
|
487
|
+
const getSnapshot = import_react.default.useCallback(() => ctx.locale.getSnapshot(), [ctx]);
|
|
488
|
+
const locale = import_react.default.useSyncExternalStore(subscribe, getSnapshot);
|
|
489
|
+
return import_react.default.useMemo(() => ctx.locale.bind("dsh-keys-manager"), [ctx, locale.revision]);
|
|
490
|
+
}
|
|
491
|
+
function useLocaleId() {
|
|
492
|
+
const runtime = useRuntime();
|
|
493
|
+
const ctx = runtime.ctx;
|
|
494
|
+
const subscribe = import_react.default.useCallback((listener) => ctx.locale.subscribe(listener), [ctx]);
|
|
495
|
+
const getSnapshot = import_react.default.useCallback(() => ctx.locale.getSnapshot(), [ctx]);
|
|
496
|
+
return import_react.default.useSyncExternalStore(subscribe, getSnapshot).active;
|
|
497
|
+
}
|
|
498
|
+
function useStore() {
|
|
499
|
+
const runtime = useRuntime();
|
|
500
|
+
return import_react.default.useSyncExternalStore(runtime.store.subscribe, runtime.store.getSnapshot);
|
|
501
|
+
}
|
|
502
|
+
var styleRefs = 0;
|
|
503
|
+
function useStyles() {
|
|
504
|
+
import_react.default.useEffect(() => {
|
|
505
|
+
styleRefs += 1;
|
|
506
|
+
let element = document.getElementById("dsh-keys-manager-styles");
|
|
507
|
+
if (element === null) {
|
|
508
|
+
element = document.createElement("style");
|
|
509
|
+
element.id = "dsh-keys-manager-styles";
|
|
510
|
+
document.head.appendChild(element);
|
|
511
|
+
}
|
|
512
|
+
element.textContent = CSS;
|
|
513
|
+
return () => {
|
|
514
|
+
styleRefs -= 1;
|
|
515
|
+
if (styleRefs <= 0) {
|
|
516
|
+
styleRefs = 0;
|
|
517
|
+
element?.remove();
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
}, []);
|
|
521
|
+
}
|
|
522
|
+
function wrapComponent(Component, runtime) {
|
|
523
|
+
return function KeysManagerRuntime(props) {
|
|
524
|
+
useStyles();
|
|
525
|
+
return import_react.default.createElement(RuntimeContext.Provider, { value: runtime }, import_react.default.createElement(Component, props));
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// src/client/store.ts
|
|
530
|
+
function messageOf(error) {
|
|
531
|
+
if (error instanceof Error && error.message.length > 0) return error.message;
|
|
532
|
+
return String(error);
|
|
533
|
+
}
|
|
534
|
+
function createStore(ctx) {
|
|
535
|
+
let snapshot = {
|
|
536
|
+
status: "idle",
|
|
537
|
+
state: null,
|
|
538
|
+
error: null,
|
|
539
|
+
busy: null,
|
|
540
|
+
now: Date.now()
|
|
541
|
+
};
|
|
542
|
+
let loadSequence = 0;
|
|
543
|
+
let mutationTail = Promise.resolve();
|
|
544
|
+
let queuedMutations = 0;
|
|
545
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
546
|
+
const emit = () => {
|
|
547
|
+
for (const listener of [...listeners]) {
|
|
548
|
+
try {
|
|
549
|
+
listener();
|
|
550
|
+
} catch {
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
const update = (patch) => {
|
|
555
|
+
snapshot = { ...snapshot, ...patch };
|
|
556
|
+
emit();
|
|
557
|
+
};
|
|
558
|
+
const rpc = (method, args) => ctx.connection.rpc.call("/api", `keysManager/${method}`, { args });
|
|
559
|
+
return {
|
|
560
|
+
getSnapshot: () => snapshot,
|
|
561
|
+
subscribe(listener) {
|
|
562
|
+
listeners.add(listener);
|
|
563
|
+
return () => listeners.delete(listener);
|
|
564
|
+
},
|
|
565
|
+
async load(options = {}) {
|
|
566
|
+
if (snapshot.busy !== null) return;
|
|
567
|
+
const request = ++loadSequence;
|
|
568
|
+
update({ busy: "load", error: options.keepError === true ? snapshot.error : null });
|
|
569
|
+
try {
|
|
570
|
+
const result = await rpc("getState", {});
|
|
571
|
+
if (request !== loadSequence) return;
|
|
572
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
573
|
+
update({ status: "ready", state: result.value, now: Date.now(), busy: null, error: null });
|
|
574
|
+
} catch (error) {
|
|
575
|
+
if (request !== loadSequence) return;
|
|
576
|
+
update({ status: snapshot.state !== null ? snapshot.status : "error", busy: null, error: messageOf(error) });
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
call(method, args) {
|
|
580
|
+
queuedMutations += 1;
|
|
581
|
+
update({ busy: method, error: null });
|
|
582
|
+
const run = async () => {
|
|
583
|
+
++loadSequence;
|
|
584
|
+
try {
|
|
585
|
+
const result = await rpc(method, args);
|
|
586
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
587
|
+
const outcome = { ok: true, value: result.value };
|
|
588
|
+
if (queuedMutations === 1) {
|
|
589
|
+
update({ status: "ready", state: result.value, now: Date.now(), busy: null, error: null });
|
|
590
|
+
} else {
|
|
591
|
+
update({ status: "ready", state: result.value, now: Date.now(), error: null });
|
|
592
|
+
}
|
|
593
|
+
return outcome;
|
|
594
|
+
} catch (error) {
|
|
595
|
+
const message = messageOf(error);
|
|
596
|
+
if (queuedMutations === 1) update({ busy: null, error: message });
|
|
597
|
+
else update({ error: message });
|
|
598
|
+
return { ok: false, error: message };
|
|
599
|
+
} finally {
|
|
600
|
+
queuedMutations -= 1;
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
const next = mutationTail.then(run, run);
|
|
604
|
+
mutationTail = next.then(() => void 0, () => void 0);
|
|
605
|
+
return next;
|
|
606
|
+
},
|
|
607
|
+
tick() {
|
|
608
|
+
update({ now: Date.now() });
|
|
609
|
+
if (snapshot.status === "ready" && snapshot.busy === null) void this.load({ keepError: true });
|
|
610
|
+
},
|
|
611
|
+
dismissError() {
|
|
612
|
+
update({ error: null });
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// src/client/ui.ts
|
|
618
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
619
|
+
|
|
620
|
+
// src/client/format.ts
|
|
621
|
+
function cooldownMinutes(ms) {
|
|
622
|
+
return ms / 6e4;
|
|
623
|
+
}
|
|
624
|
+
function cooldownMs(minutes) {
|
|
625
|
+
return Math.max(0.5, minutes) * 6e4;
|
|
626
|
+
}
|
|
627
|
+
function graceMinutes(ms) {
|
|
628
|
+
return ms / 6e4;
|
|
629
|
+
}
|
|
630
|
+
function graceMs(minutes) {
|
|
631
|
+
return Math.max(0, minutes) * 6e4;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// src/client/ui.ts
|
|
635
|
+
var h = import_react2.default.createElement;
|
|
636
|
+
function cx(...values) {
|
|
637
|
+
return values.filter(Boolean).join(" ");
|
|
638
|
+
}
|
|
639
|
+
var FOCUSABLE = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
640
|
+
function countText(t, count, oneKey, manyKey) {
|
|
641
|
+
return count === 1 ? t(oneKey) : t(manyKey, { n: count });
|
|
642
|
+
}
|
|
643
|
+
function formatClock(timestamp, locale, t) {
|
|
644
|
+
if (!timestamp) return t("never");
|
|
645
|
+
try {
|
|
646
|
+
return new Intl.DateTimeFormat(locale === "zh" ? "zh-CN" : "en", {
|
|
647
|
+
month: "2-digit",
|
|
648
|
+
day: "2-digit",
|
|
649
|
+
hour: "2-digit",
|
|
650
|
+
minute: "2-digit"
|
|
651
|
+
}).format(new Date(timestamp));
|
|
652
|
+
} catch {
|
|
653
|
+
return new Date(timestamp).toLocaleString();
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
function relativeTime(timestamp, now, t) {
|
|
657
|
+
if (!timestamp) return t("never");
|
|
658
|
+
const diff = Math.max(0, now - timestamp);
|
|
659
|
+
if (diff < 6e4) return t("timeJustNow");
|
|
660
|
+
if (diff < 36e5) return t("timeMinutesAgo", { n: Math.floor(diff / 6e4) });
|
|
661
|
+
if (diff < 864e5) return t("timeHoursAgo", { n: Math.floor(diff / 36e5) });
|
|
662
|
+
return t("timeDaysAgo", { n: Math.floor(diff / 864e5) });
|
|
663
|
+
}
|
|
664
|
+
function durationText(milliseconds, t) {
|
|
665
|
+
const ms = Math.max(0, milliseconds);
|
|
666
|
+
if (ms < 6e4) return t("timeSeconds", { n: Math.max(1, Math.ceil(ms / 1e3)) });
|
|
667
|
+
if (ms < 36e5) return t("timeMinutes", { n: Math.ceil(ms / 6e4) });
|
|
668
|
+
if (ms < 864e5) return t("timeHours", { n: Math.ceil(ms / 36e5) });
|
|
669
|
+
return t("timeDays", { n: Math.ceil(ms / 864e5) });
|
|
670
|
+
}
|
|
671
|
+
function providerInitial(provider) {
|
|
672
|
+
const source = String(provider?.displayName || provider?.provider || "?").trim();
|
|
673
|
+
return source.length === 0 ? "?" : source.slice(0, 1).toUpperCase();
|
|
674
|
+
}
|
|
675
|
+
function statusKey(status) {
|
|
676
|
+
switch (status) {
|
|
677
|
+
case "active":
|
|
678
|
+
return "keyStatusActive";
|
|
679
|
+
case "cooling":
|
|
680
|
+
return "keyStatusCooling";
|
|
681
|
+
case "paused":
|
|
682
|
+
return "keyStatusPaused";
|
|
683
|
+
case "missing":
|
|
684
|
+
return "keyStatusMissing";
|
|
685
|
+
default:
|
|
686
|
+
return "keyStatusUnmanaged";
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
function statusTone(status) {
|
|
690
|
+
switch (status) {
|
|
691
|
+
case "active":
|
|
692
|
+
return "success";
|
|
693
|
+
case "cooling":
|
|
694
|
+
return "warn";
|
|
695
|
+
case "paused":
|
|
696
|
+
return "idle";
|
|
697
|
+
case "missing":
|
|
698
|
+
return "error";
|
|
699
|
+
default:
|
|
700
|
+
return "idle";
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function Icon({ name, size = 16, className }) {
|
|
704
|
+
const common = {
|
|
705
|
+
width: size,
|
|
706
|
+
height: size,
|
|
707
|
+
viewBox: "0 0 24 24",
|
|
708
|
+
fill: "none",
|
|
709
|
+
stroke: "currentColor",
|
|
710
|
+
strokeWidth: 1.8,
|
|
711
|
+
strokeLinecap: "round",
|
|
712
|
+
strokeLinejoin: "round",
|
|
713
|
+
className,
|
|
714
|
+
"aria-hidden": true
|
|
715
|
+
};
|
|
716
|
+
if (name === "search") return h("svg", common, h("circle", { cx: 11, cy: 11, r: 6.5 }), h("path", { d: "M16 16l4 4" }));
|
|
717
|
+
if (name === "plus") return h("svg", common, h("path", { d: "M12 5v14M5 12h14" }));
|
|
718
|
+
if (name === "dots") return h("svg", common, h("circle", { cx: 5, cy: 12, r: 1.2, fill: "currentColor", stroke: "none" }), h("circle", { cx: 12, cy: 12, r: 1.2, fill: "currentColor", stroke: "none" }), h("circle", { cx: 19, cy: 12, r: 1.2, fill: "currentColor", stroke: "none" }));
|
|
719
|
+
if (name === "chevron") return h("svg", common, h("path", { d: "M6 9l6 6 6-6" }));
|
|
720
|
+
if (name === "eye") return h("svg", common, h("path", { d: "M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6z" }), h("circle", { cx: 12, cy: 12, r: 2.5 }));
|
|
721
|
+
if (name === "eyeOff") return h("svg", common, h("path", { d: "M3 3l18 18M10.6 6.2A9.8 9.8 0 0112 6c6 0 9.5 6 9.5 6a17 17 0 01-3.2 3.8M6.2 6.7A16.4 16.4 0 002.5 12s3.5 6 9.5 6a9.7 9.7 0 004.2-.9M9.9 9.9a3 3 0 004.2 4.2" }));
|
|
722
|
+
if (name === "key") return h("svg", common, h("circle", { cx: 8, cy: 12, r: 3.5 }), h("path", { d: "M11.5 12H21M17 12v3M20 12v2.5" }));
|
|
723
|
+
if (name === "check") return h("svg", common, h("path", { d: "M5 12.5l4.5 4.5L19 7.5" }));
|
|
724
|
+
if (name === "pause") return h("svg", common, h("path", { d: "M9 6v12M15 6v12" }));
|
|
725
|
+
if (name === "play") return h("svg", common, h("path", { d: "M8 5l11 7-11 7V5z" }));
|
|
726
|
+
if (name === "trash") return h("svg", common, h("path", { d: "M4 7h16M9 7V5h6v2M7 7l1 13h8l1-13M10 11v5M14 11v5" }));
|
|
727
|
+
if (name === "close") return h("svg", common, h("path", { d: "M6 6l12 12M18 6L6 18" }));
|
|
728
|
+
if (name === "refresh") return h("svg", common, h("path", { d: "M20 11a8 8 0 10-2.3 6M20 5v6h-6" }));
|
|
729
|
+
if (name === "warning") return h("svg", common, h("path", { d: "M12 3l9.5 17h-19L12 3zM12 9v5M12 17.2v.1" }));
|
|
730
|
+
if (name === "shield") return h("svg", common, h("path", { d: "M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3zM9 12l2 2 4-4" }));
|
|
731
|
+
return h("svg", common);
|
|
732
|
+
}
|
|
733
|
+
function Button({ variant = "secondary", size = "normal", type = "button", disabled, onClick, children, title }) {
|
|
734
|
+
return h("button", {
|
|
735
|
+
type,
|
|
736
|
+
className: cx("km-btn", `km-btn-${variant}`, size === "small" && "km-btn-small"),
|
|
737
|
+
disabled,
|
|
738
|
+
onClick,
|
|
739
|
+
title
|
|
740
|
+
}, children);
|
|
741
|
+
}
|
|
742
|
+
function StatusPill({ status, t }) {
|
|
743
|
+
return h(
|
|
744
|
+
"span",
|
|
745
|
+
{ className: cx("km-status", `km-status-${statusTone(status)}`) },
|
|
746
|
+
h("span", { className: cx("km-dot", `km-dot-${statusTone(status)}`) }),
|
|
747
|
+
h("span", null, t(statusKey(status)))
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
function Notice({ tone = "info", icon = "warning", title, children, action }) {
|
|
751
|
+
return h(
|
|
752
|
+
"div",
|
|
753
|
+
{ className: cx("km-notice", `km-notice-${tone}`), role: tone === "error" ? "alert" : "note" },
|
|
754
|
+
h(Icon, { name: icon, size: 15, className: "km-notice-icon" }),
|
|
755
|
+
h(
|
|
756
|
+
"div",
|
|
757
|
+
{ className: "km-notice-body" },
|
|
758
|
+
title ? h("div", { className: "km-notice-title" }, title) : null,
|
|
759
|
+
h("div", { className: "km-notice-text" }, children)
|
|
760
|
+
),
|
|
761
|
+
action ? h("div", { className: "km-notice-action" }, action) : null
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
function Modal({ title, children, onClose, footer, busy }) {
|
|
765
|
+
const dialogRef = import_react2.default.useRef(null);
|
|
766
|
+
const onCloseRef = import_react2.default.useRef(onClose);
|
|
767
|
+
const busyRef = import_react2.default.useRef(busy);
|
|
768
|
+
onCloseRef.current = onClose;
|
|
769
|
+
busyRef.current = busy;
|
|
770
|
+
import_react2.default.useEffect(() => {
|
|
771
|
+
const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
772
|
+
const dialog = dialogRef.current;
|
|
773
|
+
const inerted = [];
|
|
774
|
+
if (dialog !== null) {
|
|
775
|
+
let node = dialog.parentElement;
|
|
776
|
+
while (node !== null && node !== document.body) {
|
|
777
|
+
for (const child of [...node.children]) {
|
|
778
|
+
if (!(child instanceof HTMLElement) || child === dialog || child.contains(dialog)) continue;
|
|
779
|
+
if (!child.inert) {
|
|
780
|
+
child.inert = true;
|
|
781
|
+
inerted.push(child);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
node = node.parentElement;
|
|
785
|
+
}
|
|
786
|
+
const first = dialog.querySelector(FOCUSABLE);
|
|
787
|
+
(first ?? dialog).focus();
|
|
788
|
+
}
|
|
789
|
+
const onKey = (event) => {
|
|
790
|
+
if (event.key === "Escape" && busyRef.current !== true) {
|
|
791
|
+
event.preventDefault();
|
|
792
|
+
onCloseRef.current();
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
if (event.key !== "Tab" || dialog === null) return;
|
|
796
|
+
const nodes = [...dialog.querySelectorAll(FOCUSABLE)].filter((node) => node.offsetParent !== null);
|
|
797
|
+
if (nodes.length === 0) {
|
|
798
|
+
event.preventDefault();
|
|
799
|
+
dialog.focus();
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const first = nodes[0];
|
|
803
|
+
const last = nodes[nodes.length - 1];
|
|
804
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
805
|
+
event.preventDefault();
|
|
806
|
+
last.focus();
|
|
807
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
808
|
+
event.preventDefault();
|
|
809
|
+
first.focus();
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
document.addEventListener("keydown", onKey);
|
|
813
|
+
return () => {
|
|
814
|
+
document.removeEventListener("keydown", onKey);
|
|
815
|
+
for (const element of inerted) element.inert = false;
|
|
816
|
+
if (previous !== null && previous.isConnected) previous.focus();
|
|
817
|
+
};
|
|
818
|
+
}, []);
|
|
819
|
+
return h("div", {
|
|
820
|
+
className: "km-modal-backdrop",
|
|
821
|
+
role: "presentation",
|
|
822
|
+
onMouseDown: (event) => {
|
|
823
|
+
if (event.target === event.currentTarget && !busy) onClose();
|
|
824
|
+
}
|
|
825
|
+
}, h(
|
|
826
|
+
"div",
|
|
827
|
+
{
|
|
828
|
+
className: "km-modal",
|
|
829
|
+
role: "dialog",
|
|
830
|
+
"aria-modal": "true",
|
|
831
|
+
"aria-label": title,
|
|
832
|
+
tabIndex: -1,
|
|
833
|
+
ref: dialogRef
|
|
834
|
+
},
|
|
835
|
+
h("div", { className: "km-modal-title" }, title),
|
|
836
|
+
h("div", { className: "km-modal-body" }, children),
|
|
837
|
+
h("div", { className: "km-modal-footer" }, footer)
|
|
838
|
+
));
|
|
839
|
+
}
|
|
840
|
+
function KeyForm({ provider, onDone, autoFocus = false }) {
|
|
841
|
+
const runtime = useRuntime();
|
|
842
|
+
const t = useT();
|
|
843
|
+
const [alias, setAlias] = import_react2.default.useState("");
|
|
844
|
+
const [value, setValue] = import_react2.default.useState("");
|
|
845
|
+
const [show, setShow] = import_react2.default.useState(false);
|
|
846
|
+
const [busy, setBusy] = import_react2.default.useState(false);
|
|
847
|
+
const [error, setError] = import_react2.default.useState(null);
|
|
848
|
+
const isExtra = !provider.managed && provider.extra;
|
|
849
|
+
const disabled = busy || alias.trim().length === 0 || value.trim().length === 0;
|
|
850
|
+
async function submit(event) {
|
|
851
|
+
event.preventDefault();
|
|
852
|
+
if (disabled) return;
|
|
853
|
+
setBusy(true);
|
|
854
|
+
setError(null);
|
|
855
|
+
const method = provider.managed ? "addKey" : "addExtraProvider";
|
|
856
|
+
const args = provider.managed ? { provider: provider.provider, alias: alias.trim(), value } : { extraId: provider.extraId ?? provider.provider, alias: alias.trim(), value };
|
|
857
|
+
const result = await runtime.store.call(method, args);
|
|
858
|
+
setBusy(false);
|
|
859
|
+
if (!result.ok) {
|
|
860
|
+
setError(result.error);
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
setAlias("");
|
|
864
|
+
setValue("");
|
|
865
|
+
setShow(false);
|
|
866
|
+
onDone?.();
|
|
867
|
+
}
|
|
868
|
+
return h(
|
|
869
|
+
"form",
|
|
870
|
+
{ className: "km-form", onSubmit: submit },
|
|
871
|
+
h(
|
|
872
|
+
"div",
|
|
873
|
+
{ className: "km-form-lead" },
|
|
874
|
+
h("div", { className: "km-form-title" }, t("addKeyTitle")),
|
|
875
|
+
h("div", { className: "km-muted" }, isExtra ? t("adoptExtraHint") : t("addKeyHint"))
|
|
876
|
+
),
|
|
877
|
+
h(
|
|
878
|
+
"div",
|
|
879
|
+
{ className: "km-form-grid" },
|
|
880
|
+
h(
|
|
881
|
+
"label",
|
|
882
|
+
{ className: "km-field" },
|
|
883
|
+
h("span", { className: "km-field-label" }, t("alias")),
|
|
884
|
+
h("input", {
|
|
885
|
+
className: "km-input",
|
|
886
|
+
value: alias,
|
|
887
|
+
onChange: (event) => setAlias(event.target.value),
|
|
888
|
+
placeholder: t("aliasPlaceholder"),
|
|
889
|
+
maxLength: 80,
|
|
890
|
+
autoFocus: autoFocus || isExtra,
|
|
891
|
+
disabled: busy
|
|
892
|
+
})
|
|
893
|
+
),
|
|
894
|
+
h(
|
|
895
|
+
"label",
|
|
896
|
+
{ className: "km-field km-field-wide" },
|
|
897
|
+
h("span", { className: "km-field-label" }, t("secret")),
|
|
898
|
+
h(
|
|
899
|
+
"div",
|
|
900
|
+
{ className: "km-secret" },
|
|
901
|
+
h("input", {
|
|
902
|
+
className: "km-input km-secret-input",
|
|
903
|
+
type: show ? "text" : "password",
|
|
904
|
+
value,
|
|
905
|
+
onChange: (event) => setValue(event.target.value),
|
|
906
|
+
placeholder: t("secretPlaceholder"),
|
|
907
|
+
autoComplete: "new-password",
|
|
908
|
+
spellCheck: false,
|
|
909
|
+
disabled: busy
|
|
910
|
+
}),
|
|
911
|
+
h("button", {
|
|
912
|
+
type: "button",
|
|
913
|
+
className: "km-secret-toggle",
|
|
914
|
+
onClick: () => setShow((current) => !current),
|
|
915
|
+
disabled: busy,
|
|
916
|
+
title: show ? t("hide") : t("show")
|
|
917
|
+
}, h(Icon, { name: show ? "eyeOff" : "eye", size: 15 }))
|
|
918
|
+
)
|
|
919
|
+
)
|
|
920
|
+
),
|
|
921
|
+
error !== null ? h("div", { className: "km-inline-error", role: "alert" }, error) : null,
|
|
922
|
+
h(
|
|
923
|
+
"div",
|
|
924
|
+
{ className: "km-form-actions" },
|
|
925
|
+
h(
|
|
926
|
+
Button,
|
|
927
|
+
{ variant: "primary", type: "submit", disabled },
|
|
928
|
+
busy ? h(Icon, { name: "refresh", size: 14, className: "km-spin" }) : h(Icon, { name: "plus", size: 14 }),
|
|
929
|
+
h("span", null, busy ? isExtra ? t("adding") : t("saving") : isExtra ? t("addExtra") : t("save"))
|
|
930
|
+
)
|
|
931
|
+
)
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
function KeyRow({ provider, keyRecord, now }) {
|
|
935
|
+
const key = keyRecord;
|
|
936
|
+
const runtime = useRuntime();
|
|
937
|
+
const t = useT();
|
|
938
|
+
const locale = useLocaleId();
|
|
939
|
+
const [menu, setMenu] = import_react2.default.useState(false);
|
|
940
|
+
const [editing, setEditing] = import_react2.default.useState(false);
|
|
941
|
+
const [alias, setAlias] = import_react2.default.useState(key.alias);
|
|
942
|
+
const [confirm, setConfirm] = import_react2.default.useState(false);
|
|
943
|
+
const [busy, setBusy] = import_react2.default.useState(false);
|
|
944
|
+
const [error, setError] = import_react2.default.useState(null);
|
|
945
|
+
const rootRef = import_react2.default.useRef(null);
|
|
946
|
+
import_react2.default.useEffect(() => {
|
|
947
|
+
setAlias(key.alias);
|
|
948
|
+
}, [key.alias]);
|
|
949
|
+
import_react2.default.useEffect(() => {
|
|
950
|
+
if (!menu) return void 0;
|
|
951
|
+
const onDown = (event) => {
|
|
952
|
+
if (rootRef.current !== null && !rootRef.current.contains(event.target)) setMenu(false);
|
|
953
|
+
};
|
|
954
|
+
const onKey = (event) => {
|
|
955
|
+
if (event.key === "Escape") setMenu(false);
|
|
956
|
+
};
|
|
957
|
+
document.addEventListener("mousedown", onDown);
|
|
958
|
+
document.addEventListener("keydown", onKey);
|
|
959
|
+
return () => {
|
|
960
|
+
document.removeEventListener("mousedown", onDown);
|
|
961
|
+
document.removeEventListener("keydown", onKey);
|
|
962
|
+
};
|
|
963
|
+
}, [menu]);
|
|
964
|
+
async function update(patch) {
|
|
965
|
+
setBusy(true);
|
|
966
|
+
setError(null);
|
|
967
|
+
const result = await runtime.store.call("updateKey", { provider: provider.provider, keyId: key.id, patch });
|
|
968
|
+
setBusy(false);
|
|
969
|
+
if (!result.ok) setError(result.error);
|
|
970
|
+
else setEditing(false);
|
|
971
|
+
}
|
|
972
|
+
async function submitRename(event) {
|
|
973
|
+
event.preventDefault();
|
|
974
|
+
const next = alias.trim();
|
|
975
|
+
if (next.length === 0 || next === key.alias) {
|
|
976
|
+
setEditing(false);
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
await update({ alias: next });
|
|
980
|
+
}
|
|
981
|
+
async function remove() {
|
|
982
|
+
setBusy(true);
|
|
983
|
+
setError(null);
|
|
984
|
+
const result = await runtime.store.call("deleteKey", { provider: provider.provider, keyId: key.id });
|
|
985
|
+
setBusy(false);
|
|
986
|
+
if (!result.ok) setError(result.error);
|
|
987
|
+
else setConfirm(false);
|
|
988
|
+
}
|
|
989
|
+
const cold = key.status === "cooling" && key.cooldownUntil > now;
|
|
990
|
+
const meta = key.status === "missing" ? t("keyStatusMissing") : key.totalUses > 0 ? t("uses", { n: key.totalUses }) : "";
|
|
991
|
+
return h(
|
|
992
|
+
"div",
|
|
993
|
+
{ className: "km-key-row", ref: rootRef },
|
|
994
|
+
h(
|
|
995
|
+
"div",
|
|
996
|
+
{ className: "km-key-identity" },
|
|
997
|
+
h(
|
|
998
|
+
"div",
|
|
999
|
+
{ className: "km-key-alias-line" },
|
|
1000
|
+
editing ? h(
|
|
1001
|
+
"form",
|
|
1002
|
+
{ className: "km-rename", onSubmit: submitRename },
|
|
1003
|
+
h("input", {
|
|
1004
|
+
className: "km-input km-rename-input",
|
|
1005
|
+
"aria-label": t("alias"),
|
|
1006
|
+
value: alias,
|
|
1007
|
+
onChange: (event) => setAlias(event.target.value),
|
|
1008
|
+
maxLength: 80,
|
|
1009
|
+
autoFocus: true,
|
|
1010
|
+
disabled: busy,
|
|
1011
|
+
onKeyDown: (event) => {
|
|
1012
|
+
if (event.key === "Escape") setEditing(false);
|
|
1013
|
+
}
|
|
1014
|
+
}),
|
|
1015
|
+
h("button", { type: "submit", className: "km-icon-btn", disabled: busy, title: t("save") }, h(Icon, { name: "check", size: 15 })),
|
|
1016
|
+
h("button", { type: "button", className: "km-icon-btn", onClick: () => {
|
|
1017
|
+
setEditing(false);
|
|
1018
|
+
setAlias(key.alias);
|
|
1019
|
+
}, title: t("cancel") }, h(Icon, { name: "close", size: 15 }))
|
|
1020
|
+
) : h("span", { className: "km-key-alias" }, key.alias),
|
|
1021
|
+
key.importedFrom !== null ? h("span", { className: "km-tag" }, t("imported")) : null,
|
|
1022
|
+
key.kind === "oauth" ? h("span", { className: "km-tag" }, "OAuth") : null
|
|
1023
|
+
),
|
|
1024
|
+
h(
|
|
1025
|
+
"div",
|
|
1026
|
+
{ className: "km-key-sub" },
|
|
1027
|
+
h("span", { className: "km-mono km-muted" }, `\u2022\u2022\u2022\u2022 ${key.id.slice(-4)}`),
|
|
1028
|
+
key.totalFailures > 0 ? h("span", { className: "km-muted" }, t("failures", { n: key.totalFailures })) : null
|
|
1029
|
+
)
|
|
1030
|
+
),
|
|
1031
|
+
h(
|
|
1032
|
+
"div",
|
|
1033
|
+
{ className: "km-key-status" },
|
|
1034
|
+
h(StatusPill, { status: key.status, t }),
|
|
1035
|
+
cold ? h("div", { className: "km-key-time km-warn" }, t("coolingUntil", { time: formatClock(key.cooldownUntil, locale, t) })) : null,
|
|
1036
|
+
cold ? h("div", { className: "km-key-time" }, t("remaining", { time: durationText(key.cooldownUntil - now, t) })) : null
|
|
1037
|
+
),
|
|
1038
|
+
h(
|
|
1039
|
+
"div",
|
|
1040
|
+
{ className: "km-key-last" },
|
|
1041
|
+
h("div", { className: "km-key-time" }, `${t("lastUsed")}: ${relativeTime(key.lastUsedAt, now, t)}`),
|
|
1042
|
+
meta ? h("div", { className: "km-key-time km-muted" }, meta) : null
|
|
1043
|
+
),
|
|
1044
|
+
h(
|
|
1045
|
+
"div",
|
|
1046
|
+
{ className: "km-key-actions" },
|
|
1047
|
+
h("button", {
|
|
1048
|
+
type: "button",
|
|
1049
|
+
className: "km-icon-btn",
|
|
1050
|
+
"aria-haspopup": "menu",
|
|
1051
|
+
"aria-expanded": menu,
|
|
1052
|
+
title: t("moreActions"),
|
|
1053
|
+
"aria-label": t("moreActions"),
|
|
1054
|
+
onClick: () => setMenu((current) => !current),
|
|
1055
|
+
disabled: busy
|
|
1056
|
+
}, h(Icon, { name: "dots", size: 17 })),
|
|
1057
|
+
menu ? h(
|
|
1058
|
+
"div",
|
|
1059
|
+
{ className: "km-menu", role: "menu" },
|
|
1060
|
+
h("button", { type: "button", className: "km-menu-item", role: "menuitem", onClick: () => {
|
|
1061
|
+
setMenu(false);
|
|
1062
|
+
setEditing(true);
|
|
1063
|
+
} }, h(Icon, { name: "key", size: 15 }), t("rename")),
|
|
1064
|
+
h("button", {
|
|
1065
|
+
type: "button",
|
|
1066
|
+
className: "km-menu-item",
|
|
1067
|
+
role: "menuitem",
|
|
1068
|
+
onClick: () => {
|
|
1069
|
+
setMenu(false);
|
|
1070
|
+
void update({ enabled: !key.enabled });
|
|
1071
|
+
},
|
|
1072
|
+
disabled: busy
|
|
1073
|
+
}, h(Icon, { name: key.enabled ? "pause" : "play", size: 15 }), key.enabled ? t("pause") : t("resume")),
|
|
1074
|
+
h("div", { className: "km-menu-sep" }),
|
|
1075
|
+
h("button", { type: "button", className: "km-menu-item km-menu-danger", role: "menuitem", onClick: () => {
|
|
1076
|
+
setMenu(false);
|
|
1077
|
+
setConfirm(true);
|
|
1078
|
+
}, disabled: busy }, h(Icon, { name: "trash", size: 15 }), t("delete"))
|
|
1079
|
+
) : null
|
|
1080
|
+
),
|
|
1081
|
+
error !== null ? h("div", { className: "km-key-error", role: "alert" }, error) : null,
|
|
1082
|
+
confirm ? h(Modal, {
|
|
1083
|
+
title: t("deleteTitle", { alias: key.alias }),
|
|
1084
|
+
onClose: () => setConfirm(false),
|
|
1085
|
+
busy,
|
|
1086
|
+
footer: [
|
|
1087
|
+
h(Button, { key: "cancel", onClick: () => setConfirm(false), disabled: busy }, t("cancel")),
|
|
1088
|
+
h(Button, { key: "delete", variant: "danger", onClick: remove, disabled: busy }, busy ? t("deleting") : t("deleteConfirm"))
|
|
1089
|
+
]
|
|
1090
|
+
}, h("p", { className: "km-modal-copy" }, t("deleteBody"))) : null
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
function ProviderCard({ provider, expanded, onToggle, now }) {
|
|
1094
|
+
const runtime = useRuntime();
|
|
1095
|
+
const t = useT();
|
|
1096
|
+
const [adding, setAdding] = import_react2.default.useState(false);
|
|
1097
|
+
const [adopting, setAdopting] = import_react2.default.useState(false);
|
|
1098
|
+
const [releasing, setReleasing] = import_react2.default.useState(false);
|
|
1099
|
+
const [confirmRelease, setConfirmRelease] = import_react2.default.useState(false);
|
|
1100
|
+
const [error, setError] = import_react2.default.useState(null);
|
|
1101
|
+
const managed = provider.managed;
|
|
1102
|
+
const broken = managed && provider.bindingHealthy === false;
|
|
1103
|
+
const keyCount = provider.keyCount;
|
|
1104
|
+
const warning = provider.warning;
|
|
1105
|
+
const isExtra = provider.extra;
|
|
1106
|
+
const origin = provider.origin ?? (provider.extra ? "plugin" : "dsh");
|
|
1107
|
+
const originLabel = origin === "plugin" ? t("pluginBuiltin") : origin === "dsh" ? t("dshBuiltin") : t("customProvider");
|
|
1108
|
+
const providerMeta = [
|
|
1109
|
+
provider.provider,
|
|
1110
|
+
provider.active ? t("active") : provider.configured ? t("configured") : t("notConfigured"),
|
|
1111
|
+
provider.api ?? null
|
|
1112
|
+
].filter((value) => Boolean(value));
|
|
1113
|
+
async function adopt() {
|
|
1114
|
+
setAdopting(true);
|
|
1115
|
+
setError(null);
|
|
1116
|
+
const result = await runtime.store.call("adoptProvider", { provider: provider.provider });
|
|
1117
|
+
setAdopting(false);
|
|
1118
|
+
if (!result.ok) setError(result.error);
|
|
1119
|
+
}
|
|
1120
|
+
async function release() {
|
|
1121
|
+
setReleasing(true);
|
|
1122
|
+
setError(null);
|
|
1123
|
+
const result = await runtime.store.call("releaseProvider", { provider: provider.provider });
|
|
1124
|
+
setReleasing(false);
|
|
1125
|
+
if (!result.ok) {
|
|
1126
|
+
setError(result.error);
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
setConfirmRelease(false);
|
|
1130
|
+
}
|
|
1131
|
+
return h(
|
|
1132
|
+
"div",
|
|
1133
|
+
{ className: cx("km-card", "km-provider", expanded && "km-provider-open", managed && "km-provider-managed") },
|
|
1134
|
+
h(
|
|
1135
|
+
"button",
|
|
1136
|
+
{
|
|
1137
|
+
type: "button",
|
|
1138
|
+
className: "km-provider-head",
|
|
1139
|
+
onClick: onToggle,
|
|
1140
|
+
"aria-expanded": expanded
|
|
1141
|
+
},
|
|
1142
|
+
h("span", { className: "km-avatar", "aria-hidden": true }, providerInitial(provider)),
|
|
1143
|
+
h(
|
|
1144
|
+
"span",
|
|
1145
|
+
{ className: "km-provider-main" },
|
|
1146
|
+
h(
|
|
1147
|
+
"span",
|
|
1148
|
+
{ className: "km-provider-title-line" },
|
|
1149
|
+
h("span", { className: "km-provider-name" }, provider.displayName || provider.provider),
|
|
1150
|
+
h("span", { className: "km-tag" }, originLabel),
|
|
1151
|
+
managed ? h("span", { className: "km-tag km-tag-accent" }, t("managedBadge")) : null,
|
|
1152
|
+
!managed && !provider.supported ? h("span", { className: "km-tag km-tag-warn" }, t("unsupported")) : null
|
|
1153
|
+
),
|
|
1154
|
+
h(
|
|
1155
|
+
"span",
|
|
1156
|
+
{ className: "km-provider-meta" },
|
|
1157
|
+
h("span", { className: "km-mono" }, provider.provider),
|
|
1158
|
+
h("span", { className: "km-dot-sep", "aria-hidden": true }, "\xB7"),
|
|
1159
|
+
h("span", null, providerMeta.slice(1).join(" \xB7 ")),
|
|
1160
|
+
provider.env.length > 0 ? h("span", { className: "km-mono km-muted" }, provider.env.join(", ")) : null
|
|
1161
|
+
)
|
|
1162
|
+
),
|
|
1163
|
+
h(
|
|
1164
|
+
"span",
|
|
1165
|
+
{ className: "km-provider-side" },
|
|
1166
|
+
managed ? h("span", { className: "km-count" }, countText(t, keyCount, "providerKeyOne", "providerKeys")) : h("span", { className: "km-count km-muted" }, provider.supported ? t("unmanaged") : t("unsupported")),
|
|
1167
|
+
managed ? h(StatusPill, { status: provider.status, t }) : null,
|
|
1168
|
+
h(Icon, { name: "chevron", size: 16, className: cx("km-chevron", expanded && "km-chevron-open") })
|
|
1169
|
+
)
|
|
1170
|
+
),
|
|
1171
|
+
expanded ? h(
|
|
1172
|
+
"div",
|
|
1173
|
+
{ className: "km-provider-body" },
|
|
1174
|
+
error !== null ? h("div", { className: "km-inline-error", role: "alert" }, error) : null,
|
|
1175
|
+
warning !== void 0 || broken ? h(Notice, { tone: "warn", title: t("warning") }, broken ? t("bindingBroken") : warning) : null,
|
|
1176
|
+
!managed ? h(
|
|
1177
|
+
"div",
|
|
1178
|
+
{ className: "km-adopt" },
|
|
1179
|
+
h(
|
|
1180
|
+
"div",
|
|
1181
|
+
{ className: "km-adopt-copy" },
|
|
1182
|
+
h("div", { className: "km-adopt-title" }, provider.supported ? t(isExtra ? "adoptExtraHint" : "adoptHint") : t("unsupported")),
|
|
1183
|
+
!provider.supported && provider.reason !== void 0 ? h("div", { className: "km-muted" }, provider.reason) : null,
|
|
1184
|
+
provider.apiKeyEnv !== null ? h("div", { className: "km-meta-line" }, h("span", { className: "km-muted" }, `${t("secret")}:`), h("span", { className: "km-mono" }, provider.apiKeyEnv)) : null,
|
|
1185
|
+
provider.baseURL !== null ? h("div", { className: "km-meta-line" }, h("span", { className: "km-muted" }, `${t("baseUrl")}:`), h("span", { className: "km-mono km-truncate" }, provider.baseURL)) : null,
|
|
1186
|
+
provider.models.length > 0 ? h("div", { className: "km-meta-line" }, h("span", { className: "km-muted" }, `${t("models")}:`), h("span", null, t("countModels", { n: provider.models.length }))) : null
|
|
1187
|
+
),
|
|
1188
|
+
isExtra ? h(KeyForm, { provider, autoFocus: true }) : h(
|
|
1189
|
+
"div",
|
|
1190
|
+
{ className: "km-adopt-actions" },
|
|
1191
|
+
h(
|
|
1192
|
+
Button,
|
|
1193
|
+
{ variant: "primary", onClick: adopt, disabled: adopting || !provider.supported },
|
|
1194
|
+
adopting ? h(Icon, { name: "refresh", size: 14, className: "km-spin" }) : h(Icon, { name: "shield", size: 14 }),
|
|
1195
|
+
h("span", null, adopting ? t("adopting") : t("adopt"))
|
|
1196
|
+
)
|
|
1197
|
+
)
|
|
1198
|
+
) : h(
|
|
1199
|
+
"div",
|
|
1200
|
+
{ className: "km-managed-body" },
|
|
1201
|
+
h(
|
|
1202
|
+
"div",
|
|
1203
|
+
{ className: "km-managed-toolbar" },
|
|
1204
|
+
h(
|
|
1205
|
+
"div",
|
|
1206
|
+
{ className: "km-managed-summary" },
|
|
1207
|
+
h("span", { className: "km-mono km-muted" }, `${t("secret")}: ${provider.brokerRef ?? "\u2014"}`),
|
|
1208
|
+
provider.baseURL !== null ? h("span", { className: "km-mono km-muted km-truncate" }, provider.baseURL) : null
|
|
1209
|
+
),
|
|
1210
|
+
h(
|
|
1211
|
+
"div",
|
|
1212
|
+
{ className: "km-managed-actions" },
|
|
1213
|
+
h(
|
|
1214
|
+
Button,
|
|
1215
|
+
{ variant: "secondary", size: "small", onClick: () => setAdding((current) => !current), disabled: releasing },
|
|
1216
|
+
h(Icon, { name: "plus", size: 14 }),
|
|
1217
|
+
h("span", null, t("addKey"))
|
|
1218
|
+
),
|
|
1219
|
+
h(
|
|
1220
|
+
Button,
|
|
1221
|
+
{ variant: "ghost", size: "small", onClick: () => setConfirmRelease(true), disabled: releasing },
|
|
1222
|
+
releasing ? t("releasing") : t("release")
|
|
1223
|
+
)
|
|
1224
|
+
)
|
|
1225
|
+
),
|
|
1226
|
+
adding ? h(KeyForm, { provider, onDone: () => setAdding(false), autoFocus: true }) : null,
|
|
1227
|
+
provider.keys.length === 0 ? h("div", { className: "km-empty-keys" }, t("noKeys")) : h("div", { className: "km-keys" }, provider.keys.map((key) => h(KeyRow, { key: key.id, provider, keyRecord: key, now })))
|
|
1228
|
+
),
|
|
1229
|
+
h(
|
|
1230
|
+
"div",
|
|
1231
|
+
{ className: "km-provider-foot" },
|
|
1232
|
+
h("span", { className: "km-muted" }, provider.extra ? `${t("api")}: ${provider.api ?? "\u2014"} \xB7 ${t("models")}: ${provider.models.length}` : null),
|
|
1233
|
+
provider.defaultBaseURL !== null ? h("span", { className: "km-mono km-muted km-truncate" }, provider.defaultBaseURL) : null
|
|
1234
|
+
)
|
|
1235
|
+
) : null,
|
|
1236
|
+
confirmRelease ? h(Modal, {
|
|
1237
|
+
title: t("releaseTitle", { provider: provider.displayName || provider.provider }),
|
|
1238
|
+
onClose: () => setConfirmRelease(false),
|
|
1239
|
+
busy: releasing,
|
|
1240
|
+
footer: [
|
|
1241
|
+
h(Button, { key: "cancel", onClick: () => setConfirmRelease(false), disabled: releasing }, t("cancel")),
|
|
1242
|
+
h(Button, { key: "release", variant: "danger", onClick: release, disabled: releasing }, releasing ? t("releasing") : t("releaseConfirm"))
|
|
1243
|
+
]
|
|
1244
|
+
}, h("p", { className: "km-modal-copy" }, t(provider.createdProfile === true ? "releaseBodyCreated" : "releaseBody"))) : null
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
function SettingsCard() {
|
|
1248
|
+
const runtime = useRuntime();
|
|
1249
|
+
const t = useT();
|
|
1250
|
+
const snapshot = useStore();
|
|
1251
|
+
const state = snapshot.state;
|
|
1252
|
+
const settings = state?.settings ?? null;
|
|
1253
|
+
const [retry, setRetry] = import_react2.default.useState("2");
|
|
1254
|
+
const [base, setBase] = import_react2.default.useState("5");
|
|
1255
|
+
const [grace, setGrace] = import_react2.default.useState("10");
|
|
1256
|
+
const [busy, setBusy] = import_react2.default.useState(false);
|
|
1257
|
+
const [saved, setSaved] = import_react2.default.useState(false);
|
|
1258
|
+
const [error, setError] = import_react2.default.useState(null);
|
|
1259
|
+
const dirty = import_react2.default.useRef(false);
|
|
1260
|
+
import_react2.default.useEffect(() => {
|
|
1261
|
+
if (settings === null || dirty.current) return;
|
|
1262
|
+
setRetry(String(settings.retryCount));
|
|
1263
|
+
setBase(String(cooldownMinutes(settings.baseCooldownMs)));
|
|
1264
|
+
setGrace(String(graceMinutes(settings.recoveryGraceMs)));
|
|
1265
|
+
}, [settings]);
|
|
1266
|
+
function change(setter) {
|
|
1267
|
+
return (event) => {
|
|
1268
|
+
dirty.current = true;
|
|
1269
|
+
setSaved(false);
|
|
1270
|
+
setter(event.target.value);
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
async function save(event) {
|
|
1274
|
+
event.preventDefault();
|
|
1275
|
+
setBusy(true);
|
|
1276
|
+
setError(null);
|
|
1277
|
+
setSaved(false);
|
|
1278
|
+
const result = await runtime.store.call("setSettings", {
|
|
1279
|
+
patch: {
|
|
1280
|
+
retryCount: Number(retry),
|
|
1281
|
+
baseCooldownMs: cooldownMs(Number(base)),
|
|
1282
|
+
recoveryGraceMs: graceMs(Number(grace))
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
setBusy(false);
|
|
1286
|
+
if (!result.ok) {
|
|
1287
|
+
setError(result.error);
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
dirty.current = false;
|
|
1291
|
+
setSaved(true);
|
|
1292
|
+
}
|
|
1293
|
+
return h(
|
|
1294
|
+
"form",
|
|
1295
|
+
{ className: "km-card km-settings", onSubmit: save },
|
|
1296
|
+
h(
|
|
1297
|
+
"div",
|
|
1298
|
+
{ className: "km-settings-head" },
|
|
1299
|
+
h(
|
|
1300
|
+
"div",
|
|
1301
|
+
null,
|
|
1302
|
+
h("h3", { className: "km-settings-title" }, t("settingsTitle")),
|
|
1303
|
+
h("p", { className: "km-settings-intro" }, t("settingsIntro"))
|
|
1304
|
+
),
|
|
1305
|
+
h("span", { className: "km-settings-icon" }, h(Icon, { name: "shield", size: 20 }))
|
|
1306
|
+
),
|
|
1307
|
+
h(
|
|
1308
|
+
"div",
|
|
1309
|
+
{ className: "km-settings-grid" },
|
|
1310
|
+
h(
|
|
1311
|
+
"label",
|
|
1312
|
+
{ className: "km-field" },
|
|
1313
|
+
h("span", { className: "km-field-label" }, t("retryCount")),
|
|
1314
|
+
h(
|
|
1315
|
+
"select",
|
|
1316
|
+
{ className: "km-input", value: retry, onChange: change(setRetry), disabled: busy || state?.writable === false },
|
|
1317
|
+
["1", "2", "3"].map((value) => h("option", { key: value, value }, value))
|
|
1318
|
+
),
|
|
1319
|
+
h("span", { className: "km-field-hint" }, t("retryHint"))
|
|
1320
|
+
),
|
|
1321
|
+
h(
|
|
1322
|
+
"label",
|
|
1323
|
+
{ className: "km-field" },
|
|
1324
|
+
h("span", { className: "km-field-label" }, t("baseCooldown")),
|
|
1325
|
+
h("input", { className: "km-input", type: "number", min: 0.5, step: "any", value: base, onChange: change(setBase), disabled: busy || state?.writable === false }),
|
|
1326
|
+
h("span", { className: "km-field-hint" }, t("baseHint"))
|
|
1327
|
+
),
|
|
1328
|
+
h(
|
|
1329
|
+
"label",
|
|
1330
|
+
{ className: "km-field" },
|
|
1331
|
+
h("span", { className: "km-field-label" }, t("grace")),
|
|
1332
|
+
h("input", { className: "km-input", type: "number", min: 0, step: "any", value: grace, onChange: change(setGrace), disabled: busy || state?.writable === false }),
|
|
1333
|
+
h("span", { className: "km-field-hint" }, t("graceHint"))
|
|
1334
|
+
),
|
|
1335
|
+
h(
|
|
1336
|
+
"div",
|
|
1337
|
+
{ className: "km-field km-field-note" },
|
|
1338
|
+
h(
|
|
1339
|
+
"div",
|
|
1340
|
+
{ className: "km-policy-note" },
|
|
1341
|
+
h("div", { className: "km-policy-title" }, h(Icon, { name: "warning", size: 14 }), t("cap")),
|
|
1342
|
+
h("p", { className: "km-muted" }, t("strategyBody"))
|
|
1343
|
+
)
|
|
1344
|
+
)
|
|
1345
|
+
),
|
|
1346
|
+
error !== null ? h("div", { className: "km-inline-error", role: "alert" }, error) : null,
|
|
1347
|
+
h(
|
|
1348
|
+
"div",
|
|
1349
|
+
{ className: "km-settings-actions" },
|
|
1350
|
+
saved ? h("span", { className: "km-saved" }, h(Icon, { name: "check", size: 14 }), t("saved")) : null,
|
|
1351
|
+
h(
|
|
1352
|
+
Button,
|
|
1353
|
+
{ variant: "primary", type: "submit", disabled: busy || state?.writable === false || snapshot.busy !== null },
|
|
1354
|
+
busy ? h(Icon, { name: "refresh", size: 14, className: "km-spin" }) : null,
|
|
1355
|
+
busy ? t("savingSettings") : t("saveSettings")
|
|
1356
|
+
)
|
|
1357
|
+
)
|
|
1358
|
+
);
|
|
1359
|
+
}
|
|
1360
|
+
function KeysManagerBody() {
|
|
1361
|
+
const runtime = useRuntime();
|
|
1362
|
+
const t = useT();
|
|
1363
|
+
const snapshot = useStore();
|
|
1364
|
+
const state = snapshot.state;
|
|
1365
|
+
const now = snapshot.now;
|
|
1366
|
+
const [query, setQuery] = import_react2.default.useState("");
|
|
1367
|
+
const [showAllAvailable, setShowAllAvailable] = import_react2.default.useState(false);
|
|
1368
|
+
const [expanded, setExpanded] = import_react2.default.useState(() => /* @__PURE__ */ new Set());
|
|
1369
|
+
const loadedRef = import_react2.default.useRef(false);
|
|
1370
|
+
import_react2.default.useEffect(() => {
|
|
1371
|
+
if (loadedRef.current) return;
|
|
1372
|
+
loadedRef.current = true;
|
|
1373
|
+
if (snapshot.status === "idle") void runtime.store.load();
|
|
1374
|
+
}, [runtime, snapshot.status]);
|
|
1375
|
+
const providers = state?.providers ?? [];
|
|
1376
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
1377
|
+
const matches = (provider) => {
|
|
1378
|
+
if (normalizedQuery.length === 0) return true;
|
|
1379
|
+
const haystack = [
|
|
1380
|
+
provider.displayName,
|
|
1381
|
+
provider.provider,
|
|
1382
|
+
provider.extraId,
|
|
1383
|
+
provider.api,
|
|
1384
|
+
provider.baseURL,
|
|
1385
|
+
...provider.env
|
|
1386
|
+
].filter((value) => Boolean(value)).join(" ").toLowerCase();
|
|
1387
|
+
return haystack.includes(normalizedQuery);
|
|
1388
|
+
};
|
|
1389
|
+
const managed = providers.filter((provider) => provider.managed && matches(provider));
|
|
1390
|
+
const available = providers.filter((provider) => !provider.managed && matches(provider));
|
|
1391
|
+
const visibleAvailable = showAllAvailable || normalizedQuery.length > 0 ? available : available.slice(0, 12);
|
|
1392
|
+
function toggle(provider) {
|
|
1393
|
+
setExpanded((current) => {
|
|
1394
|
+
const next = new Set(current);
|
|
1395
|
+
if (next.has(provider)) next.delete(provider);
|
|
1396
|
+
else next.add(provider);
|
|
1397
|
+
return next;
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
const loading = snapshot.status === "loading" || snapshot.status === "idle" && state === null;
|
|
1401
|
+
const failed = snapshot.status === "error" || snapshot.status === "ready" && state === null;
|
|
1402
|
+
return h(
|
|
1403
|
+
"div",
|
|
1404
|
+
{ className: "km-page" },
|
|
1405
|
+
snapshot.error !== null ? h(
|
|
1406
|
+
"div",
|
|
1407
|
+
{ className: "km-banner km-banner-error", role: "alert" },
|
|
1408
|
+
h(Icon, { name: "warning", size: 16 }),
|
|
1409
|
+
h("span", { className: "km-banner-text" }, snapshot.error),
|
|
1410
|
+
h("button", { type: "button", className: "km-banner-close", onClick: () => runtime.store.dismissError(), "aria-label": t("dismiss") }, h(Icon, { name: "close", size: 14 }))
|
|
1411
|
+
) : null,
|
|
1412
|
+
state !== null && state.warnings.length > 0 ? h(
|
|
1413
|
+
"div",
|
|
1414
|
+
{ className: "km-banner km-banner-warn", role: "note" },
|
|
1415
|
+
h(Icon, { name: "warning", size: 16 }),
|
|
1416
|
+
h("div", { className: "km-banner-text" }, state.warnings.map((warning, index) => h("div", { key: index }, warning)))
|
|
1417
|
+
) : null,
|
|
1418
|
+
state !== null && !state.writable ? h(
|
|
1419
|
+
"div",
|
|
1420
|
+
{ className: "km-banner km-banner-warn", role: "note" },
|
|
1421
|
+
h(Icon, { name: "shield", size: 16 }),
|
|
1422
|
+
h("span", { className: "km-banner-text" }, t("writableFalse"))
|
|
1423
|
+
) : null,
|
|
1424
|
+
h(
|
|
1425
|
+
"div",
|
|
1426
|
+
{ className: "km-embedded-head" },
|
|
1427
|
+
h(
|
|
1428
|
+
"div",
|
|
1429
|
+
{ className: "km-summary" },
|
|
1430
|
+
h("div", { className: "km-stat" }, h("strong", null, loading ? "\u2014" : state?.managedCount ?? 0), h("span", null, t("managed"))),
|
|
1431
|
+
h("div", { className: "km-stat" }, h("strong", null, loading ? "\u2014" : state?.keyCount ?? 0), h("span", null, t("keys"))),
|
|
1432
|
+
h("div", { className: "km-stat" }, h("strong", null, loading ? "\u2014" : state?.healthyKeyCount ?? 0), h("span", null, t("healthy"))),
|
|
1433
|
+
h("div", { className: "km-stat" }, h("strong", null, loading ? "\u2014" : state?.coolingKeyCount ?? 0), h("span", null, t("cooling")))
|
|
1434
|
+
),
|
|
1435
|
+
h(
|
|
1436
|
+
"div",
|
|
1437
|
+
{ className: "km-embedded-actions" },
|
|
1438
|
+
h(Button, {
|
|
1439
|
+
variant: "ghost",
|
|
1440
|
+
size: "small",
|
|
1441
|
+
onClick: () => void runtime.store.load(),
|
|
1442
|
+
disabled: snapshot.busy !== null,
|
|
1443
|
+
title: t("refresh")
|
|
1444
|
+
}, h(Icon, { name: "refresh", size: 14 }), t("refresh"))
|
|
1445
|
+
)
|
|
1446
|
+
),
|
|
1447
|
+
h(
|
|
1448
|
+
"div",
|
|
1449
|
+
{ className: "km-search" },
|
|
1450
|
+
h(Icon, { name: "search", size: 17, className: "km-search-icon" }),
|
|
1451
|
+
h("input", {
|
|
1452
|
+
className: "km-search-input",
|
|
1453
|
+
value: query,
|
|
1454
|
+
onChange: (event) => setQuery(event.target.value),
|
|
1455
|
+
placeholder: t("search"),
|
|
1456
|
+
type: "search",
|
|
1457
|
+
autoFocus: true,
|
|
1458
|
+
"aria-label": t("search")
|
|
1459
|
+
}),
|
|
1460
|
+
query.length > 0 ? h("button", { type: "button", className: "km-search-clear", onClick: () => setQuery(""), "aria-label": t("reset") }, h(Icon, { name: "close", size: 14 })) : null
|
|
1461
|
+
),
|
|
1462
|
+
loading ? h("div", { className: "km-loading" }, h(Icon, { name: "refresh", size: 18, className: "km-spin" }), t("loading")) : null,
|
|
1463
|
+
failed ? h(
|
|
1464
|
+
"div",
|
|
1465
|
+
{ className: "km-load-failure" },
|
|
1466
|
+
h("div", { className: "km-empty-title" }, t("loadError")),
|
|
1467
|
+
h(Button, { variant: "primary", onClick: () => void runtime.store.load() }, t("reload"))
|
|
1468
|
+
) : null,
|
|
1469
|
+
!loading && !failed ? h(
|
|
1470
|
+
"section",
|
|
1471
|
+
{ className: "km-section" },
|
|
1472
|
+
h(
|
|
1473
|
+
"div",
|
|
1474
|
+
{ className: "km-section-head" },
|
|
1475
|
+
h("h2", { className: "km-section-title" }, t("managed")),
|
|
1476
|
+
h("span", { className: "km-section-count" }, managed.length)
|
|
1477
|
+
),
|
|
1478
|
+
managed.length === 0 ? h("div", { className: "km-empty" }, h(Icon, { name: "key", size: 20 }), h("span", null, t("managedEmpty"))) : h("div", { className: "km-provider-list" }, managed.map((provider) => h(ProviderCard, {
|
|
1479
|
+
key: provider.provider,
|
|
1480
|
+
provider,
|
|
1481
|
+
now,
|
|
1482
|
+
expanded: expanded.has(provider.provider),
|
|
1483
|
+
onToggle: () => toggle(provider.provider)
|
|
1484
|
+
})))
|
|
1485
|
+
) : null,
|
|
1486
|
+
!loading && !failed ? h(
|
|
1487
|
+
"section",
|
|
1488
|
+
{ className: "km-section" },
|
|
1489
|
+
h(
|
|
1490
|
+
"div",
|
|
1491
|
+
{ className: "km-section-head" },
|
|
1492
|
+
h("h2", { className: "km-section-title" }, t("available")),
|
|
1493
|
+
h("span", { className: "km-section-count" }, available.length)
|
|
1494
|
+
),
|
|
1495
|
+
available.length === 0 ? h("div", { className: "km-empty" }, h(Icon, { name: "search", size: 20 }), h("span", null, normalizedQuery.length > 0 ? t("noSearch") : t("availableEmpty"))) : h("div", { className: "km-provider-list" }, visibleAvailable.map((provider) => h(ProviderCard, {
|
|
1496
|
+
key: provider.provider,
|
|
1497
|
+
provider,
|
|
1498
|
+
now,
|
|
1499
|
+
expanded: expanded.has(provider.provider),
|
|
1500
|
+
onToggle: () => toggle(provider.provider)
|
|
1501
|
+
}))),
|
|
1502
|
+
available.length > visibleAvailable.length ? h(
|
|
1503
|
+
"div",
|
|
1504
|
+
{ className: "km-show-more" },
|
|
1505
|
+
h(Button, { variant: "ghost", size: "small", onClick: () => setShowAllAvailable(true) }, t("showAll", { n: available.length }))
|
|
1506
|
+
) : showAllAvailable && available.length > 12 ? h(
|
|
1507
|
+
"div",
|
|
1508
|
+
{ className: "km-show-more" },
|
|
1509
|
+
h(Button, { variant: "ghost", size: "small", onClick: () => setShowAllAvailable(false) }, t("showLess"))
|
|
1510
|
+
) : null
|
|
1511
|
+
) : null,
|
|
1512
|
+
!loading && !failed ? h("section", { className: "km-section" }, h(SettingsCard)) : null,
|
|
1513
|
+
h(
|
|
1514
|
+
"footer",
|
|
1515
|
+
{ className: "km-footer" },
|
|
1516
|
+
h(Icon, { name: "shield", size: 14 }),
|
|
1517
|
+
h("span", null, t("storageNote"))
|
|
1518
|
+
)
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
function KeysManagerCard({ view }) {
|
|
1522
|
+
const t = useT();
|
|
1523
|
+
const snapshot = useStore();
|
|
1524
|
+
if (view === "summary") {
|
|
1525
|
+
const state = snapshot.state;
|
|
1526
|
+
if (state === null) return h("span", { className: "km-summary-line" }, snapshot.status === "error" ? t("loadError") : t("loading"));
|
|
1527
|
+
if (state.managedCount === 0) return h("span", { className: "km-summary-line" }, t("summaryEmpty"));
|
|
1528
|
+
return h("span", { className: "km-summary-line" }, t("summaryText", { providers: state.managedCount, keys: state.keyCount }));
|
|
1529
|
+
}
|
|
1530
|
+
return h(KeysManagerBody);
|
|
1531
|
+
}
|
|
1532
|
+
function ManagedProviderBadge(props) {
|
|
1533
|
+
const t = useT();
|
|
1534
|
+
const snapshot = useStore();
|
|
1535
|
+
const state = snapshot.state;
|
|
1536
|
+
const providerId = props.provider?.provider;
|
|
1537
|
+
if (state === null || providerId === void 0) return null;
|
|
1538
|
+
const managed = state.providers.find((provider) => provider.provider === providerId && provider.managed);
|
|
1539
|
+
if (managed === void 0) return null;
|
|
1540
|
+
const broken = managed.bindingHealthy === false;
|
|
1541
|
+
return h(
|
|
1542
|
+
"div",
|
|
1543
|
+
{ className: cx("km-models-note", broken && "km-models-note-warn"), role: "note" },
|
|
1544
|
+
h("span", { className: cx("km-dot", broken ? "km-dot-warn" : "km-dot-success") }),
|
|
1545
|
+
h("span", { className: "km-models-note-text" }, t("modelsBadge", { n: managed.keyCount })),
|
|
1546
|
+
h("span", { className: "km-models-note-hint" }, broken ? t("bindingBroken") : t("modelsHint"))
|
|
1547
|
+
);
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
// src/client/index.ts
|
|
1551
|
+
var inject = ["slots", "locale", "connection"];
|
|
1552
|
+
var NS = "dsh-keys-manager";
|
|
1553
|
+
function apply(ctx) {
|
|
1554
|
+
ctx.effect(() => ctx.locale.register(NS, LOCALE_DICTS), "keys-manager: dictionaries");
|
|
1555
|
+
const store = createStore(ctx);
|
|
1556
|
+
const runtime = { ctx, store };
|
|
1557
|
+
ctx.effect(() => {
|
|
1558
|
+
void store.load();
|
|
1559
|
+
let disposed = false;
|
|
1560
|
+
const retry = async () => {
|
|
1561
|
+
for (let attempt = 0; attempt < 4 && !disposed; attempt += 1) {
|
|
1562
|
+
if (store.getSnapshot().status === "ready") return;
|
|
1563
|
+
await new Promise((resolve) => setTimeout(resolve, 600));
|
|
1564
|
+
if (disposed) return;
|
|
1565
|
+
await store.load();
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
void retry();
|
|
1569
|
+
const off = ctx.on("connection/reset", () => {
|
|
1570
|
+
void store.load();
|
|
1571
|
+
});
|
|
1572
|
+
const timer = setInterval(() => store.tick(), 3e4);
|
|
1573
|
+
return () => {
|
|
1574
|
+
disposed = true;
|
|
1575
|
+
off();
|
|
1576
|
+
clearInterval(timer);
|
|
1577
|
+
};
|
|
1578
|
+
}, "keys-manager: lifecycle");
|
|
1579
|
+
ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
|
|
1580
|
+
name: "plugins.bundle.config",
|
|
1581
|
+
key: "dsh-keys-manager"
|
|
1582
|
+
}, wrapComponent(KeysManagerCard, runtime)));
|
|
1583
|
+
ctx.slots.inject("settings.models.provider-card", () => {
|
|
1584
|
+
const disposers = [
|
|
1585
|
+
ctx.slots.register({ name: "settings.models.provider-card", key: "llm-pi-ai" }, wrapComponent(ManagedProviderBadge, runtime)),
|
|
1586
|
+
ctx.slots.register({ name: "settings.models.provider-card", key: "llm-deepseek-api-key" }, wrapComponent(ManagedProviderBadge, runtime)),
|
|
1587
|
+
ctx.slots.register({ name: "settings.models.provider-card", key: "llm-deepseek" }, wrapComponent(ManagedProviderBadge, runtime))
|
|
1588
|
+
];
|
|
1589
|
+
return () => {
|
|
1590
|
+
for (const dispose of disposers) dispose();
|
|
1591
|
+
};
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
return module.exports; } });
|