dsh-open-model 1.0.0 → 1.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/README.md +68 -16
- package/dist/client.js +2137 -0
- package/dist/index.js +27974 -0
- package/models.json +169 -0
- package/native/credential-key +0 -0
- package/notices/LICENSE +54 -0
- package/notices/THIRD_PARTY_NOTICES.md +424 -0
- package/package.json +41 -9
- package/catalog.js +0 -182
- package/client.js +0 -709
- package/index.js +0 -96
- package/model-availability.js +0 -99
- package/model-management.js +0 -111
- package/stream.js +0 -382
- package/updates.js +0 -141
package/dist/client.js
ADDED
|
@@ -0,0 +1,2137 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "dsh-open-model", factory: (require) => { const module = { exports: {} }; const exports = module.exports;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// client.js
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
apply: () => apply,
|
|
24
|
+
inject: () => inject
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(client_exports);
|
|
27
|
+
var import_react8 = require("react");
|
|
28
|
+
var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
29
|
+
|
|
30
|
+
// chatgpt/client/workspace.jsx
|
|
31
|
+
var import_react6 = require("react");
|
|
32
|
+
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
33
|
+
|
|
34
|
+
// chatgpt/shared/identity.js
|
|
35
|
+
var providerId = "dsh-open-model-chatgpt";
|
|
36
|
+
var apiBase = "/api/dsh-open-model/chatgpt";
|
|
37
|
+
|
|
38
|
+
// chatgpt/client/connection.js
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var connectionStatuses = ["disconnected", "connecting", "connected", "reauth_required"];
|
|
41
|
+
function validFeatures(features) {
|
|
42
|
+
return typeof features?.webSearch === "boolean" && typeof features.jsonSchema === "string";
|
|
43
|
+
}
|
|
44
|
+
async function request(action, signal, payload, method = "GET") {
|
|
45
|
+
const response = await fetch(`${apiBase}/${action}`, {
|
|
46
|
+
method,
|
|
47
|
+
headers: { accept: "application/json", ...payload === void 0 ? {} : { "content-type": "application/json" } },
|
|
48
|
+
...payload === void 0 ? {} : { body: JSON.stringify(payload) },
|
|
49
|
+
cache: "no-store",
|
|
50
|
+
signal
|
|
51
|
+
});
|
|
52
|
+
const data = await response.json().catch(() => void 0);
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const failure = new Error(typeof data?.error?.message === "string" ? data.error.message : "");
|
|
55
|
+
failure.code = data?.error?.code;
|
|
56
|
+
throw failure;
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
async function requestConnection(action, signal, payload) {
|
|
61
|
+
const data = await request(action, signal, payload, action === "status" ? "GET" : "POST");
|
|
62
|
+
if (!connectionStatuses.includes(data?.status) || typeof data.available !== "boolean" || typeof data.sharing !== "boolean" || action === "features" && !validFeatures(data.features)) {
|
|
63
|
+
throw new Error();
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
function isSignIn(action) {
|
|
68
|
+
return action === "sign-in" || action === "enable" || action === "add-account";
|
|
69
|
+
}
|
|
70
|
+
function isAccountDialogAction(action) {
|
|
71
|
+
return action === "add-account" || action === "cancel-add";
|
|
72
|
+
}
|
|
73
|
+
function useConnection() {
|
|
74
|
+
const [connection, setConnection] = (0, import_react.useState)(null);
|
|
75
|
+
const [pending, setPending] = (0, import_react.useState)(null);
|
|
76
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
77
|
+
const lifetime = (0, import_react.useRef)(null);
|
|
78
|
+
const pendingAction = (0, import_react.useRef)(null);
|
|
79
|
+
const refreshSignal = (0, import_react.useRef)(null);
|
|
80
|
+
const revision = (0, import_react.useRef)(0);
|
|
81
|
+
const refresh = (0, import_react.useCallback)(async (clearError = true) => {
|
|
82
|
+
const signal = lifetime.current?.signal;
|
|
83
|
+
if (!signal || refreshSignal.current === signal || pendingAction.current) return;
|
|
84
|
+
const update = revision.current;
|
|
85
|
+
refreshSignal.current = signal;
|
|
86
|
+
try {
|
|
87
|
+
const next = await requestConnection("status", signal);
|
|
88
|
+
if (signal.aborted || revision.current !== update) return;
|
|
89
|
+
setConnection(next);
|
|
90
|
+
if (clearError) setError((previous) => previous?.action === "status" ? null : previous);
|
|
91
|
+
} catch (failure) {
|
|
92
|
+
if (!signal.aborted && revision.current === update) {
|
|
93
|
+
setError((previous) => previous?.action && previous.action !== "status" ? previous : { action: "status", message: failure.message });
|
|
94
|
+
}
|
|
95
|
+
} finally {
|
|
96
|
+
if (refreshSignal.current === signal) refreshSignal.current = null;
|
|
97
|
+
}
|
|
98
|
+
}, []);
|
|
99
|
+
(0, import_react.useEffect)(() => {
|
|
100
|
+
const controller = new AbortController();
|
|
101
|
+
lifetime.current = controller;
|
|
102
|
+
const onFocus = () => {
|
|
103
|
+
void refresh();
|
|
104
|
+
};
|
|
105
|
+
window.addEventListener("focus", onFocus);
|
|
106
|
+
void refresh();
|
|
107
|
+
return () => {
|
|
108
|
+
window.removeEventListener("focus", onFocus);
|
|
109
|
+
controller.abort();
|
|
110
|
+
lifetime.current = null;
|
|
111
|
+
pendingAction.current = null;
|
|
112
|
+
};
|
|
113
|
+
}, [refresh]);
|
|
114
|
+
const polling = connection?.status === "connecting" || connection?.addingAccount;
|
|
115
|
+
(0, import_react.useEffect)(() => {
|
|
116
|
+
if (!polling) return;
|
|
117
|
+
const timer = window.setInterval(() => {
|
|
118
|
+
void refresh(false);
|
|
119
|
+
}, 1e3);
|
|
120
|
+
return () => {
|
|
121
|
+
window.clearInterval(timer);
|
|
122
|
+
};
|
|
123
|
+
}, [polling, refresh]);
|
|
124
|
+
async function run(action, payload) {
|
|
125
|
+
const signal = lifetime.current?.signal;
|
|
126
|
+
const previous = pendingAction.current;
|
|
127
|
+
const route = action === "add-account" ? "sign-in" : action === "cancel-add" ? "cancel" : action;
|
|
128
|
+
if (!signal || previous && !(route === "cancel" && isSignIn(previous))) return;
|
|
129
|
+
const update = ++revision.current;
|
|
130
|
+
pendingAction.current = action;
|
|
131
|
+
setPending(action);
|
|
132
|
+
setError(null);
|
|
133
|
+
let failed = false;
|
|
134
|
+
try {
|
|
135
|
+
const next = await requestConnection(route, signal, payload);
|
|
136
|
+
if (!signal.aborted && revision.current === update) {
|
|
137
|
+
setConnection(next);
|
|
138
|
+
return next;
|
|
139
|
+
}
|
|
140
|
+
} catch (failure) {
|
|
141
|
+
failed = true;
|
|
142
|
+
if (!signal.aborted && revision.current === update && !(action === "add-account" && failure.code === "cancelled")) {
|
|
143
|
+
setError({ action, message: failure.message, code: failure.code });
|
|
144
|
+
}
|
|
145
|
+
} finally {
|
|
146
|
+
if (!signal.aborted && revision.current === update) {
|
|
147
|
+
pendingAction.current = null;
|
|
148
|
+
setPending(null);
|
|
149
|
+
if (failed) void refresh(false);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return { connection, pending, error, dismissError: () => setError(null), refresh, run };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// chatgpt/client/locales.js
|
|
157
|
+
var dictionaries = {
|
|
158
|
+
zh: {
|
|
159
|
+
webSearch: "\u7F51\u9875\u641C\u7D22",
|
|
160
|
+
searchHelp: "\u5141\u8BB8\u6A21\u578B\u5728\u6B64\u5BF9\u8BDD\u4E2D\u6309\u9700\u641C\u7D22\u7F51\u9875",
|
|
161
|
+
searchUnavailable: "\u5F53\u524D\u6A21\u578B\u6CA1\u6709\u53EF\u7528\u7684\u641C\u7D22\u670D\u52A1",
|
|
162
|
+
searchLoadFailed: "\u65E0\u6CD5\u8BFB\u53D6\u7F51\u9875\u641C\u7D22\u8BBE\u7F6E\u3002",
|
|
163
|
+
searchRecheck: "\u91CD\u65B0\u68C0\u6D4B",
|
|
164
|
+
searchRetry: "\u91CD\u8BD5\u8BFB\u53D6\u7F51\u9875\u641C\u7D22\u8BBE\u7F6E",
|
|
165
|
+
saveFailed: "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
166
|
+
legacyDefaults: "\u65E7\u7248\u7F51\u9875\u641C\u7D22\u9ED8\u8BA4\u8BBE\u7F6E",
|
|
167
|
+
legacyHint: "\u65E7\u7248\u5DF2\u9ED8\u8BA4\u5F00\u542F\u7F51\u9875\u641C\u7D22\u3002\u8FD8\u539F\u540E\uFF0C\u5C1A\u672A\u5355\u72EC\u8BBE\u7F6E\u7684\u5BF9\u8BDD\u5C06\u9ED8\u8BA4\u5173\u95ED\u7F51\u9875\u641C\u7D22\u3002",
|
|
168
|
+
resetDefaults: "\u8FD8\u539F\u9ED8\u8BA4\u8BBE\u7F6E",
|
|
169
|
+
accountOptions: "{label} \u7684\u66F4\u591A\u64CD\u4F5C",
|
|
170
|
+
switchAccount: "\u5207\u6362",
|
|
171
|
+
switchToAccount: "\u5207\u6362\u5230 {label}",
|
|
172
|
+
identityFallback: "ChatGPT \u8D26\u53F7",
|
|
173
|
+
planModels: "\u5957\u9910\u6A21\u578B",
|
|
174
|
+
planHint: "\u53EF\u7528\u6A21\u578B\u548C\u4F7F\u7528\u989D\u5EA6\u53D6\u51B3\u4E8E\u5F53\u524D ChatGPT \u8D26\u53F7\u7684\u5957\u9910\u3002",
|
|
175
|
+
connectTitle: "\u8FDE\u63A5\u4F60\u7684 ChatGPT \u8D26\u53F7",
|
|
176
|
+
subtitle: "\u8BA9 DSH \u76F4\u63A5\u4F7F\u7528\u4F60\u7684 ChatGPT \u5957\u9910\u989D\u5EA6\u3002",
|
|
177
|
+
desktopTitle: "\u5728\u684C\u9762\u7AEF\u4F7F\u7528 ChatGPT \u5957\u9910",
|
|
178
|
+
connectionFailed: "\u65E0\u6CD5\u8BFB\u53D6\u8D26\u53F7\u72B6\u6001",
|
|
179
|
+
browserTitle: "\u5728\u6D4F\u89C8\u5668\u4E2D\u7EE7\u7EED",
|
|
180
|
+
chooseSignedIn: "\u9009\u62E9\u5DF2\u767B\u5F55\u8D26\u53F7",
|
|
181
|
+
authorizeHint: "\u8BF7\u5728 3 \u5206\u949F\u5185\u5B8C\u6210\u6D4F\u89C8\u5668\u4E2D\u7684\u6388\u6743\u3002\u5B8C\u6210\u540E\u5C06\u5207\u6362\u5230\u8BE5\u8D26\u53F7\u3002",
|
|
182
|
+
authorizationFailed: "\u6388\u6743\u672A\u5B8C\u6210",
|
|
183
|
+
close: "\u5173\u95ED",
|
|
184
|
+
reconnectAccount: "\u91CD\u65B0\u8FDE\u63A5",
|
|
185
|
+
pendingAccount: "\u5F85\u5B8C\u6210\u6388\u6743",
|
|
186
|
+
resumeAccount: "\u7EE7\u7EED\u6388\u6743",
|
|
187
|
+
signedOut: "\u5DF2\u9000\u51FA",
|
|
188
|
+
expiredAccount: "\u9700\u8981\u91CD\u65B0\u767B\u5F55",
|
|
189
|
+
noConsent: "\u5957\u9910\u5C1A\u672A\u6388\u6743",
|
|
190
|
+
differentAccount: "\u4F60\u9009\u62E9\u4E86\u53E6\u4E00\u4E2A\u8D26\u53F7\u3002\u518D\u6B21\u70B9\u51FB\u767B\u5F55\uFF0C\u5373\u53EF\u7528\u6240\u9009\u8D26\u53F7\u5EFA\u7ACB\u65B0\u8FDE\u63A5\u3002",
|
|
191
|
+
manageAccounts: "\u7BA1\u7406\u8D26\u53F7",
|
|
192
|
+
activeAccount: "\u5F53\u524D\u8D26\u53F7",
|
|
193
|
+
newAccount: "\u6DFB\u52A0\u8D26\u53F7",
|
|
194
|
+
loading: "\u6B63\u5728\u8BFB\u53D6\u8FDE\u63A5\u72B6\u6001\u2026",
|
|
195
|
+
unavailable: "\u8BF7\u5728\u672C\u673A\u7684 macOS \u6216 Windows \u7248 DeepSeek Harness \u4E2D\u4F7F\u7528 ChatGPT \u5957\u9910\u3002",
|
|
196
|
+
connecting: "\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u5B8C\u6210\u6388\u6743\uFF0C\u7136\u540E\u56DE\u5230 DSH\u3002",
|
|
197
|
+
needsConsent: "\u8BF7\u6388\u6743\u4F7F\u7528 ChatGPT \u5957\u9910\u989D\u5EA6\u3002",
|
|
198
|
+
signIn: "\u4F7F\u7528 ChatGPT \u767B\u5F55",
|
|
199
|
+
enable: "\u6388\u6743\u4F7F\u7528\u5957\u9910\u989D\u5EA6",
|
|
200
|
+
cancel: "\u53D6\u6D88\u6388\u6743\u6D41\u7A0B",
|
|
201
|
+
signOut: "\u9000\u51FA\u767B\u5F55",
|
|
202
|
+
retry: "\u91CD\u65B0\u8BFB\u53D6\u72B6\u6001",
|
|
203
|
+
requestFailed: "\u65E0\u6CD5\u8FDE\u63A5\u672C\u5730 ChatGPT \u5957\u9910\u670D\u52A1\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
204
|
+
modelsLoading: "\u6B63\u5728\u8BFB\u53D6\u6A21\u578B\u5217\u8868\u2026",
|
|
205
|
+
modelsEmpty: "\u5C1A\u672A\u914D\u7F6E ChatGPT \u5957\u9910\u6A21\u578B\u3002",
|
|
206
|
+
modelsFailed: "\u65E0\u6CD5\u8BFB\u53D6\u6A21\u578B\u5217\u8868\u3002",
|
|
207
|
+
refreshModels: "\u5237\u65B0\u6A21\u578B\u5217\u8868"
|
|
208
|
+
},
|
|
209
|
+
en: {
|
|
210
|
+
webSearch: "Web search",
|
|
211
|
+
searchHelp: "Allow the model to search the web when needed in this conversation",
|
|
212
|
+
searchUnavailable: "No search service is available for this model",
|
|
213
|
+
searchLoadFailed: "Could not load web search settings.",
|
|
214
|
+
searchRecheck: "Check again",
|
|
215
|
+
searchRetry: "Retry loading web search",
|
|
216
|
+
saveFailed: "Couldn\u2019t save. Try again.",
|
|
217
|
+
legacyDefaults: "Legacy web search default",
|
|
218
|
+
legacyHint: "Turn web search off for conversations that still use your previous default.",
|
|
219
|
+
resetDefaults: "Restore defaults",
|
|
220
|
+
accountOptions: "More options for {label}",
|
|
221
|
+
switchAccount: "Switch",
|
|
222
|
+
switchToAccount: "Switch to {label}",
|
|
223
|
+
identityFallback: "ChatGPT account",
|
|
224
|
+
planModels: "Plan models",
|
|
225
|
+
planHint: "Model access and usage limits depend on the current account\u2019s ChatGPT plan.",
|
|
226
|
+
connectTitle: "Connect your ChatGPT account",
|
|
227
|
+
subtitle: "Use your ChatGPT plan allowance directly in DSH.",
|
|
228
|
+
desktopTitle: "Use your ChatGPT plan on desktop",
|
|
229
|
+
connectionFailed: "Couldn\u2019t load your account",
|
|
230
|
+
browserTitle: "Continue in your browser",
|
|
231
|
+
chooseSignedIn: "Choose a signed-in account",
|
|
232
|
+
authorizeHint: "Complete authorization in your browser within 3 minutes to switch to this account.",
|
|
233
|
+
authorizationFailed: "Authorization incomplete",
|
|
234
|
+
close: "Close",
|
|
235
|
+
reconnectAccount: "Reconnect",
|
|
236
|
+
pendingAccount: "Authorization pending",
|
|
237
|
+
resumeAccount: "Continue sign-in",
|
|
238
|
+
signedOut: "Signed out",
|
|
239
|
+
expiredAccount: "Sign in again",
|
|
240
|
+
noConsent: "Plan access not granted",
|
|
241
|
+
differentAccount: "You chose a different account. Select Continue with ChatGPT again to connect it.",
|
|
242
|
+
manageAccounts: "Manage accounts",
|
|
243
|
+
activeAccount: "Active account",
|
|
244
|
+
newAccount: "Add account",
|
|
245
|
+
loading: "Checking the connection\u2026",
|
|
246
|
+
unavailable: "Use your ChatGPT plan in a local DeepSeek Harness instance on macOS or Windows.",
|
|
247
|
+
connecting: "Finish authorizing in your browser, then return to DSH.",
|
|
248
|
+
needsConsent: "Authorize access to your ChatGPT plan usage.",
|
|
249
|
+
signIn: "Continue with ChatGPT",
|
|
250
|
+
enable: "Authorize plan usage",
|
|
251
|
+
cancel: "Cancel authorization",
|
|
252
|
+
signOut: "Sign out",
|
|
253
|
+
retry: "Check connection again",
|
|
254
|
+
requestFailed: "Could not reach the local ChatGPT plan service. Try again.",
|
|
255
|
+
modelsLoading: "Loading the model list\u2026",
|
|
256
|
+
modelsEmpty: "No ChatGPT plan models are configured.",
|
|
257
|
+
modelsFailed: "Could not load the model list.",
|
|
258
|
+
refreshModels: "Reload models"
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
function chatLanguage(language, ctx) {
|
|
262
|
+
const tag = language || ctx?.locale?.getSnapshot?.().active || globalThis.document?.documentElement.lang || "zh";
|
|
263
|
+
return tag.toLowerCase().startsWith("en") ? "en" : "zh";
|
|
264
|
+
}
|
|
265
|
+
function translate(language) {
|
|
266
|
+
const messages2 = dictionaries[language] ?? dictionaries.zh;
|
|
267
|
+
return (key, values = {}) => (messages2[key] ?? dictionaries.zh[key] ?? key).replace(/\{(\w+)\}/g, (match, name) => values[name] ?? match);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// model-list.jsx
|
|
271
|
+
var import_react2 = require("react");
|
|
272
|
+
|
|
273
|
+
// model-list.css
|
|
274
|
+
var model_list_default = ".dsh-model-hub-models {\n --catalog-text: var(--dsw-alias-label-primary, CanvasText);\n --catalog-muted: var(--dsw-alias-label-secondary, color-mix(in srgb, CanvasText 68%, Canvas));\n --catalog-line: var(--dsw-alias-border-l2, color-mix(in srgb, currentColor 12%, transparent));\n --catalog-surface: var(--dsw-alias-bg-layer-1, Canvas);\n --catalog-hover: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, CanvasText 5%, Canvas));\n min-width: 0;\n margin-block-start: 20px;\n color: var(--catalog-text);\n container: dsh-model-list / inline-size;\n}\n.dsh-model-hub-toolbar { display: flex; gap: 8px; align-items: stretch; }\n.dsh-model-hub-search, .dsh-model-hub-filter select {\n box-sizing: border-box; height: 38px; border: 1px solid var(--catalog-line); border-radius: 9px;\n background: var(--catalog-surface); color: var(--catalog-text); font: inherit; font-size: 13px;\n}\n.dsh-model-hub-search { display: flex; flex: 1; min-width: 0; gap: 9px; align-items: center; padding-inline: 11px 5px; }\n.dsh-model-hub-search > svg { flex: none; color: var(--catalog-muted); }\n.dsh-model-hub-search input {\n flex: 1; min-width: 0; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0;\n background: transparent; color: inherit; font: inherit; outline: none; appearance: none;\n}\n.dsh-model-hub-search input::placeholder { color: var(--catalog-muted); opacity: 1; }\n.dsh-model-hub-search input::-webkit-search-cancel-button { appearance: none; }\n.dsh-model-hub-search:focus-within, .dsh-model-hub-filter select:focus-visible {\n outline: 2px solid var(--catalog-text); outline-offset: 2px;\n}\n.dsh-model-hub-clear {\n display: grid; flex: none; place-items: center; width: 28px; height: 28px; padding: 0; border: 0;\n border-radius: 6px; background: transparent; color: var(--catalog-muted); cursor: pointer;\n}\n.dsh-model-hub-clear:hover { color: var(--catalog-text); background: var(--catalog-hover); }\n.dsh-model-hub-clear:focus-visible, .dsh-model-hub-empty button:focus-visible { outline: 2px solid var(--catalog-text); }\n.dsh-model-hub-filter { position: relative; flex: none; }\n.dsh-model-hub-filter select { width: 100%; padding-inline: 12px 30px; appearance: none; cursor: pointer; }\n.dsh-model-hub-filter::after {\n content: ''; position: absolute; inset-inline-end: 13px; top: 50%; width: 5px; height: 5px;\n border: solid var(--catalog-muted); border-width: 0 1.5px 1.5px 0; transform: translateY(-75%) rotate(45deg); pointer-events: none;\n}\n.dsh-model-hub-filter select:hover { background: var(--catalog-hover); }\nbody[data-ds-dark-theme] .dsh-model-hub-filter select { color-scheme: dark; }\n.dsh-model-hub-columns {\n display: flex; align-items: center; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap;\n padding: 17px 0 8px; color: var(--catalog-muted); font-size: 12px; line-height: 1.4;\n}\n.dsh-model-hub-columns [role=status] { margin-inline-start: auto; font-variant-numeric: tabular-nums; }\n.dsh-model-hub-list { margin: 0; padding: 0; list-style: none; border-block-start: 1px solid var(--catalog-line); }\n.dsh-model-hub-row {\n display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 16px;\n box-sizing: border-box; min-height: 64px; margin: 0; padding: 12px 0; border-block-end: 1px solid var(--catalog-line);\n}\n.dsh-model-hub-row-heading { display: flex; align-items: baseline; gap: 4px 8px; flex-wrap: wrap; }\n.dsh-model-hub-row-name { display: block; font-size: 14px; font-weight: 550; line-height: 1.45; overflow-wrap: anywhere; }\n.dsh-model-hub-row[aria-disabled=true] .dsh-model-hub-row-name,\n.dsh-model-hub-unavailable { color: var(--catalog-muted); }\n.dsh-model-hub-unavailable { font-size: 12px; line-height: 1.45; }\n.dsh-model-hub-row-id {\n display: block; margin-block-start: 2px; color: var(--catalog-muted);\n font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere;\n}\n.dsh-model-hub-empty { padding: 28px 12px; border-block: 1px solid var(--catalog-line); text-align: center; }\n.dsh-model-hub-empty p { margin: 0; color: var(--catalog-muted); font-size: 14px; }\n.dsh-model-hub-empty button {\n margin-block-start: 6px; padding: 4px; border: 0; border-radius: 4px; background: transparent;\n color: var(--catalog-text); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;\n}\n@container dsh-model-list (max-width: 320px) {\n .dsh-model-hub-toolbar { flex-wrap: wrap; }\n .dsh-model-hub-search { flex: 1 1 190px; }\n .dsh-model-hub-row { column-gap: 10px; }\n}\n@media (forced-colors: active) {\n .dsh-model-hub-filter select { appearance: auto; padding-inline: 6px; }\n .dsh-model-hub-filter::after { display: none; }\n}\n";
|
|
275
|
+
|
|
276
|
+
// model-list.jsx
|
|
277
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
278
|
+
var copy = {
|
|
279
|
+
zh: {
|
|
280
|
+
search: "\u6309\u540D\u79F0\u6216\u6A21\u578B ID \u641C\u7D22",
|
|
281
|
+
clear: "\u6E05\u9664\u641C\u7D22",
|
|
282
|
+
filter: "\u6309\u6A21\u578B\u663E\u793A\u72B6\u6001\u7B5B\u9009",
|
|
283
|
+
all: "\u5168\u90E8\u6A21\u578B",
|
|
284
|
+
enabled: "\u5DF2\u5F00\u542F",
|
|
285
|
+
hidden: "\u5DF2\u9690\u85CF",
|
|
286
|
+
unavailable: "\u4E0D\u53EF\u7528",
|
|
287
|
+
name: "\u6A21\u578B\u540D\u79F0",
|
|
288
|
+
count: (enabled, total) => `\u5DF2\u5F00\u542F ${enabled} / ${total}`,
|
|
289
|
+
matches: (count) => `${count} \u4E2A\u7ED3\u679C`,
|
|
290
|
+
noMatch: "\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u6A21\u578B",
|
|
291
|
+
noneEnabled: "\u6CA1\u6709\u5DF2\u5F00\u542F\u7684\u6A21\u578B",
|
|
292
|
+
noneHidden: "\u6CA1\u6709\u5DF2\u9690\u85CF\u7684\u6A21\u578B",
|
|
293
|
+
noneUnavailable: "\u6CA1\u6709\u4E0D\u53EF\u7528\u7684\u6A21\u578B",
|
|
294
|
+
empty: "\u6682\u65E0\u6A21\u578B",
|
|
295
|
+
showAll: "\u67E5\u770B\u5168\u90E8\u6A21\u578B",
|
|
296
|
+
reset: "\u6E05\u9664\u641C\u7D22\u548C\u7B5B\u9009"
|
|
297
|
+
},
|
|
298
|
+
en: {
|
|
299
|
+
search: "Search by name or model ID",
|
|
300
|
+
clear: "Clear search",
|
|
301
|
+
filter: "Filter by model visibility",
|
|
302
|
+
all: "All models",
|
|
303
|
+
enabled: "Enabled",
|
|
304
|
+
hidden: "Hidden",
|
|
305
|
+
unavailable: "Unavailable",
|
|
306
|
+
name: "Model name",
|
|
307
|
+
count: (enabled, total) => `${enabled} of ${total} enabled`,
|
|
308
|
+
matches: (count) => `${count} ${count === 1 ? "result" : "results"}`,
|
|
309
|
+
noMatch: "No matching models",
|
|
310
|
+
noneEnabled: "No enabled models",
|
|
311
|
+
noneHidden: "No hidden models",
|
|
312
|
+
noneUnavailable: "No unavailable models",
|
|
313
|
+
empty: "No models available",
|
|
314
|
+
showAll: "Show all models",
|
|
315
|
+
reset: "Clear search and filter"
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
function normalize(text) {
|
|
319
|
+
return text.normalize("NFKC").trim().toLowerCase();
|
|
320
|
+
}
|
|
321
|
+
function ModelList({ label, labelledBy, language, models, renderRow, headerActions, children }) {
|
|
322
|
+
const words = copy[language] ?? copy.zh;
|
|
323
|
+
const [query, setQuery] = (0, import_react2.useState)("");
|
|
324
|
+
const [filter, setFilter] = (0, import_react2.useState)("all");
|
|
325
|
+
const searchRef = (0, import_react2.useRef)(null);
|
|
326
|
+
const filterRef = (0, import_react2.useRef)(null);
|
|
327
|
+
const resultsId = (0, import_react2.useId)();
|
|
328
|
+
const term = normalize(query);
|
|
329
|
+
const filtered = term.length > 0 || filter !== "all";
|
|
330
|
+
const visible = models.filter((model) => {
|
|
331
|
+
const status = !model.available ? "unavailable" : model.enabled ? "enabled" : "hidden";
|
|
332
|
+
if (filter !== "all" && status !== filter) return false;
|
|
333
|
+
return !term || normalize(model.name).includes(term) || normalize(model.id).includes(term);
|
|
334
|
+
});
|
|
335
|
+
const summary = [
|
|
336
|
+
filtered && models.length > 0 && words.matches(visible.length),
|
|
337
|
+
!headerActions && words.count(models.filter((model) => model.available && model.enabled).length, models.length)
|
|
338
|
+
].filter(Boolean).join(" \xB7 ");
|
|
339
|
+
function clearSearch() {
|
|
340
|
+
setQuery("");
|
|
341
|
+
searchRef.current?.focus();
|
|
342
|
+
}
|
|
343
|
+
function reset() {
|
|
344
|
+
setFilter("all");
|
|
345
|
+
if (term) clearSearch();
|
|
346
|
+
else filterRef.current?.focus();
|
|
347
|
+
}
|
|
348
|
+
const noResults = term ? words.noMatch : {
|
|
349
|
+
hidden: words.noneHidden,
|
|
350
|
+
enabled: words.noneEnabled,
|
|
351
|
+
unavailable: words.noneUnavailable,
|
|
352
|
+
all: words.empty
|
|
353
|
+
}[filter];
|
|
354
|
+
const resetLabel = !term ? words.showAll : filter === "all" ? words.clear : words.reset;
|
|
355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-model-hub-models", children: [
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: model_list_default }),
|
|
357
|
+
models.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-model-hub-toolbar", children: [
|
|
358
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-model-hub-search", children: [
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { "aria-hidden": "true", width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", children: [
|
|
360
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8.5", cy: "8.5", r: "5.5" }),
|
|
361
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m13 13 4 4" })
|
|
362
|
+
] }),
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
364
|
+
"input",
|
|
365
|
+
{
|
|
366
|
+
ref: searchRef,
|
|
367
|
+
type: "search",
|
|
368
|
+
value: query,
|
|
369
|
+
placeholder: words.search,
|
|
370
|
+
"aria-label": words.search,
|
|
371
|
+
"aria-controls": resultsId,
|
|
372
|
+
onChange: (event) => setQuery(event.target.value)
|
|
373
|
+
}
|
|
374
|
+
),
|
|
375
|
+
query && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-model-hub-clear", "aria-label": words.clear, title: words.clear, onClick: clearSearch, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { "aria-hidden": "true", width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m4.5 4.5 7 7m0-7-7 7" }) }) })
|
|
376
|
+
] }),
|
|
377
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-model-hub-filter", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
378
|
+
"select",
|
|
379
|
+
{
|
|
380
|
+
ref: filterRef,
|
|
381
|
+
value: filter,
|
|
382
|
+
"aria-label": words.filter,
|
|
383
|
+
"aria-controls": resultsId,
|
|
384
|
+
onChange: (event) => setFilter(event.target.value),
|
|
385
|
+
children: [
|
|
386
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "all", children: words.all }),
|
|
387
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "enabled", children: words.enabled }),
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "hidden", children: words.hidden }),
|
|
389
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "unavailable", children: words.unavailable })
|
|
390
|
+
]
|
|
391
|
+
}
|
|
392
|
+
) })
|
|
393
|
+
] }),
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { id: resultsId, children: [
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-model-hub-columns", children: [
|
|
396
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: words.name }),
|
|
397
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { role: "status", children: summary }),
|
|
398
|
+
headerActions
|
|
399
|
+
] }),
|
|
400
|
+
children,
|
|
401
|
+
visible.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "dsh-model-hub-list", "aria-label": label, "aria-labelledby": labelledBy, children: visible.map((model) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Fragment, { children: renderRow(model) }, model.id)) }) : models.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-model-hub-empty", children: [
|
|
402
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: noResults }),
|
|
403
|
+
filtered && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: reset, children: resetLabel })
|
|
404
|
+
] })
|
|
405
|
+
] })
|
|
406
|
+
] });
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// chatgpt/client/ModelCatalog.jsx
|
|
410
|
+
var import_react3 = require("react");
|
|
411
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
412
|
+
|
|
413
|
+
// chatgpt/client/SourceHeading.jsx
|
|
414
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
415
|
+
function SourceHeading({ id, title, hint, children }) {
|
|
416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { className: "omgpt-source-heading", children: [
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { id, children: title }),
|
|
419
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: hint })
|
|
420
|
+
] }),
|
|
421
|
+
children && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "omgpt-actions", children })
|
|
422
|
+
] });
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// chatgpt/client/PanelIcon.jsx
|
|
426
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
427
|
+
var paths = {
|
|
428
|
+
more: "M5 12h.1M12 12h.1M19 12h.1",
|
|
429
|
+
plus: "M12 5v14M5 12h14",
|
|
430
|
+
signOut: "M9 5H5v14h4m5-12 5 5-5 5m-5-5h10",
|
|
431
|
+
down: "m6 9 6 6 6-6",
|
|
432
|
+
account: "M15.75 8a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.5 20c.3-4.1 3.1-6.5 7.5-6.5s7.2 2.4 7.5 6.5",
|
|
433
|
+
refresh: "M20 5v5h-5m4.3-.7A8 8 0 1 0 19 16",
|
|
434
|
+
activity: "M2 12h5l3-8 4 16 3-8h5",
|
|
435
|
+
spinner: "M20 12a8 8 0 1 1-8-8"
|
|
436
|
+
};
|
|
437
|
+
function PanelIcon({ name, size = 18 }) {
|
|
438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
439
|
+
"svg",
|
|
440
|
+
{
|
|
441
|
+
"aria-hidden": "true",
|
|
442
|
+
focusable: "false",
|
|
443
|
+
width: size,
|
|
444
|
+
height: size,
|
|
445
|
+
viewBox: "0 0 24 24",
|
|
446
|
+
fill: "none",
|
|
447
|
+
stroke: "currentColor",
|
|
448
|
+
strokeWidth: name === "more" ? 3 : 1.65,
|
|
449
|
+
strokeLinecap: "round",
|
|
450
|
+
strokeLinejoin: "round",
|
|
451
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: paths[name] })
|
|
452
|
+
}
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// chatgpt/client/model-catalog.css
|
|
457
|
+
var model_catalog_default = ".omgpt-catalog > p { margin: 20px 0; color: var(--omgpt-muted); font-size: 14px; }\n.omgpt-model-disclosure { display: grid; justify-items: start; align-content: center; min-height: 36px; min-width: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; overflow-wrap: anywhere; cursor: pointer; }\n.omgpt-model-disclosure .dsh-model-hub-row-name { display: flex; align-items: center; gap: 6px; }\n.omgpt-model-disclosure svg { flex: none; color: var(--omgpt-muted); }\n.omgpt-model-disclosure[aria-expanded=true] svg { transform: rotate(180deg); }\n.omgpt-model-switch { display: flex; justify-content: end; align-items: center; }\n.omgpt-model-switch[aria-busy=true] { opacity: .65; }\n.omgpt-model-facts { grid-column: 1 / -1; display: grid; gap: 6px; margin: 5px 0 0; padding: 2px 12px; border-inline-start: 2px solid var(--omgpt-line); font-size: 13px; line-height: 1.5; }\n.omgpt-model-facts > div { display: grid; grid-template-columns: minmax(0, 6.5em) minmax(0, 1fr); gap: 12px; }\n.omgpt-model-facts dt { color: var(--omgpt-muted); }\n.omgpt-model-facts dd { margin: 0; overflow-wrap: anywhere; }\n.omgpt-model-row > p { grid-column: 1 / -1; margin: 4px 0 0; font-size: 13px; }\n";
|
|
458
|
+
|
|
459
|
+
// chatgpt/client/ModelCatalog.jsx
|
|
460
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
461
|
+
var copy2 = {
|
|
462
|
+
zh: {
|
|
463
|
+
inputs: "\u8F93\u5165\u7C7B\u578B",
|
|
464
|
+
effort: "\u63A8\u7406\u7B49\u7EA7",
|
|
465
|
+
standard: "\u6A21\u578B\u9ED8\u8BA4",
|
|
466
|
+
toggle: (name) => `\u5728\u6A21\u578B\u9009\u62E9\u5668\u4E2D\u663E\u793A ${name}`,
|
|
467
|
+
failed: "\u65E0\u6CD5\u66F4\u6539\u6B64\u6A21\u578B\u7684\u663E\u793A\u72B6\u6001\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
468
|
+
notListed: "\u5F53\u524D\u5957\u9910\u6682\u672A\u63D0\u4F9B\u6B64\u6A21\u578B",
|
|
469
|
+
unverified: "\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u53EF\u7528\u6027",
|
|
470
|
+
modalities: { text: "\u6587\u672C", image: "\u56FE\u7247" },
|
|
471
|
+
levels: { none: "\u5173\u95ED", low: "\u4F4E", medium: "\u4E2D", high: "\u9AD8", xhigh: "\u5F88\u9AD8", max: "\u6700\u5927" }
|
|
472
|
+
},
|
|
473
|
+
en: {
|
|
474
|
+
inputs: "Input types",
|
|
475
|
+
effort: "Reasoning effort",
|
|
476
|
+
standard: "Model default",
|
|
477
|
+
toggle: (name) => `Show ${name} in the model picker`,
|
|
478
|
+
failed: "Could not change this model\u2019s visibility. Try again.",
|
|
479
|
+
notListed: "Unavailable on the current plan",
|
|
480
|
+
unverified: "Availability could not be verified",
|
|
481
|
+
modalities: { text: "Text", image: "Images" }
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
function ModelRow({ model, words, joiner, disabled, unavailableLabel, status, onChange }) {
|
|
485
|
+
const [expanded, setExpanded] = (0, import_react3.useState)(false);
|
|
486
|
+
const detailsId = (0, import_react3.useId)();
|
|
487
|
+
const enabled = model.available && model.enabled;
|
|
488
|
+
const inputs = model.inputModalities?.map((key) => words.modalities[key] ?? key).join(joiner);
|
|
489
|
+
const levels = model.reasoning?.efforts?.map((level) => words.levels?.[level.id] ?? level.name ?? level.id).join(joiner);
|
|
490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { className: "dsh-model-hub-row omgpt-model-row", "aria-disabled": !model.available || void 0, children: [
|
|
491
|
+
model.available ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
492
|
+
"button",
|
|
493
|
+
{
|
|
494
|
+
type: "button",
|
|
495
|
+
className: "omgpt-model-disclosure",
|
|
496
|
+
"aria-expanded": expanded,
|
|
497
|
+
"aria-controls": detailsId,
|
|
498
|
+
onClick: () => setExpanded(!expanded),
|
|
499
|
+
children: [
|
|
500
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "dsh-model-hub-row-name", children: [
|
|
501
|
+
model.name,
|
|
502
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PanelIcon, { name: "down", size: 13 })
|
|
503
|
+
] }),
|
|
504
|
+
model.id !== model.name && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { className: "dsh-model-hub-row-id", children: model.id })
|
|
505
|
+
]
|
|
506
|
+
}
|
|
507
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
508
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-model-hub-row-heading", children: [
|
|
509
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-model-hub-row-name", children: model.name }),
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-model-hub-unavailable", children: unavailableLabel })
|
|
511
|
+
] }),
|
|
512
|
+
model.id !== model.name && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { className: "dsh-model-hub-row-id", children: model.id })
|
|
513
|
+
] }),
|
|
514
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "omgpt-model-switch", "aria-busy": status === "saving", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
515
|
+
import_dsh_client_ui_primitives.Switch,
|
|
516
|
+
{
|
|
517
|
+
checked: enabled,
|
|
518
|
+
label: words.toggle(model.name),
|
|
519
|
+
disabled: !model.available || disabled || status === "saving",
|
|
520
|
+
onChange: (value) => onChange(model.id, value)
|
|
521
|
+
}
|
|
522
|
+
) }),
|
|
523
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dl", { id: detailsId, className: "omgpt-model-facts", hidden: !model.available || !expanded, children: [
|
|
524
|
+
inputs && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
525
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: words.inputs }),
|
|
526
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { children: inputs })
|
|
527
|
+
] }),
|
|
528
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
529
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: words.effort }),
|
|
530
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { children: levels || words.standard })
|
|
531
|
+
] })
|
|
532
|
+
] }),
|
|
533
|
+
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "omgpt-error", children: words.failed })
|
|
534
|
+
] });
|
|
535
|
+
}
|
|
536
|
+
function ModelCatalog({ t, language, resource, profileId, hint, children }) {
|
|
537
|
+
const heading = (0, import_react3.useId)();
|
|
538
|
+
const words = copy2[language] ?? copy2.zh;
|
|
539
|
+
const { data: models, error, refresh, refreshing, update } = resource;
|
|
540
|
+
const writes = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
541
|
+
const [status, setStatus] = (0, import_react3.useState)(/* @__PURE__ */ new Map());
|
|
542
|
+
(0, import_react3.useEffect)(() => {
|
|
543
|
+
const active = writes.current;
|
|
544
|
+
setStatus(/* @__PURE__ */ new Map());
|
|
545
|
+
return () => {
|
|
546
|
+
for (const controller of active.values()) controller.abort();
|
|
547
|
+
active.clear();
|
|
548
|
+
};
|
|
549
|
+
}, [profileId]);
|
|
550
|
+
function setRowStatus(id, value) {
|
|
551
|
+
setStatus((previous) => {
|
|
552
|
+
const next = new Map(previous);
|
|
553
|
+
if (value) next.set(id, value);
|
|
554
|
+
else next.delete(id);
|
|
555
|
+
return next;
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
async function changeVisibility(model, enabled) {
|
|
559
|
+
if (!profileId || refreshing || writes.current.has(model) || !models?.some((row) => row.id === model && row.available)) return;
|
|
560
|
+
const controller = new AbortController();
|
|
561
|
+
const { signal } = controller;
|
|
562
|
+
writes.current.set(model, controller);
|
|
563
|
+
setRowStatus(model, "saving");
|
|
564
|
+
try {
|
|
565
|
+
const response = await fetch(`${apiBase}/model-visibility`, {
|
|
566
|
+
method: "POST",
|
|
567
|
+
cache: "no-store",
|
|
568
|
+
headers: { "content-type": "application/json" },
|
|
569
|
+
signal,
|
|
570
|
+
body: JSON.stringify({ profileId, model, enabled })
|
|
571
|
+
});
|
|
572
|
+
if (!response.ok) throw new Error();
|
|
573
|
+
const saved = await response.json();
|
|
574
|
+
if (saved.model !== model || saved.enabled !== enabled) throw new Error();
|
|
575
|
+
if (signal.aborted) return;
|
|
576
|
+
update((current) => current?.map((row) => row.id === model ? { ...row, enabled: saved.enabled } : row));
|
|
577
|
+
setRowStatus(model, null);
|
|
578
|
+
} catch {
|
|
579
|
+
if (!signal.aborted) setRowStatus(model, "error");
|
|
580
|
+
} finally {
|
|
581
|
+
if (writes.current.get(model) === controller) writes.current.delete(model);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "omgpt-catalog", children: [
|
|
585
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: model_catalog_default }),
|
|
586
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SourceHeading, { id: heading, title: t("planModels"), hint: hint ?? t("planHint"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
587
|
+
"button",
|
|
588
|
+
{
|
|
589
|
+
type: "button",
|
|
590
|
+
className: "omgpt-icon-button",
|
|
591
|
+
onClick: refresh,
|
|
592
|
+
disabled: refreshing || Array.from(status.values()).includes("saving"),
|
|
593
|
+
"aria-busy": refreshing,
|
|
594
|
+
"aria-label": t("refreshModels"),
|
|
595
|
+
title: t("refreshModels"),
|
|
596
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PanelIcon, { name: "refresh", size: 16 })
|
|
597
|
+
}
|
|
598
|
+
) }),
|
|
599
|
+
children,
|
|
600
|
+
error !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "omgpt-error", children: error || t("modelsFailed") }),
|
|
601
|
+
error === null && !models?.length && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "status", children: t(models ? "modelsEmpty" : "modelsLoading") }),
|
|
602
|
+
models?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
603
|
+
ModelList,
|
|
604
|
+
{
|
|
605
|
+
labelledBy: heading,
|
|
606
|
+
language,
|
|
607
|
+
models,
|
|
608
|
+
renderRow: (model) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
609
|
+
ModelRow,
|
|
610
|
+
{
|
|
611
|
+
model,
|
|
612
|
+
words,
|
|
613
|
+
joiner: language === "en" ? ", " : "\u3001",
|
|
614
|
+
unavailableLabel: !profileId ? t("noConsent") : error !== null ? words.unverified : words.notListed,
|
|
615
|
+
disabled: !profileId || refreshing,
|
|
616
|
+
status: status.get(model.id),
|
|
617
|
+
onChange: changeVisibility
|
|
618
|
+
},
|
|
619
|
+
model.id
|
|
620
|
+
)
|
|
621
|
+
}
|
|
622
|
+
)
|
|
623
|
+
] });
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// chatgpt/client/NativeChatOptions.jsx
|
|
627
|
+
var import_react5 = require("react");
|
|
628
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
629
|
+
|
|
630
|
+
// models.json
|
|
631
|
+
var models_default = {
|
|
632
|
+
kilo: {
|
|
633
|
+
name: "OpenModel (\u514D\u8D39\u6A21\u578B)",
|
|
634
|
+
models: [
|
|
635
|
+
{
|
|
636
|
+
id: "kilo-auto/free",
|
|
637
|
+
name: "Auto Free",
|
|
638
|
+
inputModalities: ["text"],
|
|
639
|
+
webSearch: true
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
id: "inclusionai/ling-3.2-flash:free",
|
|
643
|
+
name: "inclusionAI: Ling 3.2 Flash (free)",
|
|
644
|
+
inputModalities: ["text", "image"],
|
|
645
|
+
webSearch: true,
|
|
646
|
+
reasoningEfforts: ["instant", "thinking"]
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
id: "baidu/ernie-5.5-flash-preview:free",
|
|
650
|
+
name: "Baidu: ERNIE-5.5-Flash-Preview (free)",
|
|
651
|
+
inputModalities: ["text"],
|
|
652
|
+
webSearch: true,
|
|
653
|
+
reasoningEfforts: ["high"]
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
id: "liquid/lfm-3-1.7b:free",
|
|
657
|
+
name: "LiquidAI: LFM3-1.7B (free)",
|
|
658
|
+
inputModalities: ["text"],
|
|
659
|
+
webSearch: true
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
id: "particle-ai/particle-1:free",
|
|
663
|
+
name: "Particle AI: Particle-1 (free)",
|
|
664
|
+
inputModalities: ["text", "image"],
|
|
665
|
+
webSearch: true,
|
|
666
|
+
reasoningEfforts: ["none", "minimal", "low", "medium", "high", "xhigh", "max"]
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
id: "recursive/flint-v1.0:free",
|
|
670
|
+
name: "Recursive: Flint (free)",
|
|
671
|
+
inputModalities: ["text"],
|
|
672
|
+
webSearch: true
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
id: "nvidia/nemotron-3.5-super-vl:free",
|
|
676
|
+
name: "NVIDIA: Nemotron 3.5 Super VL (free)",
|
|
677
|
+
inputModalities: ["text", "image"],
|
|
678
|
+
webSearch: true,
|
|
679
|
+
reasoningEfforts: ["instant", "thinking"]
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
id: "nvidia/nemotron-3.5-lightning:free",
|
|
683
|
+
name: "NVIDIA: Nemotron 3.5 Lightning (free)",
|
|
684
|
+
inputModalities: ["text"],
|
|
685
|
+
webSearch: true,
|
|
686
|
+
reasoningEfforts: ["instant", "thinking"]
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
id: "nvidia/nemotron-3-ultra-550b-a55b:free",
|
|
690
|
+
name: "NVIDIA: Nemotron 3 Ultra (free)",
|
|
691
|
+
inputModalities: ["text"],
|
|
692
|
+
webSearch: true,
|
|
693
|
+
reasoningEfforts: ["none", "medium", "high"]
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
id: "nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free",
|
|
697
|
+
name: "NVIDIA: Nemotron 3 Nano Omni (free)",
|
|
698
|
+
inputModalities: ["text", "image"],
|
|
699
|
+
webSearch: true,
|
|
700
|
+
reasoningEfforts: ["instant", "thinking"]
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
id: "openrouter/free",
|
|
704
|
+
name: "OpenRouter Free Models Router",
|
|
705
|
+
inputModalities: ["text", "image"],
|
|
706
|
+
webSearch: true
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
id: "reflection/beam-free",
|
|
710
|
+
name: "Reflection: Beam 1.0 (Free)",
|
|
711
|
+
inputModalities: ["text"],
|
|
712
|
+
webSearch: true,
|
|
713
|
+
reasoningEfforts: ["low", "medium", "high", "xhigh", "max"]
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
id: "stealth/glyph-cluster",
|
|
717
|
+
name: "Glyph Cluster",
|
|
718
|
+
inputModalities: ["text"],
|
|
719
|
+
webSearch: true,
|
|
720
|
+
reasoningEfforts: ["low", "medium", "high", "xhigh"]
|
|
721
|
+
}
|
|
722
|
+
]
|
|
723
|
+
},
|
|
724
|
+
chatgpt: {
|
|
725
|
+
name: "OpenModel (ChatGPT \u5957\u9910)",
|
|
726
|
+
models: [
|
|
727
|
+
{
|
|
728
|
+
id: "gpt-6.2-sol",
|
|
729
|
+
name: "GPT-6.2-Sol",
|
|
730
|
+
inputModalities: ["text", "image"],
|
|
731
|
+
webSearch: true,
|
|
732
|
+
reasoningEfforts: ["low", "medium", "high", "xhigh", "max", "ultra"]
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
id: "gpt-6.2-astra",
|
|
736
|
+
name: "GPT-6.2-Astra",
|
|
737
|
+
inputModalities: ["text", "image"],
|
|
738
|
+
webSearch: true,
|
|
739
|
+
reasoningEfforts: ["low", "medium", "high", "xhigh", "max", "ultra"]
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
id: "gpt-6.1-terra",
|
|
743
|
+
name: "GPT-6.1 Terra",
|
|
744
|
+
inputModalities: ["text", "image"],
|
|
745
|
+
webSearch: true,
|
|
746
|
+
reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max", "ultra"]
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
id: "gpt-6.1-sol",
|
|
750
|
+
name: "GPT-6.1-Sol",
|
|
751
|
+
inputModalities: ["text", "image"],
|
|
752
|
+
webSearch: true,
|
|
753
|
+
reasoningEfforts: ["low", "medium", "high", "xhigh", "max", "ultra"]
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
id: "gpt-6-astra",
|
|
757
|
+
name: "GPT-6-Astra",
|
|
758
|
+
inputModalities: ["text", "image"],
|
|
759
|
+
webSearch: true,
|
|
760
|
+
reasoningEfforts: ["low", "medium", "high", "xhigh", "max", "ultra"]
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
id: "gpt-6-sol",
|
|
764
|
+
name: "GPT-6-Sol",
|
|
765
|
+
inputModalities: ["text", "image"],
|
|
766
|
+
webSearch: true,
|
|
767
|
+
reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max", "ultra"]
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
id: "gpt-6-luna",
|
|
771
|
+
name: "GPT-6-Luna",
|
|
772
|
+
inputModalities: ["text", "image"],
|
|
773
|
+
webSearch: true,
|
|
774
|
+
reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max"]
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
id: "gpt-5.6-sol",
|
|
778
|
+
name: "GPT-5.6-Sol",
|
|
779
|
+
inputModalities: ["text", "image"],
|
|
780
|
+
webSearch: true,
|
|
781
|
+
reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max", "ultra"]
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
id: "gpt-5.6-terra",
|
|
785
|
+
name: "GPT-5.6-Terra",
|
|
786
|
+
inputModalities: ["text", "image"],
|
|
787
|
+
webSearch: true,
|
|
788
|
+
reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max", "ultra"]
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
id: "gpt-5.6-luna",
|
|
792
|
+
name: "GPT-5.6-Luna",
|
|
793
|
+
inputModalities: ["text", "image"],
|
|
794
|
+
webSearch: true,
|
|
795
|
+
reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max"]
|
|
796
|
+
}
|
|
797
|
+
]
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
// model-config.js
|
|
802
|
+
var fields = /* @__PURE__ */ new Set(["id", "name", "inputModalities", "reasoningEfforts", "webSearch", "contextWindow", "maxCompletionTokens"]);
|
|
803
|
+
function stringList(value, accepts) {
|
|
804
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string" && accepts(item)) && new Set(value).size === value.length;
|
|
805
|
+
}
|
|
806
|
+
function validateModels(rows, path) {
|
|
807
|
+
if (!Array.isArray(rows)) throw new TypeError(`models.json: ${path} must be an array.`);
|
|
808
|
+
const ids = /* @__PURE__ */ new Set();
|
|
809
|
+
for (const [index, row] of rows.entries()) {
|
|
810
|
+
const invalid = (field) => {
|
|
811
|
+
throw new TypeError(`models.json: invalid ${path}[${index}].${field}`);
|
|
812
|
+
};
|
|
813
|
+
if (typeof row?.id !== "string" || !row.id.trim() || row.id.trim() !== row.id || ids.has(row.id)) invalid("id");
|
|
814
|
+
for (const field of Object.keys(row)) if (!fields.has(field)) invalid(field);
|
|
815
|
+
if (row.name !== void 0 && (typeof row.name !== "string" || !row.name.trim())) invalid("name");
|
|
816
|
+
if (row.inputModalities !== void 0 && (!stringList(row.inputModalities, (mode) => mode === "text" || mode === "image") || !row.inputModalities.includes("text"))) invalid("inputModalities");
|
|
817
|
+
if (row.reasoningEfforts !== void 0 && !stringList(row.reasoningEfforts, (effort) => /^[a-z][a-z0-9_-]*$/.test(effort))) invalid("reasoningEfforts");
|
|
818
|
+
if (row.webSearch !== void 0 && typeof row.webSearch !== "boolean") invalid("webSearch");
|
|
819
|
+
for (const field of ["contextWindow", "maxCompletionTokens"]) {
|
|
820
|
+
if (row[field] !== void 0 && (!Number.isSafeInteger(row[field]) || row[field] <= 0)) invalid(field);
|
|
821
|
+
}
|
|
822
|
+
ids.add(row.id);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
function parseModelSources(config) {
|
|
826
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
827
|
+
throw new TypeError("models.json: expected an object keyed by source ID.");
|
|
828
|
+
}
|
|
829
|
+
const byId = /* @__PURE__ */ new Map();
|
|
830
|
+
for (const [id, value] of Object.entries(config)) {
|
|
831
|
+
if (!id || id !== id.trim()) throw new TypeError("models.json: invalid source ID.");
|
|
832
|
+
const source = Array.isArray(value) ? { models: value } : value;
|
|
833
|
+
if (!source || typeof source !== "object") {
|
|
834
|
+
throw new TypeError(`models.json: ${id} must be a source object.`);
|
|
835
|
+
}
|
|
836
|
+
if (source.name !== void 0 && (typeof source.name !== "string" || !source.name.trim())) {
|
|
837
|
+
throw new TypeError(`models.json: invalid ${id}.name`);
|
|
838
|
+
}
|
|
839
|
+
validateModels(source.models, `${id}.models`);
|
|
840
|
+
byId.set(id, source);
|
|
841
|
+
}
|
|
842
|
+
return byId;
|
|
843
|
+
}
|
|
844
|
+
var sources = parseModelSources(models_default);
|
|
845
|
+
|
|
846
|
+
// catalog.js
|
|
847
|
+
var KILO_PROVIDER = "dsh-free-model-kilo";
|
|
848
|
+
var FRESH_MS = 5 * 6e4;
|
|
849
|
+
|
|
850
|
+
// chatgpt/client/use-chat-options.js
|
|
851
|
+
var import_react4 = require("react");
|
|
852
|
+
var pendingWrites = /* @__PURE__ */ new Map();
|
|
853
|
+
async function requestSettings(url, signal, enabled) {
|
|
854
|
+
const response = await fetch(url, {
|
|
855
|
+
cache: "no-store",
|
|
856
|
+
signal,
|
|
857
|
+
...enabled !== void 0 && {
|
|
858
|
+
method: "POST",
|
|
859
|
+
headers: { "content-type": "application/json" },
|
|
860
|
+
body: JSON.stringify({ enabled })
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
const data = await response.json().catch(() => null);
|
|
864
|
+
if (!response.ok || typeof data?.enabled !== "boolean" || typeof data.available !== "boolean") {
|
|
865
|
+
throw new Error(typeof data?.error === "string" ? data.error : data?.error?.message || "");
|
|
866
|
+
}
|
|
867
|
+
return { enabled: data.enabled, available: data.available };
|
|
868
|
+
}
|
|
869
|
+
function useChatOptions(sessionId, provider, model, catalogGroups, preset) {
|
|
870
|
+
const url = "/api/dsh-open-model/web-search?" + new URLSearchParams({ sessionId, provider, model });
|
|
871
|
+
const [state, setState] = (0, import_react4.useState)({});
|
|
872
|
+
const [revision, setRevision] = (0, import_react4.useState)(0);
|
|
873
|
+
const lifetime = (0, import_react4.useRef)(null);
|
|
874
|
+
(0, import_react4.useEffect)(() => {
|
|
875
|
+
const controller = new AbortController();
|
|
876
|
+
const { signal } = controller;
|
|
877
|
+
lifetime.current = signal;
|
|
878
|
+
setState({});
|
|
879
|
+
async function load() {
|
|
880
|
+
try {
|
|
881
|
+
await pendingWrites.get(sessionId)?.catch(() => {
|
|
882
|
+
});
|
|
883
|
+
signal.throwIfAborted();
|
|
884
|
+
const settings = await requestSettings(url, signal);
|
|
885
|
+
if (!signal.aborted) setState({ url, settings });
|
|
886
|
+
} catch (error) {
|
|
887
|
+
if (!signal.aborted) setState({ url, error });
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
void load();
|
|
891
|
+
return () => controller.abort();
|
|
892
|
+
}, [sessionId, url, revision, catalogGroups, preset]);
|
|
893
|
+
const current = state.url === url ? state : {};
|
|
894
|
+
async function save(enabled) {
|
|
895
|
+
const signal = lifetime.current;
|
|
896
|
+
if (!signal || signal.aborted || !current.settings?.available || pendingWrites.has(sessionId)) return;
|
|
897
|
+
setState({ url, settings: current.settings, saving: true });
|
|
898
|
+
const write = requestSettings(url, void 0, enabled);
|
|
899
|
+
pendingWrites.set(sessionId, write);
|
|
900
|
+
try {
|
|
901
|
+
const settings = await write;
|
|
902
|
+
if (!signal.aborted) setState({ url, settings });
|
|
903
|
+
} catch (error) {
|
|
904
|
+
if (!signal.aborted) setState({ url, settings: current.settings, error });
|
|
905
|
+
} finally {
|
|
906
|
+
pendingWrites.delete(sessionId);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
return { ...current, save, retry: () => setRevision((value) => value + 1) };
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// chatgpt/client/NativeChatOptions.jsx
|
|
913
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
914
|
+
function SearchRetry({ t, message, retry }) {
|
|
915
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "omgpt-search-retry", title: message, onClick: retry, children: [
|
|
916
|
+
t("searchRetry"),
|
|
917
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "omgpt-search-sr", role: "alert", children: message })
|
|
918
|
+
] });
|
|
919
|
+
}
|
|
920
|
+
function SessionSearch({ id, provider, model, catalogGroups, preset, t }) {
|
|
921
|
+
const { settings, saving, save, error, retry } = useChatOptions(id, provider, model, catalogGroups, preset);
|
|
922
|
+
if (!settings) {
|
|
923
|
+
return error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SearchRetry, { t, message: error.message || t("searchLoadFailed"), retry }) : null;
|
|
924
|
+
}
|
|
925
|
+
const { enabled, available } = settings;
|
|
926
|
+
const help = t(available ? "searchHelp" : "searchUnavailable");
|
|
927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "omgpt-search-tool", "aria-busy": Boolean(saving), children: [
|
|
928
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { title: help, className: "omgpt-search-label", "data-unavailable": !available || void 0, children: [
|
|
929
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: t("webSearch") }),
|
|
930
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
931
|
+
import_dsh_client_ui_primitives2.Switch,
|
|
932
|
+
{
|
|
933
|
+
disabled: saving || !available,
|
|
934
|
+
checked: enabled && available,
|
|
935
|
+
label: t("webSearch"),
|
|
936
|
+
title: help,
|
|
937
|
+
onChange: (value) => {
|
|
938
|
+
void save(value);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
)
|
|
942
|
+
] }),
|
|
943
|
+
!available && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
944
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { role: "status", className: "omgpt-search-note", children: help }),
|
|
945
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "omgpt-search-retry", onClick: retry, children: t("searchRecheck") })
|
|
946
|
+
] }),
|
|
947
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { role: "alert", className: "omgpt-search-note", title: error.message || void 0, children: t("saveFailed") })
|
|
948
|
+
] });
|
|
949
|
+
}
|
|
950
|
+
function ConnectedSearch({ useConnection: useConnection2, ...props }) {
|
|
951
|
+
const { id, model, t } = props;
|
|
952
|
+
const { connection, error, refresh } = useConnection2();
|
|
953
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SearchRetry, { t, message: t("requestFailed"), retry: () => {
|
|
954
|
+
void refresh();
|
|
955
|
+
} });
|
|
956
|
+
if (connection?.status !== "connected" || !connection.sharing || !connection.profileId) return null;
|
|
957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SessionSearch, { ...props }, JSON.stringify([id, model, connection.profileId]));
|
|
958
|
+
}
|
|
959
|
+
function ModelSearch({ directory, agentPreset, id, t, useConnection: useConnection2 }) {
|
|
960
|
+
const preset = (0, import_react5.useSyncExternalStore)(agentPreset.subscribe, agentPreset.getSnapshot);
|
|
961
|
+
const { current, routable, groups } = (0, import_react5.useSyncExternalStore)(directory.subscribe, directory.getSnapshot);
|
|
962
|
+
if (!current?.model || routable === false) return null;
|
|
963
|
+
const { provider, model } = current;
|
|
964
|
+
const props = { id, provider, model, catalogGroups: groups, preset, t };
|
|
965
|
+
if (provider === KILO_PROVIDER) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SessionSearch, { ...props }, JSON.stringify([id, model]));
|
|
966
|
+
if (provider === providerId) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ConnectedSearch, { ...props, useConnection: useConnection2 });
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
function registerNativeChatOptions(ctx, useConnection2) {
|
|
970
|
+
ctx.inject(["slots", "sessions", "modelDirectories"], (scope) => {
|
|
971
|
+
scope.slots.inject("conversation.input.left", () => scope.slots.register({
|
|
972
|
+
name: "conversation.input.left",
|
|
973
|
+
id: providerId,
|
|
974
|
+
order: 0,
|
|
975
|
+
locale: providerId,
|
|
976
|
+
inject: (id) => {
|
|
977
|
+
if (scope.sessions.subagentAddress(id) !== void 0) return {};
|
|
978
|
+
const binding = scope.sessions.binding(id);
|
|
979
|
+
if (!binding) return {};
|
|
980
|
+
return {
|
|
981
|
+
id,
|
|
982
|
+
directory: scope.modelDirectories.directoryFor(id).store,
|
|
983
|
+
agentPreset: binding.session.projections.faceOf("agentPreset")
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
}, function NativeSearch({ id, directory, agentPreset, t }) {
|
|
987
|
+
return directory ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ModelSearch, { id, directory, agentPreset, t, useConnection: useConnection2 }) : null;
|
|
988
|
+
}));
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// chatgpt/client/assets/chatgpt-button-black-21.svg
|
|
993
|
+
var chatgpt_button_black_21_default = 'data:image/svg+xml,<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="21" height="21" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg">%0A<g id="ChatGPT logo &%23226;&%23128;&%23148; original vector">%0A<path id="Vector" d="M11.8102 19.1625C11.2327 19.1625 10.6841 19.0528 10.1643 18.8334C9.64459 18.6139 9.18259 18.3078 8.77834 17.9151C8.33944 18.0653 7.88322 18.1404 7.40967 18.1404C6.63582 18.1404 5.91972 17.9498 5.26137 17.5686C4.60302 17.1875 4.07172 16.6677 3.66747 16.0094C3.27477 15.351 3.07842 14.6176 3.07842 13.8091C3.07842 13.4742 3.12462 13.1103 3.21702 12.7176C2.75502 12.2903 2.39697 11.7994 2.14287 11.245C1.88877 10.679 1.76172 10.09 1.76172 9.47785C1.76172 8.85415 1.89454 8.25355 2.16019 7.67605C2.42584 7.09855 2.79544 6.6019 3.26899 6.1861C3.75409 5.75875 4.31427 5.46422 4.94952 5.30252C5.07657 4.64417 5.34222 4.05512 5.74647 3.53537C6.16227 3.00407 6.67047 2.58827 7.27107 2.28797C7.87167 1.98767 8.51269 1.83752 9.19414 1.83752C9.77164 1.83752 10.3203 1.94725 10.84 2.1667C11.3598 2.38615 11.8218 2.69222 12.226 3.08492C12.6649 2.93477 13.1211 2.8597 13.5947 2.8597C14.3685 2.8597 15.0846 3.05027 15.743 3.43142C16.4013 3.81257 16.9269 4.33232 17.3196 4.99067C17.7238 5.64902 17.9259 6.38245 17.9259 7.19095C17.9259 7.5259 17.8797 7.88973 17.7873 8.28242C18.2493 8.70977 18.6074 9.20643 18.8615 9.77238C19.1156 10.3268 19.2426 10.91 19.2426 11.5222C19.2426 12.1459 19.1098 12.7465 18.8442 13.324C18.5785 13.9015 18.2031 14.4039 17.718 14.8313C17.2445 15.2471 16.6901 15.5358 16.0548 15.6975C15.9278 16.3559 15.6564 16.9449 15.2406 17.4647C14.8363 17.996 14.3339 18.4118 13.7333 18.7121C13.1327 19.0124 12.4917 19.1625 11.8102 19.1625ZM7.53094 16.9969C8.10844 16.9969 8.61087 16.8756 9.03822 16.6331L12.2953 14.762C12.4108 14.6811 12.4686 14.5714 12.4686 14.4328V12.9429L8.27592 15.351C8.02182 15.5012 7.76772 15.5012 7.51362 15.351L4.23919 13.4626C4.23919 13.4973 4.23342 13.5377 4.22187 13.5839C4.22187 13.6301 4.22187 13.6994 4.22187 13.7918C4.22187 14.3808 4.36047 14.9237 4.63767 15.4203C4.92642 15.9054 5.32489 16.2866 5.83309 16.5638C6.34129 16.8525 6.90724 16.9969 7.53094 16.9969ZM7.70419 14.1729C7.77349 14.2076 7.83702 14.2249 7.89477 14.2249C7.95252 14.2249 8.01027 14.2076 8.06802 14.1729L9.36739 13.4279L5.19207 11.0024C4.93797 10.8523 4.81092 10.6271 4.81092 10.3268V6.56725C4.23342 6.82135 3.77142 7.21405 3.42492 7.74535C3.07842 8.2651 2.90517 8.8426 2.90517 9.47785C2.90517 10.0438 3.04954 10.5866 3.33829 11.1064C3.62704 11.6261 4.00242 12.0189 4.46442 12.2845L7.70419 14.1729ZM11.8102 18.0191C12.4224 18.0191 12.9768 17.8805 13.4734 17.6033C13.9701 17.3261 14.3628 16.9449 14.6515 16.4598C14.9403 15.9747 15.0846 15.4319 15.0846 14.8313V11.0891C15.0846 10.9505 15.0269 10.8465 14.9114 10.7772L13.5947 10.0149V14.8486C13.5947 15.1489 13.4676 15.3741 13.2135 15.5243L9.93912 17.4127C10.5051 17.817 11.1288 18.0191 11.8102 18.0191ZM12.4686 11.6781V9.32192L10.5108 8.21312L8.53579 9.32192V11.6781L10.5108 12.7869L12.4686 11.6781ZM7.40967 6.15145C7.40967 5.85115 7.53672 5.62592 7.79082 5.47577L11.0652 3.58735C10.4993 3.1831 9.87559 2.98097 9.19414 2.98097C8.58199 2.98097 8.02759 3.11957 7.53094 3.39677C7.03429 3.67397 6.64159 4.05512 6.35284 4.54022C6.07564 5.02532 5.93704 5.56817 5.93704 6.16878V9.89365C5.93704 10.0323 5.99479 10.142 6.11029 10.2228L7.40967 10.9851V6.15145ZM16.2108 14.4328C16.7883 14.1787 17.2445 13.786 17.5794 13.2547C17.9259 12.7234 18.0992 12.1459 18.0992 11.5222C18.0992 10.9562 17.9548 10.4134 17.6661 9.89365C17.3773 9.3739 17.0019 8.9812 16.5399 8.71555L13.3002 6.84445C13.2309 6.79825 13.1673 6.78092 13.1096 6.79248C13.0518 6.79248 12.9941 6.8098 12.9363 6.84445L11.637 7.5721L15.8296 10.0149C15.9567 10.0842 16.0491 10.1766 16.1068 10.2921C16.1761 10.3961 16.2108 10.5231 16.2108 10.6733V14.4328ZM12.7284 5.6317C12.9825 5.47 13.2366 5.47 13.4907 5.6317L16.7825 7.55477C16.7825 7.47393 16.7825 7.36997 16.7825 7.24292C16.7825 6.68852 16.6439 6.163 16.3667 5.66635C16.101 5.15815 15.7141 4.7539 15.2059 4.4536C14.7093 4.1533 14.1318 4.00315 13.4734 4.00315C12.8959 4.00315 12.3935 4.12442 11.9661 4.36697L8.70904 6.23808C8.59354 6.31892 8.53579 6.42865 8.53579 6.56725V8.0572L12.7284 5.6317Z" fill="black"/>%0A</g>%0A</svg>%0A';
|
|
994
|
+
|
|
995
|
+
// chatgpt/client/workspace.css
|
|
996
|
+
var workspace_default = ".omgpt-workspace {\n --omgpt-surface: var(--dsw-alias-bg-layer-1);\n --omgpt-ink: var(--dsw-alias-label-primary);\n --omgpt-muted: var(--dsw-alias-label-secondary);\n --omgpt-line: var(--dsw-alias-border-l2, color-mix(in srgb, currentColor 12%, transparent));\n --omgpt-wash: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 6%, transparent));\n min-width: 0;\n color: var(--omgpt-ink);\n container: omgpt-source / inline-size;\n}\n.omgpt-workspace [hidden] { display: none !important; }\n.omgpt-source-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; }\n.omgpt-source-heading > div:first-child { min-width: min(195px, 100%); flex: 1; }\n.omgpt-source-heading h2, .omgpt-login h2 { font-family: inherit; font-size: 20px; line-height: 1.35; font-weight: 600; letter-spacing: -.02em; margin: 0; }\n.omgpt-source-heading p, .omgpt-login-hint { color: var(--omgpt-muted); font-size: 14px; line-height: 1.6; margin: 6px 0 0; }\n.omgpt-login {\n display: flex; flex-direction: column; align-items: center; justify-content: center;\n min-height: 254px; box-sizing: border-box; padding: 34px 20px; text-align: center;\n border: 1px solid var(--omgpt-line); border-radius: 16px;\n}\n.omgpt-login-icon {\n display: grid; place-items: center; width: 44px; height: 44px; margin-block-end: 15px;\n color: var(--omgpt-ink); background: var(--omgpt-wash); border-radius: 14px;\n}\n.omgpt-login-hint { max-width: 42ch; text-wrap: pretty; }\n.omgpt-login .omgpt-actions { justify-content: center; margin-block-start: 19px; }\n.omgpt-login .omgpt-actions button { max-width: 100%; overflow-wrap: anywhere; }\n.omgpt-login .omgpt-error { margin: 8px 0 0; }\n.omgpt-workspace :where(button, summary):focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }\n.omgpt-workspace button:disabled { opacity: .55; cursor: default; }\n.omgpt-actions .omgpt-primary { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; min-height: 38px; padding-inline: 16px; border: 0; border-radius: 999px; background: var(--omgpt-ink); color: var(--omgpt-surface); }\n.omgpt-actions .omgpt-primary:hover:enabled { background: color-mix(in srgb, var(--omgpt-ink) 86%, var(--omgpt-surface)); }\n.omgpt-mark { width: 16px; height: 16px; flex: none; display: block; filter: invert(1); }\nbody[data-ds-dark-theme] .omgpt-mark { filter: none; }\n.omgpt-details { color: var(--omgpt-ink); font-size: 13px; }\n.omgpt-details > summary {\n display: flex; align-items: center; gap: 8px; min-height: 40px;\n list-style: none; overflow-wrap: anywhere; cursor: pointer;\n}\n.omgpt-details > summary::-webkit-details-marker { display: none; }\n.omgpt-details > summary > svg { flex: none; color: var(--omgpt-muted); }\n.omgpt-details > summary > svg:last-child { margin-inline-start: auto; }\n.omgpt-details[open] > summary > svg:last-child { transform: rotate(180deg); }\n.omgpt-details > summary:hover { color: var(--omgpt-ink); }\n.omgpt-account-details {\n margin-block: 16px 18px; padding-inline: 12px;\n border: 1px solid var(--omgpt-line); border-radius: 10px;\n}\n.omgpt-account-details > summary { min-height: 42px; }\n.omgpt-account-details > summary > svg:last-child { margin-inline-start: 0; }\n.omgpt-account-identity { min-width: 0; font-weight: 500; }\n.omgpt-account-identity > span { margin-inline-end: 5px; color: var(--omgpt-muted); font-weight: 400; }\n.omgpt-manage-label { flex: none; margin-inline-start: auto; color: var(--omgpt-muted); }\n.omgpt-account-details > summary:hover .omgpt-manage-label { color: var(--omgpt-ink); }\n.omgpt-account-details > .omgpt-account { border-block-start: 1px solid var(--omgpt-line); padding-block-end: 12px; }\n.omgpt-legacy-defaults { color: var(--omgpt-muted); }\n.omgpt-legacy-defaults p { color: var(--omgpt-muted); }\n.omgpt-icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; flex: none; padding: 0; border: 1px solid var(--omgpt-line); border-radius: 9px; background: transparent; color: var(--omgpt-muted); cursor: pointer; }\n.omgpt-icon-button:hover:enabled { color: var(--omgpt-ink); background: var(--omgpt-wash); }\n.omgpt-profile-list { margin: 0; padding: 0; list-style: none; }\n.omgpt-profile {\n display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;\n min-height: 64px; padding-block: 11px; border-block-end: 1px solid var(--omgpt-line);\n}\n.omgpt-profile-avatar {\n display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; overflow: hidden;\n background: var(--omgpt-ink); color: var(--omgpt-surface); font-size: 13px; line-height: 1; font-weight: 550;\n}\n.omgpt-profile-text { display: grid; gap: 3px; min-width: 0; }\n.omgpt-profile-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }\n.omgpt-profile-name strong { min-width: 0; font-size: 15px; font-weight: 550; overflow-wrap: anywhere; }\n.omgpt-current-account {\n display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;\n background: var(--omgpt-wash);\n color: var(--omgpt-muted); font-size: 11px; font-weight: 600; white-space: nowrap;\n}\n.omgpt-profile-meta { display: flex; align-items: center; gap: 3px 12px; flex-wrap: wrap; font-size: 13px; color: var(--omgpt-muted); overflow-wrap: anywhere; }\n.omgpt-profile-actions { display: flex; align-items: center; justify-self: end; gap: 6px; }\n.omgpt-account-action, .omgpt-account-more, .omgpt-account-add {\n display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 32px;\n border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--omgpt-ink);\n font: inherit; font-size: 13px; font-weight: 500; line-height: 1.4; cursor: pointer;\n}\n.omgpt-account-action, .omgpt-account-add { border-color: var(--omgpt-line); padding: 5px 12px; }\n.omgpt-account-more { width: 32px; padding: 0; color: var(--omgpt-muted); }\n.omgpt-account-add { min-height: 36px; margin-block-start: 14px; font-size: 14px; }\n.omgpt-account-action:hover:enabled, .omgpt-account-add:hover:enabled,\n.omgpt-account-more:hover:enabled, .omgpt-account-more[aria-expanded=true] { color: var(--omgpt-ink); background: var(--omgpt-wash); }\n.omgpt-account-flow { display: grid; gap: 12px; justify-items: start; padding: 16px 0; }\n.omgpt-account-flow p { margin: 0; color: var(--omgpt-muted); }\n.omgpt-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }\n.omgpt-actions:empty { display: none; }\n.omgpt-account > p { margin: 12px 0; font-size: 14px; color: var(--omgpt-muted); }\n.omgpt-workspace .omgpt-error { color: var(--dsw-alias-state-warn-label, #9a461e); overflow-wrap: anywhere; }\n\n@container omgpt-source (max-width: 400px) {\n .omgpt-profile { column-gap: 8px; }\n .omgpt-profile-meta { gap: 2px 6px; }\n .omgpt-account-identity > span { display: block; font-size: 12px; }\n .omgpt-account-details > summary { padding-block: 5px; }\n}\n";
|
|
997
|
+
|
|
998
|
+
// chatgpt/client/native-chat-options.css
|
|
999
|
+
var native_chat_options_default = ".omgpt-search-tool, .omgpt-search-label { display: inline-flex; align-items: center; gap: 6px; }\n.omgpt-search-label, .omgpt-search-retry {\n min-height: 28px;\n color: var(--dsw-alias-label-secondary);\n font-family: inherit; font-size: 13px; line-height: 20px; font-weight: 500;\n white-space: nowrap; cursor: pointer;\n}\n.omgpt-search-tool { flex-wrap: wrap; min-width: 0; }\n.omgpt-search-label[data-unavailable=true] { cursor: default; }\n.omgpt-search-tool[aria-busy=true] .omgpt-search-label { cursor: progress; }\n.omgpt-search-retry { border: 0; background: transparent; border-radius: 6px; padding: 0 4px; }\n.omgpt-search-retry:hover { background: var(--dsw-alias-button-ghost-hover); }\n.omgpt-search-retry:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); }\n.omgpt-search-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }\n.omgpt-search-note { color: var(--dsw-alias-label-secondary); font-size: 12px; }\n";
|
|
1000
|
+
|
|
1001
|
+
// chatgpt/client/workspace.jsx
|
|
1002
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1003
|
+
function profileName(profile) {
|
|
1004
|
+
return profile.identity?.email || profile.identity?.name || profile.label;
|
|
1005
|
+
}
|
|
1006
|
+
function LoginScreen({ t, state }) {
|
|
1007
|
+
const { connection, pending, error, refresh, run } = state;
|
|
1008
|
+
const waiting = connection?.status === "connecting" || pending === "sign-in" || pending === "cancel";
|
|
1009
|
+
const profiles = connection?.profiles ?? [];
|
|
1010
|
+
const signedIn = profiles.filter((profile) => !profile.pending && profile.status === "connected");
|
|
1011
|
+
const choosing = connection?.available && !waiting && signedIn.length > 0;
|
|
1012
|
+
const current = profiles.find((profile) => profile.id === connection?.profileId);
|
|
1013
|
+
const differentAccount = (error?.code || connection?.error?.code) === "account_mismatch";
|
|
1014
|
+
const failure = error || connection?.error;
|
|
1015
|
+
const message = differentAccount ? t("differentAccount") : failure && failure.code !== "cancelled" ? failure.message || t("requestFailed") : null;
|
|
1016
|
+
let title = t("connectTitle");
|
|
1017
|
+
let hint = t("subtitle");
|
|
1018
|
+
if (waiting) {
|
|
1019
|
+
title = t("browserTitle");
|
|
1020
|
+
hint = t("authorizeHint");
|
|
1021
|
+
} else if (!connection) {
|
|
1022
|
+
title = t(error ? "connectionFailed" : "planModels");
|
|
1023
|
+
hint = error ? null : t("loading");
|
|
1024
|
+
} else if (!connection.available) {
|
|
1025
|
+
title = t("desktopTitle");
|
|
1026
|
+
hint = t("unavailable");
|
|
1027
|
+
} else if (choosing) {
|
|
1028
|
+
title = t("chooseSignedIn");
|
|
1029
|
+
hint = t("planHint");
|
|
1030
|
+
}
|
|
1031
|
+
function signIn() {
|
|
1032
|
+
const existing = !differentAccount && !current?.requiresNewRegistration && current;
|
|
1033
|
+
const target = existing || profiles.find((profile) => profile.pending);
|
|
1034
|
+
void run("sign-in", target ? { profileId: target.id } : { newProfile: true });
|
|
1035
|
+
}
|
|
1036
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "omgpt-login", children: [
|
|
1037
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "omgpt-login-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PanelIcon, { name: "account", size: 24 }) }),
|
|
1038
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { children: title }),
|
|
1039
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "omgpt-login-hint", role: waiting || !connection ? "status" : void 0, children: hint }),
|
|
1040
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "omgpt-error", role: "alert", children: message }),
|
|
1041
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "omgpt-actions", children: [
|
|
1042
|
+
!connection && error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button, { variant: "outline", size: "sm", onClick: () => {
|
|
1043
|
+
void refresh();
|
|
1044
|
+
}, children: t("retry") }),
|
|
1045
|
+
waiting && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1046
|
+
import_dsh_client_ui_primitives3.Button,
|
|
1047
|
+
{
|
|
1048
|
+
variant: "outline",
|
|
1049
|
+
size: "sm",
|
|
1050
|
+
disabled: pending === "cancel",
|
|
1051
|
+
onClick: () => {
|
|
1052
|
+
void run("cancel");
|
|
1053
|
+
},
|
|
1054
|
+
children: t("cancel")
|
|
1055
|
+
}
|
|
1056
|
+
),
|
|
1057
|
+
choosing && signedIn.map((profile) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1058
|
+
import_dsh_client_ui_primitives3.Button,
|
|
1059
|
+
{
|
|
1060
|
+
variant: "outline",
|
|
1061
|
+
size: "sm",
|
|
1062
|
+
disabled: Boolean(pending),
|
|
1063
|
+
onClick: () => {
|
|
1064
|
+
void run("select-profile", { profileId: profile.id });
|
|
1065
|
+
},
|
|
1066
|
+
children: profileName(profile)
|
|
1067
|
+
},
|
|
1068
|
+
profile.id
|
|
1069
|
+
)),
|
|
1070
|
+
connection?.available && !waiting && !choosing && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1071
|
+
import_dsh_client_ui_primitives3.Button,
|
|
1072
|
+
{
|
|
1073
|
+
className: "omgpt-primary",
|
|
1074
|
+
variant: "primary",
|
|
1075
|
+
size: "sm",
|
|
1076
|
+
disabled: Boolean(pending),
|
|
1077
|
+
onClick: signIn,
|
|
1078
|
+
children: [
|
|
1079
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { className: "omgpt-mark", src: chatgpt_button_black_21_default, width: "16", height: "16", alt: "" }),
|
|
1080
|
+
t("signIn")
|
|
1081
|
+
]
|
|
1082
|
+
}
|
|
1083
|
+
)
|
|
1084
|
+
] })
|
|
1085
|
+
] });
|
|
1086
|
+
}
|
|
1087
|
+
function AccountRow({ profile, current, busy, t, run }) {
|
|
1088
|
+
const [menuOpen, setMenuOpen] = (0, import_react6.useState)(false);
|
|
1089
|
+
const { id, identity, sharing } = profile;
|
|
1090
|
+
const connected = !profile.pending && profile.status === "connected";
|
|
1091
|
+
const email = identity?.email;
|
|
1092
|
+
const display = identity?.name || email || profile.label || t("identityFallback");
|
|
1093
|
+
const secondaryEmail = email !== display ? email : void 0;
|
|
1094
|
+
const initials = identity?.name?.trim().split(/\s+/u).slice(0, 2).map((part) => Array.from(part)[0]).join("");
|
|
1095
|
+
let status;
|
|
1096
|
+
if (profile.pending) status = "pendingAccount";
|
|
1097
|
+
else if (profile.status === "reauth_required") status = "expiredAccount";
|
|
1098
|
+
else if (!connected) status = "signedOut";
|
|
1099
|
+
else if (!sharing) status = "noConsent";
|
|
1100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "omgpt-profile", children: [
|
|
1101
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "omgpt-profile-avatar", "aria-hidden": "true", children: initials || /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PanelIcon, { name: "account", size: 19 }) }),
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "omgpt-profile-text", children: [
|
|
1103
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "omgpt-profile-name", children: [
|
|
1104
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: display }),
|
|
1105
|
+
current && connected && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "omgpt-current-account", children: t("activeAccount") })
|
|
1106
|
+
] }),
|
|
1107
|
+
(secondaryEmail || status) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "omgpt-profile-meta", children: [
|
|
1108
|
+
secondaryEmail && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: secondaryEmail }),
|
|
1109
|
+
status && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t(status) })
|
|
1110
|
+
] })
|
|
1111
|
+
] }),
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "omgpt-profile-actions", children: connected ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1113
|
+
!current && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1114
|
+
"button",
|
|
1115
|
+
{
|
|
1116
|
+
type: "button",
|
|
1117
|
+
className: "omgpt-account-action",
|
|
1118
|
+
disabled: busy,
|
|
1119
|
+
"aria-label": t("switchToAccount", { label: profileName(profile) }),
|
|
1120
|
+
onClick: () => {
|
|
1121
|
+
void run("select-profile", { profileId: id });
|
|
1122
|
+
},
|
|
1123
|
+
children: t("switchAccount")
|
|
1124
|
+
}
|
|
1125
|
+
),
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1127
|
+
import_dsh_client_ui_primitives3.Menu,
|
|
1128
|
+
{
|
|
1129
|
+
open: menuOpen && !busy,
|
|
1130
|
+
align: "end",
|
|
1131
|
+
portal: true,
|
|
1132
|
+
autoFocus: true,
|
|
1133
|
+
dense: true,
|
|
1134
|
+
anchor: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1135
|
+
"button",
|
|
1136
|
+
{
|
|
1137
|
+
type: "button",
|
|
1138
|
+
className: "omgpt-account-more",
|
|
1139
|
+
disabled: busy,
|
|
1140
|
+
"aria-label": t("accountOptions", { label: profileName(profile) || display }),
|
|
1141
|
+
"aria-haspopup": "menu",
|
|
1142
|
+
"aria-expanded": menuOpen && !busy,
|
|
1143
|
+
onClick: () => setMenuOpen((open) => !open),
|
|
1144
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PanelIcon, { name: "more" })
|
|
1145
|
+
}
|
|
1146
|
+
),
|
|
1147
|
+
items: [
|
|
1148
|
+
{ type: "label", id: "account", text: email || display },
|
|
1149
|
+
{ id: "sign-out", label: t("signOut"), icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PanelIcon, { name: "signOut", size: 16 }) }
|
|
1150
|
+
],
|
|
1151
|
+
onClose: () => setMenuOpen(false),
|
|
1152
|
+
onSelect: () => {
|
|
1153
|
+
setMenuOpen(false);
|
|
1154
|
+
void run("sign-out-profile", { profileId: id });
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
)
|
|
1158
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1159
|
+
"button",
|
|
1160
|
+
{
|
|
1161
|
+
type: "button",
|
|
1162
|
+
className: "omgpt-account-action",
|
|
1163
|
+
disabled: busy,
|
|
1164
|
+
"aria-haspopup": "dialog",
|
|
1165
|
+
onClick: () => {
|
|
1166
|
+
void run("add-account", { profileId: id });
|
|
1167
|
+
},
|
|
1168
|
+
children: t(profile.pending ? "resumeAccount" : "reconnectAccount")
|
|
1169
|
+
}
|
|
1170
|
+
) })
|
|
1171
|
+
] });
|
|
1172
|
+
}
|
|
1173
|
+
function Account({ t, state }) {
|
|
1174
|
+
const { connection, pending, error, run } = state;
|
|
1175
|
+
const { profileId, profiles = [] } = connection;
|
|
1176
|
+
const rows = profiles.filter((profile) => profile.status === "connected" || !profile.requiresNewRegistration);
|
|
1177
|
+
if (profileId && connection.status === "connected" && !rows.some((profile) => profile.id === profileId)) {
|
|
1178
|
+
rows.unshift({
|
|
1179
|
+
id: profileId,
|
|
1180
|
+
label: connection.profileLabel,
|
|
1181
|
+
identity: connection.identity,
|
|
1182
|
+
status: connection.status,
|
|
1183
|
+
sharing: connection.sharing
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
const waiting = connection.status === "connecting" || pending === "enable" || pending === "cancel";
|
|
1187
|
+
const busy = waiting || Boolean(pending) && !isAccountDialogAction(pending);
|
|
1188
|
+
const needsConsent = connection.status === "connected" && !connection.sharing;
|
|
1189
|
+
const message = error ? !isAccountDialogAction(error.action) && (error.message || t("requestFailed")) : !waiting && connection.error?.message;
|
|
1190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "omgpt-account", children: [
|
|
1191
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "omgpt-profile-list", children: rows.map((profile) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1192
|
+
AccountRow,
|
|
1193
|
+
{
|
|
1194
|
+
profile,
|
|
1195
|
+
current: profile.id === profileId,
|
|
1196
|
+
busy,
|
|
1197
|
+
t,
|
|
1198
|
+
run
|
|
1199
|
+
},
|
|
1200
|
+
profile.id
|
|
1201
|
+
)) }),
|
|
1202
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "omgpt-error", role: "alert", children: message }),
|
|
1203
|
+
waiting ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "omgpt-account-flow", children: [
|
|
1204
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "status", children: t("connecting") }),
|
|
1205
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "omgpt-actions", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1206
|
+
import_dsh_client_ui_primitives3.Button,
|
|
1207
|
+
{
|
|
1208
|
+
variant: "outline",
|
|
1209
|
+
size: "sm",
|
|
1210
|
+
disabled: pending === "cancel",
|
|
1211
|
+
onClick: () => {
|
|
1212
|
+
void run("cancel");
|
|
1213
|
+
},
|
|
1214
|
+
children: t("cancel")
|
|
1215
|
+
}
|
|
1216
|
+
) })
|
|
1217
|
+
] }) : needsConsent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "omgpt-account-flow", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "omgpt-actions", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button, { variant: "primary", size: "sm", disabled: busy, onClick: () => {
|
|
1218
|
+
void run("enable", { profileId });
|
|
1219
|
+
}, children: t("enable") }) }) }),
|
|
1220
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1221
|
+
"button",
|
|
1222
|
+
{
|
|
1223
|
+
type: "button",
|
|
1224
|
+
className: "omgpt-account-add",
|
|
1225
|
+
disabled: busy,
|
|
1226
|
+
"aria-haspopup": "dialog",
|
|
1227
|
+
onClick: () => {
|
|
1228
|
+
void run("add-account", { newProfile: true });
|
|
1229
|
+
},
|
|
1230
|
+
children: [
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PanelIcon, { name: "plus", size: 17 }),
|
|
1232
|
+
t("newAccount")
|
|
1233
|
+
]
|
|
1234
|
+
}
|
|
1235
|
+
)
|
|
1236
|
+
] });
|
|
1237
|
+
}
|
|
1238
|
+
function useModelCatalog(profileId) {
|
|
1239
|
+
const [data, setData] = (0, import_react6.useState)(null);
|
|
1240
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
1241
|
+
const [revision, setRevision] = (0, import_react6.useState)(0);
|
|
1242
|
+
const [refreshing, setRefreshing] = (0, import_react6.useState)(false);
|
|
1243
|
+
const refresh = (0, import_react6.useCallback)(() => {
|
|
1244
|
+
setRevision((value) => value + 1);
|
|
1245
|
+
}, []);
|
|
1246
|
+
(0, import_react6.useEffect)(() => {
|
|
1247
|
+
const controller = new AbortController();
|
|
1248
|
+
const { signal } = controller;
|
|
1249
|
+
setRefreshing(true);
|
|
1250
|
+
void (async () => {
|
|
1251
|
+
try {
|
|
1252
|
+
const result = await readModels(profileId, signal, revision > 0);
|
|
1253
|
+
if (!signal.aborted) {
|
|
1254
|
+
setData(profileId ? result.models : result.models.map((model) => ({ ...model, available: false, enabled: false })));
|
|
1255
|
+
setError(result.catalogError ?? null);
|
|
1256
|
+
}
|
|
1257
|
+
} catch (failure) {
|
|
1258
|
+
if (!signal.aborted) {
|
|
1259
|
+
setError(failure?.message ?? "");
|
|
1260
|
+
setData((current) => current?.map((model) => ({ ...model, available: false })) ?? null);
|
|
1261
|
+
}
|
|
1262
|
+
} finally {
|
|
1263
|
+
if (!signal.aborted) setRefreshing(false);
|
|
1264
|
+
}
|
|
1265
|
+
})();
|
|
1266
|
+
return () => {
|
|
1267
|
+
controller.abort();
|
|
1268
|
+
};
|
|
1269
|
+
}, [profileId, revision]);
|
|
1270
|
+
return { data, error, refresh, refreshing, update: setData };
|
|
1271
|
+
}
|
|
1272
|
+
async function readModels(profileId, signal, force) {
|
|
1273
|
+
const query = new URLSearchParams();
|
|
1274
|
+
if (profileId) query.set("profileId", profileId);
|
|
1275
|
+
if (force) query.set("refresh", "1");
|
|
1276
|
+
const data = await request(query.size ? "models?" + query : "models", signal);
|
|
1277
|
+
if (!Array.isArray(data?.models) || !data.models.every((model) => typeof model?.id === "string" && typeof model.name === "string" && typeof model.available === "boolean" && typeof model.enabled === "boolean")) throw new Error();
|
|
1278
|
+
return data;
|
|
1279
|
+
}
|
|
1280
|
+
function WorkspaceBody({ t, language, state, profileId }) {
|
|
1281
|
+
const { connection, pending, run } = state;
|
|
1282
|
+
const models = useModelCatalog(profileId);
|
|
1283
|
+
if (!profileId) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModelCatalog, { t, language, resource: models, hint: t("needsConsent"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Account, { t, state }) });
|
|
1284
|
+
const activeProfile = connection.profiles?.find((profile) => profile.id === profileId);
|
|
1285
|
+
const activeName = activeProfile && profileName(activeProfile) || connection.identity?.email || connection.identity?.name || connection.profileLabel || t("identityFallback");
|
|
1286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1287
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModelCatalog, { t, language, resource: models, profileId, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("details", { className: "omgpt-details omgpt-account-details", children: [
|
|
1288
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("summary", { children: [
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PanelIcon, { name: "account", size: 18 }),
|
|
1290
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "omgpt-account-identity", children: [
|
|
1291
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t("activeAccount") }),
|
|
1292
|
+
" ",
|
|
1293
|
+
activeName
|
|
1294
|
+
] }),
|
|
1295
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "omgpt-manage-label", children: t("manageAccounts") }),
|
|
1296
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PanelIcon, { name: "down", size: 15 })
|
|
1297
|
+
] }),
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Account, { t, state })
|
|
1299
|
+
] }) }),
|
|
1300
|
+
connection.features?.webSearch && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("details", { className: "omgpt-details omgpt-legacy-defaults", children: [
|
|
1301
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("summary", { children: [
|
|
1302
|
+
t("legacyDefaults"),
|
|
1303
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PanelIcon, { name: "down", size: 15 })
|
|
1304
|
+
] }),
|
|
1305
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: t("legacyHint") }),
|
|
1306
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button, { variant: "outline", size: "sm", disabled: Boolean(pending), onClick: () => {
|
|
1307
|
+
void run("features", { ...connection.features, webSearch: false });
|
|
1308
|
+
}, children: t("resetDefaults") })
|
|
1309
|
+
] })
|
|
1310
|
+
] });
|
|
1311
|
+
}
|
|
1312
|
+
function ChatGPTWorkspace({ ctx, language, active = true }) {
|
|
1313
|
+
const selectedLanguage = chatLanguage(language, ctx);
|
|
1314
|
+
const t = translate(selectedLanguage);
|
|
1315
|
+
const state = useConnection();
|
|
1316
|
+
const { connection, pending, error, run, dismissError } = state;
|
|
1317
|
+
const authorizing = connection?.addingAccount || isAccountDialogAction(pending);
|
|
1318
|
+
const dialogError = isAccountDialogAction(error?.action) ? error : null;
|
|
1319
|
+
const dialogOpen = active && Boolean(authorizing || dialogError);
|
|
1320
|
+
function closeDialog() {
|
|
1321
|
+
if (authorizing) {
|
|
1322
|
+
if (pending !== "cancel-add") void run("cancel-add");
|
|
1323
|
+
} else dismissError();
|
|
1324
|
+
}
|
|
1325
|
+
const connectedProfile = connection?.profiles?.some((profile) => profile.id === connection.profileId && profile.status === "connected" && !profile.pending);
|
|
1326
|
+
const signedIn = connection?.available && (connection.status === "connected" || connection.status === "connecting" && connectedProfile);
|
|
1327
|
+
const profileId = signedIn && connection.status === "connected" && connection.sharing ? connection.profileId : void 0;
|
|
1328
|
+
let body = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LoginScreen, { t, state });
|
|
1329
|
+
if (signedIn) {
|
|
1330
|
+
body = connection.status === "connecting" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Account, { t, state }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WorkspaceBody, { t, language: selectedLanguage, state, profileId }, profileId ?? "");
|
|
1331
|
+
}
|
|
1332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "omgpt-workspace", "aria-label": "ChatGPT", children: [
|
|
1333
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { inert: dialogOpen ? "" : void 0, children: body }),
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1335
|
+
import_dsh_client_ui_primitives3.Modal,
|
|
1336
|
+
{
|
|
1337
|
+
open: dialogOpen,
|
|
1338
|
+
title: t(dialogError ? "authorizationFailed" : "browserTitle"),
|
|
1339
|
+
description: dialogError ? dialogError.message || t("requestFailed") : t("authorizeHint"),
|
|
1340
|
+
closeLabel: t(authorizing ? "cancel" : "close"),
|
|
1341
|
+
onClose: closeDialog,
|
|
1342
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button, { variant: "outline", autoFocus: true, disabled: pending === "cancel-add", onClick: closeDialog, children: t(authorizing ? "cancel" : "close") })
|
|
1343
|
+
}
|
|
1344
|
+
)
|
|
1345
|
+
] });
|
|
1346
|
+
}
|
|
1347
|
+
function registerChatGPTClient(ctx) {
|
|
1348
|
+
ctx.effect(() => ctx.locale.register(providerId, dictionaries), "Model Center ChatGPT translations");
|
|
1349
|
+
ctx.effect(() => {
|
|
1350
|
+
const style = document.createElement("style");
|
|
1351
|
+
style.dataset.plugin = providerId;
|
|
1352
|
+
style.textContent = [workspace_default, native_chat_options_default].join("\n");
|
|
1353
|
+
document.head.append(style);
|
|
1354
|
+
return () => style.remove();
|
|
1355
|
+
}, "Model Center ChatGPT styles");
|
|
1356
|
+
registerNativeChatOptions(ctx, useConnection);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
// model-sources.jsx
|
|
1360
|
+
var import_react7 = require("react");
|
|
1361
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1362
|
+
var sources2 = ["kilo", "chatgpt"];
|
|
1363
|
+
function ModelSources({ ctx, t, language, children }) {
|
|
1364
|
+
const id = (0, import_react7.useId)();
|
|
1365
|
+
const tabs = (0, import_react7.useRef)([]);
|
|
1366
|
+
const [selected, setSelected] = (0, import_react7.useState)("kilo");
|
|
1367
|
+
const [visitedChatGPT, setVisitedChatGPT] = (0, import_react7.useState)(false);
|
|
1368
|
+
function select(source) {
|
|
1369
|
+
if (source === "chatgpt") setVisitedChatGPT(true);
|
|
1370
|
+
setSelected(source);
|
|
1371
|
+
}
|
|
1372
|
+
function navigate(event, index) {
|
|
1373
|
+
let target;
|
|
1374
|
+
switch (event.key) {
|
|
1375
|
+
case "ArrowRight":
|
|
1376
|
+
target = (index + 1) % sources2.length;
|
|
1377
|
+
break;
|
|
1378
|
+
case "ArrowLeft":
|
|
1379
|
+
target = (index + sources2.length - 1) % sources2.length;
|
|
1380
|
+
break;
|
|
1381
|
+
case "Home":
|
|
1382
|
+
target = 0;
|
|
1383
|
+
break;
|
|
1384
|
+
case "End":
|
|
1385
|
+
target = sources2.length - 1;
|
|
1386
|
+
break;
|
|
1387
|
+
default:
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
event.preventDefault();
|
|
1391
|
+
select(sources2[target]);
|
|
1392
|
+
tabs.current[target].focus();
|
|
1393
|
+
}
|
|
1394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "dsh-model-sources", role: "tablist", "aria-label": t("sources"), children: sources2.map((source, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1396
|
+
"button",
|
|
1397
|
+
{
|
|
1398
|
+
type: "button",
|
|
1399
|
+
role: "tab",
|
|
1400
|
+
id: `${id}-${source}-tab`,
|
|
1401
|
+
"aria-selected": source === selected,
|
|
1402
|
+
"aria-controls": `${id}-${source}-panel`,
|
|
1403
|
+
tabIndex: source === selected ? 0 : -1,
|
|
1404
|
+
ref: (button) => {
|
|
1405
|
+
tabs.current[index] = button;
|
|
1406
|
+
},
|
|
1407
|
+
onKeyDown: (event) => navigate(event, index),
|
|
1408
|
+
onClick: () => select(source),
|
|
1409
|
+
children: t(`${source}Tab`)
|
|
1410
|
+
},
|
|
1411
|
+
source
|
|
1412
|
+
)) }),
|
|
1413
|
+
sources2.map((source) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1414
|
+
"div",
|
|
1415
|
+
{
|
|
1416
|
+
role: "tabpanel",
|
|
1417
|
+
className: "dsh-model-source-panel",
|
|
1418
|
+
id: `${id}-${source}-panel`,
|
|
1419
|
+
"aria-labelledby": `${id}-${source}-tab`,
|
|
1420
|
+
hidden: source !== selected,
|
|
1421
|
+
tabIndex: 0,
|
|
1422
|
+
children: source === "kilo" ? children : visitedChatGPT && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChatGPTWorkspace, { ctx, language, active: selected === source })
|
|
1423
|
+
},
|
|
1424
|
+
source
|
|
1425
|
+
))
|
|
1426
|
+
] });
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// model-page.css
|
|
1430
|
+
var model_page_default = ".dsh-free-model-page {\n --model-surface: var(--dsw-alias-bg-layer-1, Canvas);\n --model-ink: var(--dsw-alias-label-primary, CanvasText);\n --model-muted: var(--dsw-alias-label-secondary, GrayText);\n --model-line: var(--dsw-alias-border-l2, color-mix(in srgb, currentColor 12%, transparent));\n --model-hover: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 6%, transparent));\n --model-error: var(--dsw-alias-state-error-primary, #b13e3a);\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n min-width: 0;\n overflow: auto;\n color: var(--model-ink);\n background: var(--model-surface);\n font-size: 14px;\n line-height: 1.5;\n container: model-page / inline-size;\n}\n.dsh-free-model-content {\n box-sizing: border-box;\n width: min(100%, 840px);\n padding: 44px 32px 36px;\n margin-inline: auto;\n}\n.dsh-free-model-header h1 { margin: 0; font-size: 30px; font-weight: 600; line-height: 1.25; letter-spacing: -.03em; }\n.dsh-free-model-hint { margin: 6px 0 0; color: var(--model-muted); }\n.dsh-model-sources {\n display: flex; align-items: stretch; gap: 22px; margin-block-start: 24px;\n border-bottom: 1px solid var(--model-line);\n}\n.dsh-model-sources button {\n position: relative; box-sizing: border-box; min-height: 42px; padding: 6px 2px 10px;\n border: 0; background: transparent; color: var(--model-muted);\n font: inherit; font-weight: 550; cursor: pointer;\n}\n.dsh-model-sources button[aria-selected=true], .dsh-model-sources button:hover { color: var(--model-ink); }\n.dsh-model-sources button[aria-selected=true]::after {\n content: ''; position: absolute; inset: auto 0 -1px; height: 2px; border-radius: 2px; background: currentColor;\n}\n.dsh-model-source-panel { min-width: 0; padding-block-start: 26px; }\n.dsh-model-source-panel[hidden] { display: none; }\n.dsh-free-model-page :where(button, a, summary, [role=tabpanel]):focus-visible {\n outline: 2px solid var(--model-ink); outline-offset: 3px;\n}\n.dsh-free-model-catalog .dsh-model-hub-models { margin-block-start: 0; }\n.dsh-free-model-actions { display: flex; align-items: center; gap: 2px; }\n.dsh-free-model-action-anchor { display: inline-flex; }\n.dsh-free-model-actions button {\n display: grid; place-items: center; width: 32px; height: 32px; padding: 0;\n border: 0; border-radius: 50%; background: transparent; color: var(--model-muted); cursor: pointer;\n}\n.dsh-free-model-actions button:enabled:hover { background: var(--model-hover); color: var(--model-ink); }\n.dsh-free-model-actions button:disabled { pointer-events: none; opacity: .55; }\n@media (prefers-reduced-motion: no-preference) {\n .dsh-free-model-actions button[aria-busy=true] svg { animation: open-model-refresh 1.2s linear infinite; }\n @keyframes open-model-refresh { to { transform: rotate(360deg); } }\n}\n.dsh-free-model-status { margin: 18px 0 0; color: var(--model-muted); font-size: 13px; }\n.dsh-free-model-error { color: var(--model-error); overflow-wrap: anywhere; }\n.dsh-model-hub-row .dsh-free-model-error { grid-column: 1 / -1; margin: 0; font-size: 13px; }\n.dsh-free-model-badge, .dsh-free-model-reason, .dsh-free-model-duration { font-size: 12px; color: var(--model-muted); }\n.dsh-free-model-badge { display: inline-flex; align-items: center; gap: 5px; }\n.dsh-free-model-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }\n.dsh-free-model-badge[data-status=available]::before { background: var(--dsw-alias-state-success-primary, #278251); }\n.dsh-free-model-badge[data-status=unavailable]::before { background: var(--model-error); }\n.dsh-free-model-duration { font-variant-numeric: tabular-nums; white-space: nowrap; }\n\n.dsh-free-model-update-banner {\n display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 9px 14px; margin-block-start: 16px;\n border: 1px solid var(--model-line); border-radius: 10px;\n}\n.dsh-free-model-update-banner-content { flex: 1; margin: 0; }\n.dsh-free-model-update-title { font-weight: 550; }\n.dsh-free-model-update-version { margin-inline-start: 8px; color: var(--model-muted); font-size: 13px; }\n.dsh-free-model-update-action, .dsh-free-model-about-content > a {\n color: var(--model-ink); font-size: 13px; text-decoration: underline; text-underline-offset: 3px;\n}\n.dsh-free-model-update-badge {\n display: inline-flex; padding: 1px 6px; border-radius: 999px; background: var(--dsw-alias-label-primary);\n color: var(--dsw-alias-bg-layer-1); font-size: 11px; line-height: 16px; font-weight: 550; white-space: nowrap;\n}\n.dsh-free-model-update-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-label-primary); }\n.dsh-free-model-update-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n\n.dsh-free-model-about { margin-block-start: 28px; color: var(--model-muted); font-size: 13px; }\n.dsh-free-model-about > h2 { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: 16px; font-weight: 600; color: var(--model-ink); }\n.dsh-free-model-about > h2 span { font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 400; color: var(--model-muted); }\n.dsh-free-model-about-content { padding-block: 8px; }\n.dsh-free-model-recommendations { margin-block-start: 20px; color: var(--model-ink); }\n.dsh-free-model-recommendations h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }\n.dsh-free-model-plugins { list-style: none; margin: 0; padding: 0; }\n.dsh-free-model-plugin { display: grid; align-items: center; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; padding-block: 12px; }\n.dsh-free-model-plugin + .dsh-free-model-plugin { border-block-start: 1px solid var(--model-line); }\n.dsh-free-model-plugin-name { font-weight: 550; }\n.dsh-free-model-plugin p { margin: 2px 0 0; color: var(--model-muted); overflow-wrap: anywhere; }\n.dsh-free-model-plugin-actions { display: flex; flex-wrap: wrap; gap: 6px; }\n.dsh-free-model-plugin-action {\n display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 30px;\n padding: 4px 12px; border: 1px solid var(--model-line); border-radius: 999px;\n background: transparent; color: var(--model-ink); font: inherit; text-decoration: none; white-space: nowrap; cursor: pointer;\n}\nbutton.dsh-free-model-plugin-action:enabled:hover { background: var(--model-hover); }\na.dsh-free-model-plugin-action {\n background: var(--dsw-alias-button-primary-fill, var(--model-ink));\n color: var(--dsw-alias-label-primary-foreground, var(--model-surface));\n}\na.dsh-free-model-plugin-action:hover {\n background: var(--dsw-alias-button-primary-hover, color-mix(in srgb, var(--model-ink) 85%, var(--model-surface)));\n}\n.dsh-free-model-plugin-action:disabled { background: transparent; color: var(--model-muted); cursor: default; }\n.dsh-free-model-plugin .dsh-free-model-error { grid-column: 1 / -1; color: var(--model-error); }\n@container model-page (max-width: 520px) {\n .dsh-free-model-content { padding: 24px 16px; }\n .dsh-free-model-header h1 { font-size: 26px; }\n .dsh-model-sources { margin-block-start: 18px; }\n .dsh-model-source-panel { padding-block-start: 20px; }\n}\n@container model-page (max-width: 370px) {\n .dsh-free-model-plugin { grid-template-columns: minmax(0, 1fr); }\n}\n";
|
|
1431
|
+
|
|
1432
|
+
// client.js
|
|
1433
|
+
var panelId = "dsh-free-model";
|
|
1434
|
+
var apiPath = "/api/dsh-free-model/models";
|
|
1435
|
+
var availabilityPath = `${apiPath}/availability`;
|
|
1436
|
+
var updatePath = "/api/dsh-free-model/update";
|
|
1437
|
+
var updateCheckInterval = 5 * 60 * 1e3;
|
|
1438
|
+
var packageName = "dsh-open-model";
|
|
1439
|
+
var repositoryUrl = "https://github.com/houyanchao/dsh-open-model";
|
|
1440
|
+
var npmRegistry = "https://registry.npmjs.org/";
|
|
1441
|
+
var publishedVersion = /^\d+\.\d+\.\d+(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?$/i;
|
|
1442
|
+
var recommendedPlugins = [
|
|
1443
|
+
{ name: "dsh-timeline", description: "timelineDescription" },
|
|
1444
|
+
{ name: "dsh-use-chatgpt", description: "chatgptDescription" },
|
|
1445
|
+
{ name: "timeline", description: "browserDescription", stores: [
|
|
1446
|
+
{ label: "chrome", href: "https://chromewebstore.google.com/detail/fgebdnlceacaiaeikopldglhffljjlhh" },
|
|
1447
|
+
{ label: "edge", href: "https://microsoftedge.microsoft.com/addons/detail/ekednjjojnhlajfobalaaihkibbdcbab" }
|
|
1448
|
+
] }
|
|
1449
|
+
];
|
|
1450
|
+
var resultStatuses = /* @__PURE__ */ new Set(["checking", "available", "unavailable"]);
|
|
1451
|
+
var emptyAvailability = { checking: false, models: [] };
|
|
1452
|
+
var catalogReasonKeys = /* @__PURE__ */ new Map([
|
|
1453
|
+
["output-limit-unenforceable", "outputLimitUnavailable"],
|
|
1454
|
+
["provider-unavailable", "unverified"],
|
|
1455
|
+
["not-offered", "notListed"]
|
|
1456
|
+
]);
|
|
1457
|
+
var reasonKeys = new Map(Object.entries({
|
|
1458
|
+
AUTH: "reasonAuth",
|
|
1459
|
+
QUOTA: "reasonQuota",
|
|
1460
|
+
RATE_LIMIT: "reasonRateLimit",
|
|
1461
|
+
TIMEOUT: "reasonTimeout",
|
|
1462
|
+
MODEL_UNAVAILABLE: "reasonRoute",
|
|
1463
|
+
TRANSPORT: "reasonNetwork",
|
|
1464
|
+
INVALID_REQUEST: "reasonRequest",
|
|
1465
|
+
MALFORMED_RESPONSE: "reasonFormat",
|
|
1466
|
+
EMPTY_RESPONSE: "reasonEmpty",
|
|
1467
|
+
SERVER: "reasonServer"
|
|
1468
|
+
}));
|
|
1469
|
+
var messages = {
|
|
1470
|
+
zh: {
|
|
1471
|
+
title: "OpenModel",
|
|
1472
|
+
introduction: "\u4E3A DSH \u63D0\u4F9B\u514D\u8D39\u6A21\u578B\uFF0C\u8BA9 DSH \u76F4\u63A5\u4F7F\u7528\u4F60\u7684 ChatGPT \u5957\u9910\u989D\u5EA6\u3002",
|
|
1473
|
+
sources: "\u6A21\u578B\u6765\u6E90",
|
|
1474
|
+
kiloTab: "\u514D\u8D39\u6A21\u578B",
|
|
1475
|
+
chatgptTab: "ChatGPT",
|
|
1476
|
+
about: "\u5173\u4E8E Open Model",
|
|
1477
|
+
project: "GitHub \u4ED3\u5E93",
|
|
1478
|
+
checkProgress: "\u6D4B\u901F\u4E2D {done}/{total}",
|
|
1479
|
+
refresh: "\u5237\u65B0\u5217\u8868",
|
|
1480
|
+
loading: "\u6B63\u5728\u8BFB\u53D6 Kilo \u6A21\u578B\u5217\u8868\u2026",
|
|
1481
|
+
empty: "\u5C1A\u672A\u914D\u7F6E\u514D\u8D39\u6A21\u578B\u3002",
|
|
1482
|
+
notListed: "Kilo \u6682\u672A\u63D0\u4F9B\u6B64\u514D\u8D39\u6A21\u578B",
|
|
1483
|
+
unverified: "\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u53EF\u7528\u6027",
|
|
1484
|
+
outputLimitUnavailable: "Kilo \u65E0\u6CD5\u4FDD\u8BC1\u914D\u7F6E\u7684\u8F93\u51FA\u4E0A\u9650",
|
|
1485
|
+
loadError: "\u65E0\u6CD5\u8BFB\u53D6\u6A21\u578B\u5217\u8868\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
1486
|
+
saveError: "\u65E0\u6CD5\u4FDD\u5B58\u6B64\u6A21\u578B\u7684\u663E\u793A\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
1487
|
+
toggle: "\u5728\u6A21\u578B\u9009\u62E9\u5668\u4E2D\u663E\u793A {name}",
|
|
1488
|
+
checkAvailability: "\u6D4B\u901F",
|
|
1489
|
+
checkingAvailability: "\u6D4B\u901F\u4E2D\u2026",
|
|
1490
|
+
checkCooldown: "\u8BF7\u7A0D\u540E\u518D\u6D4B",
|
|
1491
|
+
checkError: "\u6D4B\u901F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
1492
|
+
checkProgressError: "\u65E0\u6CD5\u66F4\u65B0\u6D4B\u901F\u8FDB\u5EA6\uFF0C\u8BF7\u5237\u65B0\u5217\u8868\u3002",
|
|
1493
|
+
checking: "\u6D4B\u901F\u4E2D",
|
|
1494
|
+
available: "\u53EF\u7528",
|
|
1495
|
+
unavailable: "\u4E0D\u53EF\u7528",
|
|
1496
|
+
checkedAt: "\u68C0\u6D4B\u65F6\u95F4 {time}",
|
|
1497
|
+
reasonAuth: "\u533F\u540D\u8BBF\u95EE\u88AB\u62D2\u7EDD",
|
|
1498
|
+
reasonQuota: "\u514D\u8D39\u989D\u5EA6\u4E0D\u8DB3",
|
|
1499
|
+
reasonRateLimit: "\u6682\u65F6\u9650\u6D41",
|
|
1500
|
+
reasonTimeout: "\u8D85\u65F6",
|
|
1501
|
+
reasonRoute: "\u4E0A\u6E38\u6682\u672A\u63D0\u4F9B\u6A21\u578B",
|
|
1502
|
+
reasonNetwork: "\u65E0\u6CD5\u8FDE\u63A5 Kilo",
|
|
1503
|
+
reasonRequest: "\u8BF7\u6C42\u88AB\u62D2\u7EDD",
|
|
1504
|
+
reasonFormat: "\u54CD\u5E94\u683C\u5F0F\u5F02\u5E38",
|
|
1505
|
+
reasonEmpty: "\u672A\u6536\u5230\u6587\u672C\u56DE\u590D",
|
|
1506
|
+
reasonServer: "\u4E0A\u6E38\u670D\u52A1\u5F02\u5E38",
|
|
1507
|
+
reasonUnknown: "\u672C\u6B21\u68C0\u6D4B\u5931\u8D25",
|
|
1508
|
+
updateBadge: "\u66F4\u65B0",
|
|
1509
|
+
updateTitle: "\u6709\u65B0\u7248\u672C",
|
|
1510
|
+
updateDetails: "\u67E5\u770B\u66F4\u65B0",
|
|
1511
|
+
otherPlugins: "\u4F5C\u8005\u7684\u5176\u4ED6\u63D2\u4EF6",
|
|
1512
|
+
timelineDescription: "\u4E3A DSH \u5BF9\u8BDD\u6DFB\u52A0\u63D0\u95EE\u65F6\u95F4\u8F74\u3001\u6536\u85CF\u5939\u3001\u63D0\u793A\u8BCD\u5E93\u548C\u591A\u683C\u5F0F\u5BFC\u51FA\u3002",
|
|
1513
|
+
chatgptDescription: "\u8BA9 DSH \u76F4\u63A5\u4F7F\u7528\u4F60\u7684 ChatGPT \u5957\u9910\u989D\u5EA6\u3002",
|
|
1514
|
+
browserDescription: "\u4E3A ChatGPT\u3001Gemini\u3001DeepSeek \u7B49\u7F51\u9875\u6DFB\u52A0\u5BF9\u8BDD\u65F6\u95F4\u8F74\u3001\u6536\u85CF\u5939\u548C\u63D0\u793A\u8BCD\u5E93\u3002",
|
|
1515
|
+
install: "\u5B89\u88C5",
|
|
1516
|
+
installed: "\u5DF2\u5B89\u88C5",
|
|
1517
|
+
installing: "\u5B89\u88C5\u4E2D\u2026",
|
|
1518
|
+
checkInstall: "\u68C0\u6D4B\u4E2D\u2026",
|
|
1519
|
+
retryInventory: "\u91CD\u65B0\u68C0\u6D4B",
|
|
1520
|
+
installUnavailable: "\u5B89\u88C5\u4E0D\u53EF\u7528",
|
|
1521
|
+
installAction: "{name} \xB7 {action}",
|
|
1522
|
+
inventoryError: "\u65E0\u6CD5\u8BFB\u53D6\u5DF2\u5B89\u88C5\u63D2\u4EF6\uFF0C\u8BF7\u91CD\u65B0\u68C0\u6D4B\u3002",
|
|
1523
|
+
installError: "\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
1524
|
+
chrome: "Chrome \u7248",
|
|
1525
|
+
edge: "Edge \u7248",
|
|
1526
|
+
storeLabel: "{name} \xB7 {store}"
|
|
1527
|
+
},
|
|
1528
|
+
en: {
|
|
1529
|
+
title: "OpenModel",
|
|
1530
|
+
introduction: "Use free models in DSH and connect your ChatGPT account to use your plan\u2019s allowance.",
|
|
1531
|
+
sources: "Model sources",
|
|
1532
|
+
kiloTab: "Free models",
|
|
1533
|
+
chatgptTab: "ChatGPT",
|
|
1534
|
+
about: "About Open Model",
|
|
1535
|
+
project: "GitHub repository",
|
|
1536
|
+
checkProgress: "Testing speed {done}/{total}",
|
|
1537
|
+
refresh: "Refresh list",
|
|
1538
|
+
loading: "Loading the Kilo model list\u2026",
|
|
1539
|
+
empty: "No free models are configured.",
|
|
1540
|
+
notListed: "Currently unavailable from Kilo for free",
|
|
1541
|
+
unverified: "Availability could not be verified",
|
|
1542
|
+
outputLimitUnavailable: "Kilo cannot enforce the configured output limit",
|
|
1543
|
+
loadError: "Could not load the model list. Try again.",
|
|
1544
|
+
saveError: "Could not save visibility for this model. Try again.",
|
|
1545
|
+
toggle: "Show {name} in the model picker",
|
|
1546
|
+
checkAvailability: "Speed test",
|
|
1547
|
+
checkingAvailability: "Testing speed\u2026",
|
|
1548
|
+
checkCooldown: "Check again shortly",
|
|
1549
|
+
checkError: "Could not start the speed test. Try again.",
|
|
1550
|
+
checkProgressError: "Could not update speed test progress. Refresh the list.",
|
|
1551
|
+
checking: "Testing speed",
|
|
1552
|
+
available: "Available",
|
|
1553
|
+
unavailable: "Unavailable",
|
|
1554
|
+
checkedAt: "Checked at {time}",
|
|
1555
|
+
reasonAuth: "Anonymous access denied",
|
|
1556
|
+
reasonQuota: "Free quota exhausted",
|
|
1557
|
+
reasonRateLimit: "Temporarily rate limited",
|
|
1558
|
+
reasonTimeout: "Request timed out",
|
|
1559
|
+
reasonRoute: "Model unavailable upstream",
|
|
1560
|
+
reasonNetwork: "Could not connect to Kilo",
|
|
1561
|
+
reasonRequest: "Request rejected",
|
|
1562
|
+
reasonFormat: "Unexpected response format",
|
|
1563
|
+
reasonEmpty: "No text reply received",
|
|
1564
|
+
reasonServer: "Upstream service error",
|
|
1565
|
+
reasonUnknown: "Check failed",
|
|
1566
|
+
updateBadge: "Update",
|
|
1567
|
+
updateTitle: "Update available",
|
|
1568
|
+
updateDetails: "View update",
|
|
1569
|
+
otherPlugins: "More plugins by this author",
|
|
1570
|
+
timelineDescription: "Add a question timeline, bookmark folders, a prompt library, and chat exports to DSH.",
|
|
1571
|
+
chatgptDescription: "Use your ChatGPT plan allowance directly in DSH.",
|
|
1572
|
+
browserDescription: "Add a chat timeline, bookmarks, and a prompt library to ChatGPT, Gemini, DeepSeek, and other AI chat sites.",
|
|
1573
|
+
install: "Install",
|
|
1574
|
+
installed: "Installed",
|
|
1575
|
+
installing: "Installing\u2026",
|
|
1576
|
+
checkInstall: "Checking\u2026",
|
|
1577
|
+
retryInventory: "Check again",
|
|
1578
|
+
installUnavailable: "Install unavailable",
|
|
1579
|
+
installAction: "{name} \xB7 {action}",
|
|
1580
|
+
inventoryError: "Could not load installed plugins. Check again.",
|
|
1581
|
+
installError: "Installation failed. Try again.",
|
|
1582
|
+
chrome: "Chrome",
|
|
1583
|
+
edge: "Edge",
|
|
1584
|
+
storeLabel: "{name} \xB7 {store}"
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
async function request2(path, signal, body) {
|
|
1588
|
+
const headers = { accept: "application/json" };
|
|
1589
|
+
if (body !== void 0) headers["content-type"] = "application/json";
|
|
1590
|
+
const response = await fetch(path, {
|
|
1591
|
+
method: body === void 0 ? "GET" : "POST",
|
|
1592
|
+
headers,
|
|
1593
|
+
cache: "no-store",
|
|
1594
|
+
signal,
|
|
1595
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
1596
|
+
});
|
|
1597
|
+
const data = await response.json().catch(() => void 0);
|
|
1598
|
+
if (!response.ok) throw new Error(typeof data?.error === "string" ? data.error : "");
|
|
1599
|
+
return data;
|
|
1600
|
+
}
|
|
1601
|
+
function monitorUpdates(ctx) {
|
|
1602
|
+
let update = null;
|
|
1603
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1604
|
+
ctx.effect(() => {
|
|
1605
|
+
const controller = new AbortController();
|
|
1606
|
+
const { signal } = controller;
|
|
1607
|
+
let checking = false;
|
|
1608
|
+
async function refresh() {
|
|
1609
|
+
if (checking || signal.aborted) return;
|
|
1610
|
+
checking = true;
|
|
1611
|
+
let next = update && { currentVersion: update.currentVersion };
|
|
1612
|
+
try {
|
|
1613
|
+
const data = await request2(updatePath, signal);
|
|
1614
|
+
if (typeof data?.currentVersion === "string") {
|
|
1615
|
+
next = { currentVersion: data.currentVersion };
|
|
1616
|
+
if (data.status === "update_available" && typeof data.latestVersion === "string") {
|
|
1617
|
+
next.latestVersion = data.latestVersion;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
} catch {
|
|
1621
|
+
} finally {
|
|
1622
|
+
checking = false;
|
|
1623
|
+
}
|
|
1624
|
+
if (signal.aborted || update?.currentVersion === next?.currentVersion && update?.latestVersion === next?.latestVersion) return;
|
|
1625
|
+
update = next;
|
|
1626
|
+
for (const listener of listeners) listener();
|
|
1627
|
+
}
|
|
1628
|
+
const recheck = () => {
|
|
1629
|
+
void refresh();
|
|
1630
|
+
};
|
|
1631
|
+
const timer = window.setInterval(recheck, updateCheckInterval);
|
|
1632
|
+
window.addEventListener("focus", recheck);
|
|
1633
|
+
recheck();
|
|
1634
|
+
return () => {
|
|
1635
|
+
controller.abort();
|
|
1636
|
+
window.clearInterval(timer);
|
|
1637
|
+
window.removeEventListener("focus", recheck);
|
|
1638
|
+
};
|
|
1639
|
+
}, "free-model: update checks");
|
|
1640
|
+
return {
|
|
1641
|
+
getSnapshot: () => update,
|
|
1642
|
+
subscribe(listener) {
|
|
1643
|
+
listeners.add(listener);
|
|
1644
|
+
return () => listeners.delete(listener);
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
function UpdateBanner({ ctx, t, update }) {
|
|
1649
|
+
if (!update?.latestVersion) return null;
|
|
1650
|
+
function openDetails(event) {
|
|
1651
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
1652
|
+
try {
|
|
1653
|
+
const navigation = ctx.get("pluginNavigation");
|
|
1654
|
+
if (typeof navigation?.openBundle !== "function") return;
|
|
1655
|
+
navigation.openBundle(packageName);
|
|
1656
|
+
event.preventDefault();
|
|
1657
|
+
} catch {
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
return (0, import_react8.createElement)(
|
|
1661
|
+
"div",
|
|
1662
|
+
{ className: "dsh-free-model-update-banner" },
|
|
1663
|
+
(0, import_react8.createElement)(
|
|
1664
|
+
"p",
|
|
1665
|
+
{ className: "dsh-free-model-update-banner-content" },
|
|
1666
|
+
(0, import_react8.createElement)("strong", { className: "dsh-free-model-update-title" }, t("updateTitle")),
|
|
1667
|
+
(0, import_react8.createElement)("span", { className: "dsh-free-model-update-version" }, `v${update.latestVersion}`)
|
|
1668
|
+
),
|
|
1669
|
+
(0, import_react8.createElement)("a", {
|
|
1670
|
+
className: "dsh-free-model-update-action",
|
|
1671
|
+
href: `https://www.npmjs.com/package/${packageName}`,
|
|
1672
|
+
target: "_blank",
|
|
1673
|
+
rel: "noopener noreferrer",
|
|
1674
|
+
onClick: openDetails
|
|
1675
|
+
}, t("updateDetails"))
|
|
1676
|
+
);
|
|
1677
|
+
}
|
|
1678
|
+
function rpcValue(reply) {
|
|
1679
|
+
if (!reply?.ok) throw new Error(reply?.error?.message);
|
|
1680
|
+
return reply.value;
|
|
1681
|
+
}
|
|
1682
|
+
function createPluginInstaller(ctx) {
|
|
1683
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1684
|
+
const initial = { inventory: "unavailable", installed: /* @__PURE__ */ new Set(), pending: null, error: null };
|
|
1685
|
+
let state = initial;
|
|
1686
|
+
let manager;
|
|
1687
|
+
let revision = 0;
|
|
1688
|
+
function update(changes) {
|
|
1689
|
+
state = { ...state, ...changes };
|
|
1690
|
+
for (const listener of listeners) listener();
|
|
1691
|
+
}
|
|
1692
|
+
async function refresh() {
|
|
1693
|
+
if (!manager) return;
|
|
1694
|
+
const current = ++revision;
|
|
1695
|
+
try {
|
|
1696
|
+
const bundles = rpcValue(await manager.listBundles());
|
|
1697
|
+
const installed = new Set(bundles.filter((bundle) => bundle.installed || bundle.availability === "profile" || bundle.availability === "installation").map((bundle) => bundle.name));
|
|
1698
|
+
if (current === revision) update({ inventory: "ready", installed, error: installed.has(state.error?.name) ? null : state.error });
|
|
1699
|
+
} catch {
|
|
1700
|
+
if (current === revision) update({ inventory: "failed" });
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
ctx.inject(["remote", "remote.pluginManager"], (scope) => {
|
|
1704
|
+
scope.effect(() => {
|
|
1705
|
+
manager = scope.remote.pluginManager;
|
|
1706
|
+
const recheck = () => {
|
|
1707
|
+
if (listeners.size) void refresh();
|
|
1708
|
+
};
|
|
1709
|
+
const unsubscribe = scope.remote.$on("plugin-manager/changed", recheck);
|
|
1710
|
+
const reset = scope.on("connection/reset", recheck);
|
|
1711
|
+
window.addEventListener("focus", recheck);
|
|
1712
|
+
update({ ...initial, inventory: "loading" });
|
|
1713
|
+
recheck();
|
|
1714
|
+
return () => {
|
|
1715
|
+
manager = void 0;
|
|
1716
|
+
revision++;
|
|
1717
|
+
update(initial);
|
|
1718
|
+
unsubscribe();
|
|
1719
|
+
reset();
|
|
1720
|
+
window.removeEventListener("focus", recheck);
|
|
1721
|
+
};
|
|
1722
|
+
}, "free-model: plugin inventory");
|
|
1723
|
+
});
|
|
1724
|
+
async function install(name) {
|
|
1725
|
+
if (!manager || state.inventory !== "ready" || state.pending || state.installed.has(name)) return;
|
|
1726
|
+
const host = manager;
|
|
1727
|
+
update({ pending: name, error: null });
|
|
1728
|
+
try {
|
|
1729
|
+
const info = rpcValue(await host.inspect(name, { registry: npmRegistry }));
|
|
1730
|
+
if (host !== manager) return;
|
|
1731
|
+
if (info.status !== "accepted") throw new Error(info.reason);
|
|
1732
|
+
if (info.registry !== npmRegistry || info.name !== name || info.bundle !== true || typeof info.version !== "string" || !publishedVersion.test(info.version)) throw new Error();
|
|
1733
|
+
const requestId = globalThis.crypto?.randomUUID?.();
|
|
1734
|
+
const options = {
|
|
1735
|
+
enabled: true,
|
|
1736
|
+
registry: npmRegistry,
|
|
1737
|
+
expected: { name, version: info.version },
|
|
1738
|
+
...requestId && { requestId }
|
|
1739
|
+
};
|
|
1740
|
+
let result;
|
|
1741
|
+
try {
|
|
1742
|
+
result = rpcValue(await host.installBundle(`${name}@${info.version}`, options));
|
|
1743
|
+
} catch (error) {
|
|
1744
|
+
if (!requestId || host !== manager) throw error;
|
|
1745
|
+
result = rpcValue(await host.waitForInstall(requestId));
|
|
1746
|
+
if (!result) throw error;
|
|
1747
|
+
}
|
|
1748
|
+
if (!["applied", "restart-required", "overridden"].includes(result.application)) {
|
|
1749
|
+
throw new Error(result.error?.diagnostic || result.error?.code);
|
|
1750
|
+
}
|
|
1751
|
+
} catch (error) {
|
|
1752
|
+
if (host === manager) update({ error: { name, message: error.message } });
|
|
1753
|
+
} finally {
|
|
1754
|
+
if (host === manager) {
|
|
1755
|
+
await refresh();
|
|
1756
|
+
if (host === manager) update({ pending: null });
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
return {
|
|
1761
|
+
getSnapshot: () => state,
|
|
1762
|
+
subscribe(listener) {
|
|
1763
|
+
listeners.add(listener);
|
|
1764
|
+
if (listeners.size === 1) void refresh();
|
|
1765
|
+
return () => listeners.delete(listener);
|
|
1766
|
+
},
|
|
1767
|
+
install,
|
|
1768
|
+
refresh
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
function PluginInstallButton({ name, installer, state, t }) {
|
|
1772
|
+
let label = "install";
|
|
1773
|
+
if (state.pending === name) label = "installing";
|
|
1774
|
+
else if (state.inventory === "unavailable") label = "installUnavailable";
|
|
1775
|
+
else if (state.inventory === "failed") label = "retryInventory";
|
|
1776
|
+
else if (state.inventory === "loading") label = "checkInstall";
|
|
1777
|
+
else if (state.installed.has(name)) label = "installed";
|
|
1778
|
+
return (0, import_react8.createElement)("button", {
|
|
1779
|
+
type: "button",
|
|
1780
|
+
className: "dsh-free-model-plugin-action",
|
|
1781
|
+
"data-state": label,
|
|
1782
|
+
"aria-label": t("installAction", { name, action: t(label) }),
|
|
1783
|
+
disabled: !!state.pending || label !== "install" && label !== "retryInventory",
|
|
1784
|
+
onClick: () => {
|
|
1785
|
+
void (label === "retryInventory" ? installer.refresh() : installer.install(name));
|
|
1786
|
+
}
|
|
1787
|
+
}, t(label));
|
|
1788
|
+
}
|
|
1789
|
+
function PluginRecommendations({ installer, t }) {
|
|
1790
|
+
const headingId = (0, import_react8.useId)();
|
|
1791
|
+
const state = (0, import_react8.useSyncExternalStore)(installer.subscribe, installer.getSnapshot);
|
|
1792
|
+
return (0, import_react8.createElement)(
|
|
1793
|
+
"section",
|
|
1794
|
+
{ className: "dsh-free-model-recommendations", "aria-labelledby": headingId },
|
|
1795
|
+
(0, import_react8.createElement)("h3", { id: headingId }, t("otherPlugins")),
|
|
1796
|
+
(0, import_react8.createElement)("ul", { className: "dsh-free-model-plugins" }, recommendedPlugins.map(
|
|
1797
|
+
({ name, description, stores }) => (0, import_react8.createElement)(
|
|
1798
|
+
"li",
|
|
1799
|
+
{ key: name, className: "dsh-free-model-plugin" },
|
|
1800
|
+
(0, import_react8.createElement)(
|
|
1801
|
+
"div",
|
|
1802
|
+
null,
|
|
1803
|
+
(0, import_react8.createElement)("span", { className: "dsh-free-model-plugin-name" }, name),
|
|
1804
|
+
(0, import_react8.createElement)("p", null, t(description))
|
|
1805
|
+
),
|
|
1806
|
+
(0, import_react8.createElement)(
|
|
1807
|
+
"div",
|
|
1808
|
+
{ className: "dsh-free-model-plugin-actions", "aria-live": "polite" },
|
|
1809
|
+
stores ? stores.map(
|
|
1810
|
+
(store) => (0, import_react8.createElement)("a", {
|
|
1811
|
+
key: store.label,
|
|
1812
|
+
className: "dsh-free-model-plugin-action",
|
|
1813
|
+
href: store.href,
|
|
1814
|
+
target: "_blank",
|
|
1815
|
+
rel: "noopener noreferrer",
|
|
1816
|
+
"aria-label": t("storeLabel", { name, store: t(store.label) })
|
|
1817
|
+
}, t(store.label))
|
|
1818
|
+
) : (0, import_react8.createElement)(PluginInstallButton, { name, installer, state, t })
|
|
1819
|
+
),
|
|
1820
|
+
state.error?.name === name && !state.installed.has(name) && (0, import_react8.createElement)(
|
|
1821
|
+
"p",
|
|
1822
|
+
{ className: "dsh-free-model-error", role: "alert" },
|
|
1823
|
+
t("installError"),
|
|
1824
|
+
state.error.message && ` ${state.error.message}`
|
|
1825
|
+
)
|
|
1826
|
+
)
|
|
1827
|
+
)),
|
|
1828
|
+
state.inventory === "failed" && (0, import_react8.createElement)("p", { className: "dsh-free-model-error", role: "alert" }, t("inventoryError"))
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1831
|
+
function parseAvailability(data) {
|
|
1832
|
+
if (typeof data?.checking !== "boolean" || !Array.isArray(data.models) || data.retryAt !== void 0 && !Number.isFinite(data.retryAt) || !data.models.every((result) => typeof result?.id === "string" && resultStatuses.has(result.status))) {
|
|
1833
|
+
throw new Error();
|
|
1834
|
+
}
|
|
1835
|
+
return data;
|
|
1836
|
+
}
|
|
1837
|
+
function ModelActionButton({ label, icon, busy, disabled, onClick }) {
|
|
1838
|
+
return (0, import_react8.createElement)(
|
|
1839
|
+
import_dsh_client_ui_primitives4.Tooltip,
|
|
1840
|
+
{ label, side: "top" },
|
|
1841
|
+
(0, import_react8.createElement)(
|
|
1842
|
+
"span",
|
|
1843
|
+
{ className: "dsh-free-model-action-anchor" },
|
|
1844
|
+
(0, import_react8.createElement)(
|
|
1845
|
+
"button",
|
|
1846
|
+
{ type: "button", "aria-label": label, "aria-busy": busy, disabled, onClick },
|
|
1847
|
+
(0, import_react8.createElement)(PanelIcon, { name: icon, size: 17 })
|
|
1848
|
+
)
|
|
1849
|
+
)
|
|
1850
|
+
);
|
|
1851
|
+
}
|
|
1852
|
+
function KiloWorkspace({ t, language }) {
|
|
1853
|
+
const writes = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
1854
|
+
const checkRequest = (0, import_react8.useRef)(null);
|
|
1855
|
+
const [models, setModels] = (0, import_react8.useState)(null);
|
|
1856
|
+
const [loadError, setLoadError] = (0, import_react8.useState)(null);
|
|
1857
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
1858
|
+
const [revision, setRevision] = (0, import_react8.useState)(0);
|
|
1859
|
+
const [rows, setRows] = (0, import_react8.useState)(/* @__PURE__ */ new Map());
|
|
1860
|
+
const [availability, setAvailability] = (0, import_react8.useState)(emptyAvailability);
|
|
1861
|
+
const [availabilityError, setAvailabilityError] = (0, import_react8.useState)(null);
|
|
1862
|
+
const [starting, setStarting] = (0, import_react8.useState)(false);
|
|
1863
|
+
const [cooldown, setCooldown] = (0, import_react8.useState)(false);
|
|
1864
|
+
(0, import_react8.useEffect)(() => {
|
|
1865
|
+
const controller = new AbortController();
|
|
1866
|
+
const { signal } = controller;
|
|
1867
|
+
const polling = availability.checking;
|
|
1868
|
+
const path = revision > 0 ? `${apiPath}?refresh=1` : apiPath;
|
|
1869
|
+
request2(path, signal).then((data) => {
|
|
1870
|
+
if (!Array.isArray(data?.models) || !data.models.every((model) => typeof model?.id === "string" && typeof model?.name === "string" && typeof model.enabled === "boolean" && typeof model.available === "boolean")) throw new Error();
|
|
1871
|
+
if (signal.aborted) return;
|
|
1872
|
+
setModels(data.models);
|
|
1873
|
+
setLoadError(data.catalogError ?? null);
|
|
1874
|
+
if (!polling && data.availability !== void 0) setAvailability(parseAvailability(data.availability));
|
|
1875
|
+
}).catch((error) => {
|
|
1876
|
+
if (!signal.aborted) {
|
|
1877
|
+
setLoadError(error.message);
|
|
1878
|
+
setModels((current) => current?.map((model) => ({ ...model, available: false, unavailableReason: "provider-unavailable" })) ?? null);
|
|
1879
|
+
}
|
|
1880
|
+
}).finally(() => {
|
|
1881
|
+
if (!signal.aborted) setLoading(false);
|
|
1882
|
+
});
|
|
1883
|
+
return () => controller.abort();
|
|
1884
|
+
}, [revision]);
|
|
1885
|
+
(0, import_react8.useEffect)(() => {
|
|
1886
|
+
const active = writes.current;
|
|
1887
|
+
return () => {
|
|
1888
|
+
for (const controller of active.values()) controller.abort();
|
|
1889
|
+
active.clear();
|
|
1890
|
+
checkRequest.current?.abort();
|
|
1891
|
+
};
|
|
1892
|
+
}, []);
|
|
1893
|
+
(0, import_react8.useEffect)(() => {
|
|
1894
|
+
if (!availability.checking) return;
|
|
1895
|
+
const controller = new AbortController();
|
|
1896
|
+
const { signal } = controller;
|
|
1897
|
+
let timer = setTimeout(poll, 1e3);
|
|
1898
|
+
async function poll() {
|
|
1899
|
+
try {
|
|
1900
|
+
const snapshot = parseAvailability(await request2(availabilityPath, signal));
|
|
1901
|
+
if (signal.aborted) return;
|
|
1902
|
+
setAvailability(snapshot);
|
|
1903
|
+
if (snapshot.checking) timer = setTimeout(poll, 1e3);
|
|
1904
|
+
} catch (error) {
|
|
1905
|
+
if (signal.aborted) return;
|
|
1906
|
+
setAvailability((current) => ({ ...current, checking: false, retryAt: void 0 }));
|
|
1907
|
+
setAvailabilityError(error.message || t("checkProgressError"));
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
return () => {
|
|
1911
|
+
clearTimeout(timer);
|
|
1912
|
+
controller.abort();
|
|
1913
|
+
};
|
|
1914
|
+
}, [availability.checking]);
|
|
1915
|
+
(0, import_react8.useEffect)(() => {
|
|
1916
|
+
let timer;
|
|
1917
|
+
function updateCooldown() {
|
|
1918
|
+
const delay = (availability.retryAt ?? 0) - Date.now();
|
|
1919
|
+
setCooldown(delay > 0);
|
|
1920
|
+
if (delay > 0) timer = setTimeout(updateCooldown, Math.min(delay, 2147483647));
|
|
1921
|
+
}
|
|
1922
|
+
updateCooldown();
|
|
1923
|
+
return () => clearTimeout(timer);
|
|
1924
|
+
}, [availability.retryAt]);
|
|
1925
|
+
function refresh() {
|
|
1926
|
+
if (loading || writes.current.size || checkRequest.current) return;
|
|
1927
|
+
setLoading(true);
|
|
1928
|
+
setLoadError(null);
|
|
1929
|
+
setAvailabilityError(null);
|
|
1930
|
+
setRows(/* @__PURE__ */ new Map());
|
|
1931
|
+
setRevision((value) => value + 1);
|
|
1932
|
+
}
|
|
1933
|
+
async function checkAvailability() {
|
|
1934
|
+
if (loading || !models?.some((model) => model.available) || checkRequest.current || availability.checking || availability.retryAt > Date.now()) return;
|
|
1935
|
+
const controller = new AbortController();
|
|
1936
|
+
const { signal } = controller;
|
|
1937
|
+
checkRequest.current = controller;
|
|
1938
|
+
setStarting(true);
|
|
1939
|
+
setAvailabilityError(null);
|
|
1940
|
+
try {
|
|
1941
|
+
const snapshot = parseAvailability(await request2(availabilityPath, signal, {}));
|
|
1942
|
+
if (!signal.aborted) setAvailability(snapshot);
|
|
1943
|
+
} catch (error) {
|
|
1944
|
+
if (!signal.aborted) setAvailabilityError(error.message || t("checkError"));
|
|
1945
|
+
} finally {
|
|
1946
|
+
checkRequest.current = null;
|
|
1947
|
+
if (!signal.aborted) setStarting(false);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
function setRow(id, state) {
|
|
1951
|
+
setRows((previous) => {
|
|
1952
|
+
const next = new Map(previous);
|
|
1953
|
+
if (state === void 0) next.delete(id);
|
|
1954
|
+
else next.set(id, state);
|
|
1955
|
+
return next;
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
async function changeVisibility(id, enabled) {
|
|
1959
|
+
if (loading || writes.current.has(id) || !models?.some((model) => model.id === id && model.available)) return;
|
|
1960
|
+
const controller = new AbortController();
|
|
1961
|
+
const { signal } = controller;
|
|
1962
|
+
writes.current.set(id, controller);
|
|
1963
|
+
setRow(id, { saving: true });
|
|
1964
|
+
try {
|
|
1965
|
+
const saved = await request2(apiPath, signal, { id, enabled });
|
|
1966
|
+
if (saved?.id !== id || saved.enabled !== enabled) throw new Error();
|
|
1967
|
+
if (signal.aborted) return;
|
|
1968
|
+
setModels((current) => current.map((model) => model.id === id ? { ...model, enabled } : model));
|
|
1969
|
+
setRow(id, void 0);
|
|
1970
|
+
} catch (error) {
|
|
1971
|
+
if (!signal.aborted) setRow(id, { error: error.message });
|
|
1972
|
+
} finally {
|
|
1973
|
+
if (writes.current.get(id) === controller) writes.current.delete(id);
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
const checking = starting || availability.checking;
|
|
1977
|
+
const results = new Map(availability.models.map((result) => [result.id, result]));
|
|
1978
|
+
const finished = availability.models.filter((result) => result.status !== "checking").length;
|
|
1979
|
+
const checkLabel = checking && availability.checking && results.size ? t("checkProgress", { done: finished, total: results.size }) : t(checking ? "checkingAvailability" : cooldown ? "checkCooldown" : "checkAvailability");
|
|
1980
|
+
const headerActions = (0, import_react8.createElement)(
|
|
1981
|
+
"div",
|
|
1982
|
+
{ className: "dsh-free-model-actions" },
|
|
1983
|
+
(0, import_react8.createElement)(ModelActionButton, {
|
|
1984
|
+
onClick: checkAvailability,
|
|
1985
|
+
icon: checking ? "spinner" : "activity",
|
|
1986
|
+
disabled: loading || checking || cooldown || !models?.some((model) => model.available),
|
|
1987
|
+
label: checkLabel,
|
|
1988
|
+
busy: checking
|
|
1989
|
+
}),
|
|
1990
|
+
(0, import_react8.createElement)(ModelActionButton, {
|
|
1991
|
+
onClick: refresh,
|
|
1992
|
+
icon: "refresh",
|
|
1993
|
+
label: t("refresh"),
|
|
1994
|
+
busy: loading,
|
|
1995
|
+
disabled: loading || starting || writes.current.size > 0
|
|
1996
|
+
})
|
|
1997
|
+
);
|
|
1998
|
+
return (0, import_react8.createElement)(
|
|
1999
|
+
"div",
|
|
2000
|
+
{ className: "dsh-free-model-catalog" },
|
|
2001
|
+
(0, import_react8.createElement)(
|
|
2002
|
+
ModelList,
|
|
2003
|
+
{
|
|
2004
|
+
label: t("kiloTab"),
|
|
2005
|
+
language,
|
|
2006
|
+
models: models ?? [],
|
|
2007
|
+
headerActions,
|
|
2008
|
+
renderRow(model) {
|
|
2009
|
+
const state = rows.get(model.id);
|
|
2010
|
+
const result = model.available ? results.get(model.id) : void 0;
|
|
2011
|
+
const status = result && (result.status !== "checking" || availability.checking) ? result.status : void 0;
|
|
2012
|
+
const checkedAt = Number.isFinite(result?.checkedAt) ? t("checkedAt", { time: new Date(result.checkedAt).toLocaleString(language) }) : void 0;
|
|
2013
|
+
const elapsedMs = result?.elapsedMs;
|
|
2014
|
+
const showDuration = (status === "available" || status === "unavailable") && result.reason !== "TIMEOUT" && Number.isSafeInteger(elapsedMs) && elapsedMs >= 0;
|
|
2015
|
+
return (0, import_react8.createElement)(
|
|
2016
|
+
"li",
|
|
2017
|
+
{
|
|
2018
|
+
className: "dsh-model-hub-row",
|
|
2019
|
+
key: model.id,
|
|
2020
|
+
"aria-disabled": !model.available || void 0,
|
|
2021
|
+
"aria-busy": state?.saving === true
|
|
2022
|
+
},
|
|
2023
|
+
(0, import_react8.createElement)(
|
|
2024
|
+
"div",
|
|
2025
|
+
null,
|
|
2026
|
+
(0, import_react8.createElement)(
|
|
2027
|
+
"div",
|
|
2028
|
+
{ className: "dsh-model-hub-row-heading" },
|
|
2029
|
+
(0, import_react8.createElement)("span", { className: "dsh-model-hub-row-name" }, model.name),
|
|
2030
|
+
!model.available && (0, import_react8.createElement)("span", { className: "dsh-model-hub-unavailable" }, t(catalogReasonKeys.get(model.unavailableReason) ?? "unverified")),
|
|
2031
|
+
status && (0, import_react8.createElement)("span", { className: "dsh-free-model-badge", "data-status": status, title: checkedAt }, t(status)),
|
|
2032
|
+
status === "unavailable" && (0, import_react8.createElement)("span", { className: "dsh-free-model-reason" }, t(reasonKeys.get(result.reason) ?? "reasonUnknown")),
|
|
2033
|
+
showDuration && (0, import_react8.createElement)("span", { className: "dsh-free-model-duration" }, `${elapsedMs} ms`)
|
|
2034
|
+
),
|
|
2035
|
+
model.name !== model.id && (0, import_react8.createElement)("code", { className: "dsh-model-hub-row-id" }, model.id)
|
|
2036
|
+
),
|
|
2037
|
+
(0, import_react8.createElement)(import_dsh_client_ui_primitives4.Switch, {
|
|
2038
|
+
checked: model.available && model.enabled,
|
|
2039
|
+
disabled: !model.available || loading || state?.saving === true,
|
|
2040
|
+
label: t("toggle", { name: model.name }),
|
|
2041
|
+
onChange: (enabled) => {
|
|
2042
|
+
void changeVisibility(model.id, enabled);
|
|
2043
|
+
}
|
|
2044
|
+
}),
|
|
2045
|
+
state?.error !== void 0 && (0, import_react8.createElement)("p", { className: "dsh-free-model-error", role: "alert" }, state.error || t("saveError"))
|
|
2046
|
+
);
|
|
2047
|
+
}
|
|
2048
|
+
},
|
|
2049
|
+
loading && models === null && (0, import_react8.createElement)("p", { className: "dsh-free-model-status", role: "status" }, t("loading")),
|
|
2050
|
+
loadError !== null && (0, import_react8.createElement)("p", { className: "dsh-free-model-status dsh-free-model-error", role: "alert" }, loadError || t("loadError")),
|
|
2051
|
+
availabilityError !== null && (0, import_react8.createElement)("p", { className: "dsh-free-model-status dsh-free-model-error", role: "alert" }, availabilityError),
|
|
2052
|
+
!loading && loadError === null && models?.length === 0 && (0, import_react8.createElement)("p", { className: "dsh-free-model-status", role: "status" }, t("empty"))
|
|
2053
|
+
)
|
|
2054
|
+
);
|
|
2055
|
+
}
|
|
2056
|
+
function ModelPage({ ctx, t, updates, installer }) {
|
|
2057
|
+
const headingId = (0, import_react8.useId)();
|
|
2058
|
+
const update = (0, import_react8.useSyncExternalStore)(updates.subscribe, updates.getSnapshot);
|
|
2059
|
+
const aboutHeadingId = (0, import_react8.useId)();
|
|
2060
|
+
const language = (ctx.locale.getSnapshot?.()?.active || document.documentElement.lang || "zh").startsWith("en") ? "en" : "zh";
|
|
2061
|
+
return (0, import_react8.createElement)(
|
|
2062
|
+
"section",
|
|
2063
|
+
{ className: "dsh-free-model-page", "aria-labelledby": headingId },
|
|
2064
|
+
(0, import_react8.createElement)(
|
|
2065
|
+
"div",
|
|
2066
|
+
{ className: "dsh-free-model-content" },
|
|
2067
|
+
(0, import_react8.createElement)(
|
|
2068
|
+
"header",
|
|
2069
|
+
{ className: "dsh-free-model-header" },
|
|
2070
|
+
(0, import_react8.createElement)("h1", { id: headingId }, t("title")),
|
|
2071
|
+
(0, import_react8.createElement)("p", { className: "dsh-free-model-hint" }, t("introduction"))
|
|
2072
|
+
),
|
|
2073
|
+
(0, import_react8.createElement)(UpdateBanner, { ctx, t, update }),
|
|
2074
|
+
(0, import_react8.createElement)(ModelSources, { ctx, t, language }, (0, import_react8.createElement)(KiloWorkspace, { t, language })),
|
|
2075
|
+
(0, import_react8.createElement)(
|
|
2076
|
+
"section",
|
|
2077
|
+
{ className: "dsh-free-model-about", "aria-labelledby": aboutHeadingId },
|
|
2078
|
+
(0, import_react8.createElement)("h2", { id: aboutHeadingId }, t("about"), update?.currentVersion && (0, import_react8.createElement)("span", null, `v${update.currentVersion}`)),
|
|
2079
|
+
(0, import_react8.createElement)(
|
|
2080
|
+
"div",
|
|
2081
|
+
{ className: "dsh-free-model-about-content" },
|
|
2082
|
+
(0, import_react8.createElement)("a", { href: repositoryUrl, target: "_blank", rel: "noopener noreferrer" }, t("project")),
|
|
2083
|
+
(0, import_react8.createElement)(PluginRecommendations, { installer, t })
|
|
2084
|
+
)
|
|
2085
|
+
)
|
|
2086
|
+
)
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
function SidebarIcon({ size }) {
|
|
2090
|
+
const Icon = import_dsh_client_ui_primitives4.IconSparkleRegular ?? import_dsh_client_ui_primitives4.IconSparkle16;
|
|
2091
|
+
return Icon ? (0, import_react8.createElement)(Icon, { size }) : null;
|
|
2092
|
+
}
|
|
2093
|
+
function SidebarUpdateBadge({ t, updates, wide }) {
|
|
2094
|
+
const update = (0, import_react8.useSyncExternalStore)(updates.subscribe, updates.getSnapshot);
|
|
2095
|
+
if (!update?.latestVersion) return null;
|
|
2096
|
+
if (wide) return (0, import_react8.createElement)("span", { className: "dsh-free-model-update-badge" }, t("updateBadge"));
|
|
2097
|
+
return (0, import_react8.createElement)(
|
|
2098
|
+
"span",
|
|
2099
|
+
{ className: "dsh-free-model-update-dot" },
|
|
2100
|
+
(0, import_react8.createElement)("span", { className: "dsh-free-model-update-sr" }, t("updateBadge"))
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
var inject = ["locale", "slots"];
|
|
2104
|
+
function apply(ctx) {
|
|
2105
|
+
registerChatGPTClient(ctx);
|
|
2106
|
+
ctx.effect(() => ctx.locale.register(panelId, messages), "free-model: translations");
|
|
2107
|
+
const t = ctx.locale.bind(panelId);
|
|
2108
|
+
const updates = monitorUpdates(ctx);
|
|
2109
|
+
const installer = createPluginInstaller(ctx);
|
|
2110
|
+
ctx.effect(() => {
|
|
2111
|
+
const style = document.createElement("style");
|
|
2112
|
+
style.textContent = model_page_default;
|
|
2113
|
+
document.head.append(style);
|
|
2114
|
+
return () => style.remove();
|
|
2115
|
+
}, "free-model: styles");
|
|
2116
|
+
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
2117
|
+
name: "sidebar.panellist",
|
|
2118
|
+
id: panelId,
|
|
2119
|
+
order: 30,
|
|
2120
|
+
label: () => t("title")
|
|
2121
|
+
}, SidebarIcon));
|
|
2122
|
+
ctx.slots.inject("sidebar.panellist.trailing", () => ctx.slots.register({
|
|
2123
|
+
name: "sidebar.panellist.trailing",
|
|
2124
|
+
id: panelId,
|
|
2125
|
+
locale: panelId
|
|
2126
|
+
}, function Trailing(props) {
|
|
2127
|
+
return (0, import_react8.createElement)(SidebarUpdateBadge, { ...props, updates });
|
|
2128
|
+
}));
|
|
2129
|
+
ctx.slots.inject("main", () => ctx.slots.register({
|
|
2130
|
+
name: "main",
|
|
2131
|
+
key: panelId,
|
|
2132
|
+
locale: panelId
|
|
2133
|
+
}, function Panel(props) {
|
|
2134
|
+
return (0, import_react8.createElement)(ModelPage, { ...props, ctx, updates, installer });
|
|
2135
|
+
}));
|
|
2136
|
+
}
|
|
2137
|
+
return module.exports; } });
|