@deepseek-ai/dsh-client-ui-settings-models 0.0.1-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js ADDED
@@ -0,0 +1,2442 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@deepseek-ai/dsh-client-ui-settings-models",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ let _deepseek_ai_dsh_client_web_react = require("@deepseek-ai/dsh-client-web-react");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ let react = require("react");
10
+ let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
11
+ let _deepseek_ai_dsh_client_runtime_client = require("@deepseek-ai/dsh-client-runtime/client");
12
+ let _deepseek_ai_dsh_client_schema_form = require("@deepseek-ai/dsh-client-schema-form");
13
+ //#region lib/types/client/apiKey.js
14
+ /**
15
+ * Browser-side judgement of a typed API key.
16
+ * @module @deepseek-ai/dsh-client-ui-settings-models/apiKey
17
+ */
18
+ /**
19
+ * Twin of `normalizeApiKey` in `@deepseek-ai/dsh-llm`: printable ASCII, space
20
+ * excluded. Client packages reference only client packages, so the charset
21
+ * rule is mirrored here rather than imported; keep the two in step, as
22
+ * `validateDeepSeekModels` is kept in step with the host's `catalogModel`.
23
+ */
24
+ const LEGAL_API_KEY = /^[\x21-\x7E]+$/;
25
+ /**
26
+ * A pasted `NAME=value` environment line. Two narrowings keep real keys clear
27
+ * of it: the name must be upper-case, so `sk-` forms break at the hyphen, and
28
+ * the `=` must be followed by something other than another `=`, so base64
29
+ * padding on an all-upper-case key (`ABCD==`) is not mistaken for an
30
+ * assignment. This heuristic runs only here — a resolver applying it could
31
+ * lock a user out of a gateway whose key legitimately takes this shape, with
32
+ * the environment refusing it too and no way through.
33
+ */
34
+ const ENV_LINE = /^[A-Z][A-Z0-9_]*=[^=]/;
35
+ /** Whether a value is wrapped in one matching pair of quotes. */
36
+ function isQuoted(value) {
37
+ const first = value[0];
38
+ if (first !== "\"" && first !== "'" && first !== "`") return false;
39
+ return value.length > 1 && value.endsWith(first);
40
+ }
41
+ /**
42
+ * Judge the key input's current value.
43
+ *
44
+ * An empty field is not a failure: every card opens with it empty even when a
45
+ * key is already stored, where it means keep that one. A field holding only
46
+ * whitespace is a failure rather than an empty field, so typed input is never
47
+ * silently discarded.
48
+ * @param draft - the key input's current value, untrimmed.
49
+ * @returns the copy key for a field-level failure, or `undefined` to allow submit.
50
+ */
51
+ function apiKeyFailure(draft) {
52
+ if (draft.length === 0) return void 0;
53
+ const value = draft.trim();
54
+ if (value.length === 0) return "keyBlank";
55
+ if (ENV_LINE.test(value) || isQuoted(value)) return "keyIllegalCharacters";
56
+ if (!LEGAL_API_KEY.test(value)) return "keyIllegalCharacters";
57
+ }
58
+ //#endregion
59
+ //#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-settings-models/src/client/ModelsSection.module.css.mjs
60
+ const css$1 = ".zGbnIq_section{max-width:720px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:12px;display:flex}.zGbnIq_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:500;line-height:24px}.zGbnIq_intro{color:var(--dsw-alias-label-tertiary);margin:0;font-size:14px;line-height:22px}.zGbnIq_notice{color:var(--dsw-alias-state-warn-label);margin:0;font-size:12px;line-height:18px}.zGbnIq_savedNotice{color:var(--dsw-alias-state-success-primary);margin:0;font-size:12px;line-height:18px}.zGbnIq_rows{flex-direction:column;gap:8px;margin:12px 0 0;padding:0;list-style:none;display:flex}.zGbnIq_rowCard{border:1px solid var(--dsw-alias-border-l2);border-radius:12px;flex-direction:column;gap:12px;padding:12px 14px;display:flex}.zGbnIq_rowHead{align-items:center;gap:10px;display:flex}.zGbnIq_rowIdentity{align-items:center;gap:6px;min-width:0;display:inline-flex}.zGbnIq_rowName{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px}.zGbnIq_rowTag{border:1px solid var(--dsw-alias-border-l3);color:var(--dsw-alias-label-secondary);border-radius:4px;flex:none;padding:1px 6px;font-size:11px;line-height:16px}.zGbnIq_credentialDot{box-sizing:border-box;border-radius:50%;flex:none;width:8px;height:8px;display:inline-block}.zGbnIq_credentialDotConfigured{background:var(--dsw-alias-state-success-primary)}.zGbnIq_credentialDotMissing{background:var(--dsw-alias-state-error-primary)}.zGbnIq_rowActions{align-items:center;gap:4px;margin-left:auto;display:inline-flex}.zGbnIq_primaryButton,.zGbnIq_secondaryButton,.zGbnIq_addButton{box-sizing:border-box;height:36px;font:inherit;cursor:pointer;border:none;border-radius:18px;justify-content:center;align-items:center;gap:4px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.zGbnIq_primaryButton{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}.zGbnIq_primaryButton:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}.zGbnIq_secondaryButton,.zGbnIq_addButton{border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary);background:0 0}.zGbnIq_secondaryButton:hover:not(:disabled),.zGbnIq_addButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.zGbnIq_secondaryButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}.zGbnIq_dangerButton{box-sizing:border-box;height:36px;color:var(--dsw-alias-state-error-primary);font:inherit;cursor:pointer;background:0 0;border:none;border-radius:18px;justify-content:center;align-items:center;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.zGbnIq_dangerButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger)}.zGbnIq_rowActions .zGbnIq_secondaryButton,.zGbnIq_rowActions .zGbnIq_dangerButton{border-radius:14px;height:28px;padding:0 10px;font-size:12px;line-height:18px}.zGbnIq_primaryButton:disabled,.zGbnIq_secondaryButton:disabled,.zGbnIq_dangerButton:disabled,.zGbnIq_addButton:disabled,.zGbnIq_linkButton:disabled,.zGbnIq_addModelButton:disabled{opacity:.4;cursor:default}.zGbnIq_primaryButton:focus-visible,.zGbnIq_secondaryButton:focus-visible,.zGbnIq_dangerButton:focus-visible,.zGbnIq_addButton:focus-visible,.zGbnIq_linkButton:focus-visible,.zGbnIq_addModelButton:focus-visible,.zGbnIq_iconButton:focus-visible,.zGbnIq_customizedSummary:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-border-l3);outline:none}.zGbnIq_editor{background:var(--dsw-alias-bg-module-platform);border-radius:12px;flex-direction:column;gap:14px;padding:14px 16px;display:flex}.zGbnIq_editorHeader{align-items:baseline;gap:8px;display:flex}.zGbnIq_editorTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px}.zGbnIq_editorRoute{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.zGbnIq_field{flex-direction:column;gap:6px;display:flex}.zGbnIq_fieldLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:12px;font-weight:500;line-height:18px;display:inline-flex}.zGbnIq_linkButton{box-sizing:border-box;height:28px;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;background:0 0;border:none;border-radius:14px;align-items:center;padding:0 10px;font-size:12px;line-height:18px;display:inline-flex}.zGbnIq_linkButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.zGbnIq_advancedHint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:18px}.zGbnIq_editorActions{justify-content:flex-end;gap:8px;display:flex}.zGbnIq_addBlock{flex-direction:column;gap:12px;display:flex}.zGbnIq_addActions{flex-wrap:wrap;gap:10px;display:flex}.zGbnIq_addButton{border:1px dashed var(--dsw-alias-border-l3);border-radius:12px;flex:1 1 0;gap:6px;min-width:180px;height:44px}.zGbnIq_addCard,.zGbnIq_setupCard{background:var(--dsw-alias-bg-module-platform);border-radius:12px;flex-direction:column;gap:14px;padding:14px 16px;list-style:none;display:flex}.zGbnIq_addCard .zGbnIq_editor,.zGbnIq_setupCard .zGbnIq_editor{background:0 0;padding:0}.zGbnIq_customized{border-top:1px solid var(--dsw-alias-border-l2);padding-top:10px}.zGbnIq_customizedSummary{cursor:pointer;width:fit-content;color:var(--dsw-alias-label-secondary);border-radius:6px;align-items:center;gap:6px;margin-left:-4px;padding:2px 4px;font-size:12px;font-weight:500;line-height:18px;list-style:none;display:flex}.zGbnIq_customizedSummary::-webkit-details-marker{display:none}.zGbnIq_customizedSummary:before{content:\"\";border-bottom:1.5px solid;border-right:1.5px solid;width:5px;height:5px;transition:transform .12s;transform:rotate(-45deg)translate(-1px,-1px)}.zGbnIq_customized[open]>.zGbnIq_customizedSummary:before{transform:rotate(45deg)translate(-1px,-1px)}.zGbnIq_customizedSummary:hover{color:var(--dsw-alias-label-primary)}.zGbnIq_customizedBody{flex-direction:column;gap:12px;padding-top:12px;display:flex}.zGbnIq_modelCatalog{border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;gap:10px;padding-top:12px;display:flex}.zGbnIq_modelCatalogHeading{flex-direction:column;gap:2px;display:flex}.zGbnIq_modelCatalogTitle{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:500;line-height:18px}.zGbnIq_modelCatalogMeta,.zGbnIq_modelEmpty{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:18px}.zGbnIq_modelList{flex-direction:column;gap:8px;display:flex}.zGbnIq_modelListHead{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.zGbnIq_modelEntry{border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:6px}.zGbnIq_modelRow{grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) auto auto;align-items:center;gap:6px;display:grid}.zGbnIq_iconButton{box-sizing:border-box;width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;display:inline-flex}.zGbnIq_iconButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.zGbnIq_iconButton:disabled{cursor:default;opacity:.4}.zGbnIq_iconButtonDanger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary)}.zGbnIq_modelAdvanced{grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:8px;padding:8px 4px 2px;display:grid}.zGbnIq_modelField{flex-direction:column;gap:4px;display:flex}.zGbnIq_modelFieldLabel{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.zGbnIq_modelEmpty{border:1px dashed var(--dsw-alias-border-l3);text-align:center;border-radius:8px;padding:12px}.zGbnIq_addModelButton{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);height:28px;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;background:0 0;border-radius:14px;align-self:flex-start;align-items:center;gap:4px;padding:0 10px;font-size:12px;line-height:18px;display:inline-flex}.zGbnIq_addModelButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.zGbnIq_input{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);width:100%;height:32px;font:inherit;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 10px;font-size:14px;line-height:22px}select.zGbnIq_input{cursor:pointer;max-width:240px}.zGbnIq_input:focus{border-color:var(--dsw-alias-brand-primary);outline:none}.zGbnIq_input::placeholder{color:var(--dsw-alias-label-dimmed)}.zGbnIq_input:disabled{opacity:.6;cursor:default}.zGbnIq_selectInput{appearance:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\");background-position:right 12px center;background-repeat:no-repeat;background-size:12px 12px;padding-right:32px}.zGbnIq_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:12px;line-height:18px}.zGbnIq_deleteDialog{width:min(480px,100%)}.zGbnIq_deleteConfirm:not(:disabled){border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}.zGbnIq_deleteConfirm:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger)}.zGbnIq_hiddenLabel{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.zGbnIq_customizedSummary:before{transition:none}}.zGbnIq_fetchDialog{--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);max-width:520px}.zGbnIq_candidateList{flex-direction:column;gap:2px;max-height:320px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.zGbnIq_candidate{border-radius:6px}.zGbnIq_candidateLabel{cursor:pointer;align-items:center;gap:8px;padding:6px 8px;display:flex}.zGbnIq_candidateId{font-family:var(--ds-font-family-code);overflow-wrap:anywhere;flex:auto;font-size:13px}";
61
+ const tagId$1 = "@deepseek-ai/dsh-client-ui-settings-models/ModelsSection.module.css";
62
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
63
+ const tag = document.createElement("style");
64
+ tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-settings-models";
65
+ tag.dataset.pluginCss = tagId$1;
66
+ tag.textContent = css$1;
67
+ document.head.appendChild(tag);
68
+ }
69
+ var ModelsSection_module_css_default = {
70
+ "modelEntry": "zGbnIq_modelEntry",
71
+ "modelRow": "zGbnIq_modelRow",
72
+ "credentialDotMissing": "zGbnIq_credentialDotMissing",
73
+ "rows": "zGbnIq_rows",
74
+ "deleteDialog": "zGbnIq_deleteDialog",
75
+ "customizedSummary": "zGbnIq_customizedSummary",
76
+ "customizedBody": "zGbnIq_customizedBody",
77
+ "modelList": "zGbnIq_modelList",
78
+ "savedNotice": "zGbnIq_savedNotice",
79
+ "modelCatalogMeta": "zGbnIq_modelCatalogMeta",
80
+ "modelListHead": "zGbnIq_modelListHead",
81
+ "primaryButton": "zGbnIq_primaryButton",
82
+ "rowActions": "zGbnIq_rowActions",
83
+ "candidateLabel": "zGbnIq_candidateLabel",
84
+ "rowName": "zGbnIq_rowName",
85
+ "editorHeader": "zGbnIq_editorHeader",
86
+ "addButton": "zGbnIq_addButton",
87
+ "modelField": "zGbnIq_modelField",
88
+ "editorTitle": "zGbnIq_editorTitle",
89
+ "candidateList": "zGbnIq_candidateList",
90
+ "editorRoute": "zGbnIq_editorRoute",
91
+ "customized": "zGbnIq_customized",
92
+ "field": "zGbnIq_field",
93
+ "credentialDotConfigured": "zGbnIq_credentialDotConfigured",
94
+ "hiddenLabel": "zGbnIq_hiddenLabel",
95
+ "editorActions": "zGbnIq_editorActions",
96
+ "intro": "zGbnIq_intro",
97
+ "candidateId": "zGbnIq_candidateId",
98
+ "addActions": "zGbnIq_addActions",
99
+ "candidate": "zGbnIq_candidate",
100
+ "modelEmpty": "zGbnIq_modelEmpty",
101
+ "setupCard": "zGbnIq_setupCard",
102
+ "modelFieldLabel": "zGbnIq_modelFieldLabel",
103
+ "input": "zGbnIq_input",
104
+ "deleteConfirm": "zGbnIq_deleteConfirm",
105
+ "section": "zGbnIq_section",
106
+ "fieldLabel": "zGbnIq_fieldLabel",
107
+ "modelCatalog": "zGbnIq_modelCatalog",
108
+ "iconButton": "zGbnIq_iconButton",
109
+ "rowTag": "zGbnIq_rowTag",
110
+ "dangerButton": "zGbnIq_dangerButton",
111
+ "modelCatalogTitle": "zGbnIq_modelCatalogTitle",
112
+ "editor": "zGbnIq_editor",
113
+ "linkButton": "zGbnIq_linkButton",
114
+ "advancedHint": "zGbnIq_advancedHint",
115
+ "addModelButton": "zGbnIq_addModelButton",
116
+ "rowCard": "zGbnIq_rowCard",
117
+ "credentialDot": "zGbnIq_credentialDot",
118
+ "addCard": "zGbnIq_addCard",
119
+ "addBlock": "zGbnIq_addBlock",
120
+ "title": "zGbnIq_title",
121
+ "iconButtonDanger": "zGbnIq_iconButtonDanger",
122
+ "notice": "zGbnIq_notice",
123
+ "error": "zGbnIq_error",
124
+ "secondaryButton": "zGbnIq_secondaryButton",
125
+ "rowIdentity": "zGbnIq_rowIdentity",
126
+ "fetchDialog": "zGbnIq_fetchDialog",
127
+ "modelAdvanced": "zGbnIq_modelAdvanced",
128
+ "selectInput": "zGbnIq_selectInput",
129
+ "modelCatalogHeading": "zGbnIq_modelCatalogHeading",
130
+ "rowHead": "zGbnIq_rowHead"
131
+ };
132
+ //#endregion
133
+ //#region lib/types/client/EditorFooter.js
134
+ /**
135
+ * Render one provider card's action row.
136
+ * @param props - the labels, commit gating, and handlers the owning card supplies.
137
+ * @returns the cancel/commit row.
138
+ */
139
+ function EditorFooter(props) {
140
+ const { t } = props;
141
+ return (0, react_jsx_runtime.jsxs)("div", {
142
+ className: ModelsSection_module_css_default["editorActions"],
143
+ children: [(0, react_jsx_runtime.jsx)("button", {
144
+ type: "button",
145
+ className: ModelsSection_module_css_default["secondaryButton"],
146
+ disabled: props.busy,
147
+ onClick: props.onCancel,
148
+ children: t("cancel")
149
+ }), (0, react_jsx_runtime.jsx)("button", {
150
+ type: "button",
151
+ className: ModelsSection_module_css_default["primaryButton"],
152
+ disabled: props.submitDisabled,
153
+ onClick: props.onSubmit,
154
+ children: props.busy ? t(props.submitBusyLabel) : t(props.submitLabel)
155
+ })]
156
+ });
157
+ }
158
+ //#endregion
159
+ //#region lib/types/client/DeepSeekModelsEditor.js
160
+ /**
161
+ * Curated editor for the direct DeepSeek adapter's advisory model catalog.
162
+ * The settings layer replaces `models` as one array, so the parent supplies
163
+ * the effective inherited rows until the first edit materializes a user
164
+ * override; reset removes that override instead of copying defaults into it.
165
+ */
166
+ /** Row index encoded in an editing-buffer key. */
167
+ function rowOf(key) {
168
+ return Number(key.slice(0, key.indexOf(":")));
169
+ }
170
+ /** Accepted capacity spellings: a decimal count with an optional K/M suffix. */
171
+ const CAPACITY_PATTERN = /^(\d+(?:\.\d+)?)([km])?$/i;
172
+ /** Decimal suffix scales — `1M` is 1000K, matching how model capacities are quoted. */
173
+ const CAPACITY_SCALE = {
174
+ k: 1e3,
175
+ m: 1e6
176
+ };
177
+ /**
178
+ * Read a typed capacity, so a user can write `256K` or `1M` instead of counting
179
+ * zeroes. The stored value stays a plain token count.
180
+ * @param text - raw field text.
181
+ * @returns the count; `undefined` when blank (inherit), `NaN` when unreadable
182
+ * (rejected by {@link validateDeepSeekModels} before any write).
183
+ */
184
+ function parseCapacity(text) {
185
+ const trimmed = text.trim();
186
+ if (trimmed.length === 0) return void 0;
187
+ const match = CAPACITY_PATTERN.exec(trimmed);
188
+ if (match === null) return NaN;
189
+ const suffix = match[2]?.toLowerCase();
190
+ const scale = suffix === "k" || suffix === "m" ? CAPACITY_SCALE[suffix] : 1;
191
+ const scaled = Number(match[1]) * scale;
192
+ const rounded = Math.round(scaled);
193
+ return Math.abs(scaled - rounded) < 1e-6 ? rounded : scaled;
194
+ }
195
+ /**
196
+ * Spell a stored count back in the shortest form that survives a round trip
197
+ * through {@link parseCapacity}; a count that is not a whole number of
198
+ * thousands stays written out.
199
+ * @param value - stored capacity.
200
+ * @returns the field text.
201
+ */
202
+ function formatCapacity(value) {
203
+ if (!Number.isInteger(value) || value <= 0) return String(value);
204
+ if (value % CAPACITY_SCALE.m === 0) return `${String(value / CAPACITY_SCALE.m)}M`;
205
+ if (value % CAPACITY_SCALE.k === 0) return `${String(value / CAPACITY_SCALE.k)}K`;
206
+ return String(value);
207
+ }
208
+ /** Convert a schema-validated catalog value into records without dropping hidden fields. */
209
+ function modelDrafts(value) {
210
+ if (!Array.isArray(value)) return [];
211
+ return value.map((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry) ? entry : {});
212
+ }
213
+ /**
214
+ * Validate adapter constraints that the serialized schema cannot express.
215
+ * @param value - user-owned `models` value, or undefined while inherited.
216
+ * @returns the first invalid row, or undefined when the adapter will accept it.
217
+ */
218
+ function validateDeepSeekModels(value) {
219
+ if (value === void 0) return void 0;
220
+ const models = modelDrafts(value);
221
+ const seen = /* @__PURE__ */ new Set();
222
+ for (const [index, model] of models.entries()) {
223
+ const id = model["id"];
224
+ const trimmed = typeof id === "string" ? id.trim() : void 0;
225
+ if (trimmed === void 0 || trimmed.length === 0) return {
226
+ index,
227
+ key: "modelIdRequired"
228
+ };
229
+ if (seen.has(trimmed)) return {
230
+ index,
231
+ key: "modelIdDuplicate"
232
+ };
233
+ seen.add(trimmed);
234
+ const name = model["name"];
235
+ if (name !== void 0 && (typeof name !== "string" || name.length === 0)) return {
236
+ index,
237
+ key: "modelNameInvalid"
238
+ };
239
+ const contextWindow = model["contextWindow"];
240
+ if (contextWindow !== void 0 && (typeof contextWindow !== "number" || !Number.isInteger(contextWindow) || contextWindow <= 0)) return {
241
+ index,
242
+ key: "modelContextInvalid"
243
+ };
244
+ const maxTokens = model["maxTokens"];
245
+ if (maxTokens !== void 0 && (typeof maxTokens !== "number" || !Number.isInteger(maxTokens) || maxTokens <= 0)) return {
246
+ index,
247
+ key: "modelMaxTokensInvalid"
248
+ };
249
+ }
250
+ }
251
+ /**
252
+ * Render the direct DeepSeek adapter's model catalog: id and display name on
253
+ * each row, capacities behind the row's own disclosure.
254
+ * @param props - effective rows plus the array-level override actions.
255
+ * @returns the catalog editor.
256
+ */
257
+ function DeepSeekModelsEditor(props) {
258
+ const [editing, setEditing] = (0, react.useState)(() => /* @__PURE__ */ new Map());
259
+ const [expanded, setExpanded] = (0, react.useState)(() => /* @__PURE__ */ new Set());
260
+ const update = (index, key, value) => {
261
+ const next = props.models.map((model, at) => {
262
+ const copy = { ...model };
263
+ if (at !== index) return copy;
264
+ if (value === void 0) Reflect.deleteProperty(copy, key);
265
+ else copy[key] = value;
266
+ return copy;
267
+ });
268
+ props.onChange(next);
269
+ };
270
+ const remove = (index) => {
271
+ setEditing((current) => {
272
+ const next = /* @__PURE__ */ new Map();
273
+ for (const [key, text] of current) {
274
+ const at = rowOf(key);
275
+ if (at === index) continue;
276
+ next.set(at > index ? key.replace(/^\d+/, String(at - 1)) : key, text);
277
+ }
278
+ return next;
279
+ });
280
+ setExpanded((current) => {
281
+ const next = /* @__PURE__ */ new Set();
282
+ for (const at of current) {
283
+ if (at === index) continue;
284
+ next.add(at > index ? at - 1 : at);
285
+ }
286
+ return next;
287
+ });
288
+ props.onChange(props.models.filter((_model, at) => at !== index).map((model) => ({ ...model })));
289
+ };
290
+ const reset = () => {
291
+ setEditing(/* @__PURE__ */ new Map());
292
+ setExpanded(/* @__PURE__ */ new Set());
293
+ props.onReset();
294
+ };
295
+ const toggle = (index) => {
296
+ setExpanded((current) => {
297
+ const next = new Set(current);
298
+ if (!next.delete(index)) next.add(index);
299
+ return next;
300
+ });
301
+ };
302
+ /** The field's text: its live keystrokes, else the stored count spelled short. */
303
+ const capacityText = (model, index, field) => {
304
+ const typed = editing.get(`${String(index)}:${field}`);
305
+ if (typed !== void 0) return typed;
306
+ const value = model[field];
307
+ return typeof value === "number" ? formatCapacity(value) : "";
308
+ };
309
+ const settleCapacity = (index, field) => {
310
+ const key = `${String(index)}:${field}`;
311
+ const typed = editing.get(key);
312
+ if (typed === void 0) return;
313
+ const parsed = parseCapacity(typed);
314
+ if (parsed !== void 0 && Number.isNaN(parsed)) return;
315
+ setEditing((current) => {
316
+ const next = new Map(current);
317
+ next.delete(key);
318
+ return next;
319
+ });
320
+ };
321
+ /** One capacity field of one row, rendered inside the row's disclosure. */
322
+ const capacityField = (model, index, field, fallback) => (0, react_jsx_runtime.jsxs)("label", {
323
+ className: ModelsSection_module_css_default["modelField"],
324
+ children: [(0, react_jsx_runtime.jsx)("span", {
325
+ className: ModelsSection_module_css_default["modelFieldLabel"],
326
+ children: props.t(field === "contextWindow" ? "contextWindow" : "maxTokens")
327
+ }), (0, react_jsx_runtime.jsx)("input", {
328
+ className: ModelsSection_module_css_default["input"],
329
+ type: "text",
330
+ inputMode: "numeric",
331
+ value: capacityText(model, index, field),
332
+ placeholder: fallback === void 0 ? props.t(field === "contextWindow" ? "contextWindowPlaceholder" : "maxTokensPlaceholder") : formatCapacity(fallback),
333
+ "aria-label": `${props.t(field === "contextWindow" ? "contextWindow" : "maxTokens")} ${String(index + 1)}`,
334
+ disabled: props.disabled,
335
+ onChange: (event) => {
336
+ const text = event.target.value;
337
+ setEditing((current) => new Map(current).set(`${String(index)}:${field}`, text));
338
+ update(index, field, parseCapacity(text));
339
+ },
340
+ onBlur: () => {
341
+ settleCapacity(index, field);
342
+ }
343
+ })]
344
+ });
345
+ return (0, react_jsx_runtime.jsxs)("section", {
346
+ className: ModelsSection_module_css_default["modelCatalog"],
347
+ "aria-label": props.t("models"),
348
+ children: [
349
+ (0, react_jsx_runtime.jsxs)("div", {
350
+ className: ModelsSection_module_css_default["modelListHead"],
351
+ children: [(0, react_jsx_runtime.jsxs)("div", {
352
+ className: ModelsSection_module_css_default["modelCatalogHeading"],
353
+ children: [(0, react_jsx_runtime.jsx)("span", {
354
+ className: ModelsSection_module_css_default["modelCatalogTitle"],
355
+ children: props.t("models")
356
+ }), (0, react_jsx_runtime.jsx)("span", {
357
+ className: ModelsSection_module_css_default["modelCatalogMeta"],
358
+ children: props.overridden ? props.t("modelsCustomized") : props.t("modelsInherited")
359
+ })]
360
+ }), props.overridden ? (0, react_jsx_runtime.jsx)("button", {
361
+ type: "button",
362
+ className: ModelsSection_module_css_default["linkButton"],
363
+ disabled: props.disabled,
364
+ onClick: reset,
365
+ children: props.t("resetModels")
366
+ }) : null]
367
+ }),
368
+ props.models.length === 0 ? (0, react_jsx_runtime.jsx)("p", {
369
+ className: ModelsSection_module_css_default["modelEmpty"],
370
+ children: props.t("modelsEmpty")
371
+ }) : (0, react_jsx_runtime.jsx)("div", {
372
+ className: ModelsSection_module_css_default["modelList"],
373
+ children: props.models.map((model, index) => (0, react_jsx_runtime.jsxs)("div", {
374
+ className: ModelsSection_module_css_default["modelEntry"],
375
+ children: [(0, react_jsx_runtime.jsxs)("div", {
376
+ className: ModelsSection_module_css_default["modelRow"],
377
+ children: [
378
+ (0, react_jsx_runtime.jsx)("input", {
379
+ className: ModelsSection_module_css_default["input"],
380
+ type: "text",
381
+ value: typeof model["id"] === "string" ? model["id"] : "",
382
+ placeholder: props.t("modelId"),
383
+ "aria-label": `${props.t("modelId")} ${String(index + 1)}`,
384
+ disabled: props.disabled,
385
+ onChange: (event) => {
386
+ update(index, "id", event.target.value);
387
+ },
388
+ onBlur: (event) => {
389
+ const trimmed = event.target.value.trim();
390
+ if (trimmed !== event.target.value) update(index, "id", trimmed);
391
+ }
392
+ }),
393
+ (0, react_jsx_runtime.jsx)("input", {
394
+ className: ModelsSection_module_css_default["input"],
395
+ type: "text",
396
+ value: typeof model["name"] === "string" ? model["name"] : "",
397
+ placeholder: props.t("modelName"),
398
+ "aria-label": `${props.t("modelName")} ${String(index + 1)}`,
399
+ disabled: props.disabled,
400
+ onChange: (event) => {
401
+ update(index, "name", event.target.value === "" ? void 0 : event.target.value);
402
+ }
403
+ }),
404
+ (0, react_jsx_runtime.jsx)("button", {
405
+ type: "button",
406
+ className: ModelsSection_module_css_default["iconButton"],
407
+ "aria-label": `${props.t("modelAdvanced")} ${String(index + 1)}`,
408
+ "aria-expanded": expanded.has(index),
409
+ title: props.t("modelAdvanced"),
410
+ onClick: () => {
411
+ toggle(index);
412
+ },
413
+ children: expanded.has(index) ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, {}) : (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutline14, {})
414
+ }),
415
+ (0, react_jsx_runtime.jsx)("button", {
416
+ type: "button",
417
+ className: `${ModelsSection_module_css_default["iconButton"]} ${ModelsSection_module_css_default["iconButtonDanger"]}`,
418
+ "aria-label": `${props.t("removeModel")} ${String(index + 1)}`,
419
+ title: props.t("removeModel"),
420
+ disabled: props.disabled,
421
+ onClick: () => {
422
+ remove(index);
423
+ },
424
+ children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, { size: 14 })
425
+ })
426
+ ]
427
+ }), expanded.has(index) ? (0, react_jsx_runtime.jsxs)("div", {
428
+ className: ModelsSection_module_css_default["modelAdvanced"],
429
+ children: [capacityField(model, index, "contextWindow", props.defaultContextWindow), capacityField(model, index, "maxTokens", props.defaultMaxTokens)]
430
+ }) : null]
431
+ }, index))
432
+ }),
433
+ (0, react_jsx_runtime.jsxs)("button", {
434
+ type: "button",
435
+ className: ModelsSection_module_css_default["addModelButton"],
436
+ disabled: props.disabled,
437
+ onClick: () => {
438
+ props.onChange([...props.models.map((model) => ({ ...model })), { id: "" }]);
439
+ },
440
+ children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 14 }), props.t("addModel")]
441
+ })
442
+ ]
443
+ });
444
+ }
445
+ //#endregion
446
+ //#region lib/types/client/store.js
447
+ /**
448
+ * Models settings page store: one snapshot joining the configurable-provider
449
+ * directory (`llm.providers`), the settings namespaces (`settings.describe`),
450
+ * and the referenced credentials (`credentials.describe`). The host stays the
451
+ * single fact source — every mutation writes through the wire and the page
452
+ * re-renders from the next describe, pushed or refetched.
453
+ */
454
+ /**
455
+ * Any route key walks a dict schema to the same profile node, so the lookup
456
+ * names one that cannot collide with a configured route.
457
+ */
458
+ const PROBE_ROUTE = "\0probe";
459
+ /**
460
+ * Human text for a rejected wire call. A transport failure rejects with an
461
+ * Error; a host or a runtime can reject with anything, and the page still has
462
+ * to say something.
463
+ * @param error - the rejection value.
464
+ * @returns the message to show.
465
+ */
466
+ function messageOf(error) {
467
+ return error instanceof Error ? error.message : String(error);
468
+ }
469
+ /**
470
+ * Derive the conventional credential reference for a provider route: the v1
471
+ * page never asks for an environment-variable name, so a typed key stores
472
+ * under this derived reference and the profile records it as `apiKeyEnv`.
473
+ * @param provider - provider route id (e.g. `anthropic`, `minimax-cn`).
474
+ * @returns the derived reference name (e.g. `MINIMAX_CN_API_KEY`).
475
+ */
476
+ function deriveKeyRef(provider) {
477
+ return `${provider.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
478
+ }
479
+ /**
480
+ * The wire protocols a hand-declared route may name, read out of the owning
481
+ * namespace's own schema. This stays a schema read rather than a wire field so
482
+ * the choices the page offers cannot drift from the ones the adapter accepts:
483
+ * both come from the same `Config`.
484
+ * @param namespace - the namespace view whose schema declares the profile shape.
485
+ * @returns the protocol identifiers, or an empty list when the schema has none.
486
+ */
487
+ function protocolChoices(namespace) {
488
+ if (namespace === void 0) return [];
489
+ const list = (0, _deepseek_ai_dsh_client_schema_form.nodeAtPath)((0, _deepseek_ai_dsh_client_schema_form.rehydrateSchema)(namespace.schema), [
490
+ "providers",
491
+ PROBE_ROUTE,
492
+ "api"
493
+ ]);
494
+ if (list?.type !== "union" || list.list === void 0) return [];
495
+ return list.list.map((entry) => entry.value).filter((value) => typeof value === "string");
496
+ }
497
+ /** The credential reference a resolved profile names (its `apiKeyEnv` field). */
498
+ function apiKeyEnvOf(namespace, path) {
499
+ if (namespace === void 0) return void 0;
500
+ const profile = (0, _deepseek_ai_dsh_client_schema_form.getPath)(namespace.value, path);
501
+ if (typeof profile !== "object" || profile === null) return void 0;
502
+ const ref = profile.apiKeyEnv;
503
+ return typeof ref === "string" && ref.length > 0 ? ref : void 0;
504
+ }
505
+ /** The models settings page controller (one per settings surface). */
506
+ var ModelsSettingsStore = class {
507
+ api;
508
+ /** The snapshot the section renders from (uSES-safe store). */
509
+ store = (0, _deepseek_ai_dsh_client_runtime_client.createSnapshotStore)({
510
+ status: "idle",
511
+ error: null,
512
+ credentialError: null,
513
+ writable: false,
514
+ rows: [],
515
+ namespaces: /* @__PURE__ */ new Map()
516
+ });
517
+ /** Latest load wins; an older response never overwrites a newer one. */
518
+ generation = 0;
519
+ /**
520
+ * @param api - the wire face (settings/credentials/llm domains).
521
+ */
522
+ constructor(api) {
523
+ this.api = api;
524
+ }
525
+ /**
526
+ * Refresh the whole page snapshot: directory and namespaces in parallel,
527
+ * then one batched credential describe over every referenced ref. A
528
+ * failure keeps the last good rows and surfaces the error.
529
+ * @returns nothing; the snapshot carries the outcome.
530
+ */
531
+ async load() {
532
+ const generation = ++this.generation;
533
+ this.store.update((s) => {
534
+ s.status = "loading";
535
+ s.error = null;
536
+ });
537
+ let providers;
538
+ let writable;
539
+ let views;
540
+ try {
541
+ const [providersResponse, settingsResponse] = await Promise.all([this.api.llm.providers({}), this.api.settings.describe({})]);
542
+ if (!providersResponse.result.ok) throw new Error(providersResponse.result.error.message);
543
+ if (!settingsResponse.result.ok) throw new Error(settingsResponse.result.error.message);
544
+ providers = providersResponse.result.value.providers;
545
+ writable = settingsResponse.result.value.writable;
546
+ views = settingsResponse.result.value.namespaces;
547
+ } catch (error) {
548
+ if (generation !== this.generation) return;
549
+ this.store.update((s) => {
550
+ s.status = "error";
551
+ s.error = error instanceof Error ? error.message : String(error);
552
+ });
553
+ return;
554
+ }
555
+ const namespaces = new Map(views.map((view) => [view.ns, view]));
556
+ const rows = providers.map((entry) => {
557
+ const namespace = namespaces.get(entry.settingsNs);
558
+ return {
559
+ entry,
560
+ configured: namespace !== void 0 && (entry.settingsPath.length === 0 || (0, _deepseek_ai_dsh_client_schema_form.getPath)(namespace.value, entry.settingsPath) !== void 0),
561
+ removable: namespace !== void 0 && entry.settingsPath.length > 0 && (0, _deepseek_ai_dsh_client_schema_form.hasPath)(namespace.user, entry.settingsPath) && !(0, _deepseek_ai_dsh_client_schema_form.hasPath)(namespace.base, entry.settingsPath),
562
+ apiKeyEnv: apiKeyEnvOf(namespace, entry.settingsPath),
563
+ credential: void 0
564
+ };
565
+ });
566
+ const refs = [...new Set(rows.flatMap((row) => row.apiKeyEnv === void 0 ? [] : [row.apiKeyEnv]))];
567
+ let credentials = {};
568
+ let credentialError = null;
569
+ if (refs.length > 0) try {
570
+ const response = await this.api.credentials.describe({ refs });
571
+ if (response.result.ok) credentials = response.result.value.credentials;
572
+ else credentialError = response.result.error.message;
573
+ } catch (error) {
574
+ credentialError = messageOf(error);
575
+ }
576
+ if (generation !== this.generation) return;
577
+ this.store.update((s) => {
578
+ s.status = "ready";
579
+ s.error = null;
580
+ s.credentialError = credentialError;
581
+ s.writable = writable;
582
+ s.rows = rows.map((row) => ({
583
+ ...row,
584
+ ...row.apiKeyEnv !== void 0 && credentials[row.apiKeyEnv] !== void 0 ? { credential: credentials[row.apiKeyEnv] } : {}
585
+ }));
586
+ s.namespaces = namespaces;
587
+ });
588
+ }
589
+ };
590
+ /**
591
+ * Whether a joined row can serve model requests as it stands: the route is
592
+ * registered with the adapter registry, and whatever credential its resolved
593
+ * profile names is stored. A profile naming no reference authenticates through
594
+ * the provider's own path (the Bedrock chain, Vertex ADC, a gateway that needs
595
+ * nothing), as does a live route with no settings address at all, so neither
596
+ * owes this page a key.
597
+ * @param row - one joined provider row.
598
+ * @returns whether the user already has this provider to talk to.
599
+ */
600
+ function providerUsable(row) {
601
+ if (!row.entry.active) return false;
602
+ if (row.apiKeyEnv === void 0) return true;
603
+ return row.credential?.configured === true;
604
+ }
605
+ /**
606
+ * Project first-run readiness from the provider/settings/credential join used
607
+ * by the Models page. The step exists to leave the user with a model to talk
608
+ * to, so ANY usable provider ends it; only when none exists does the official
609
+ * DeepSeek route — the one route the prompt can offer a key field for — decide
610
+ * whether prompting can help. A missing official configurable-provider
611
+ * declaration means the adapter is not repairable by navigating to Models.
612
+ * @param state - current shared Models join snapshot.
613
+ * @returns the onboarding state without reading a parallel fact source.
614
+ */
615
+ function onboardingReadiness(state) {
616
+ if ((state.status === "idle" || state.status === "loading") && state.rows.length === 0) return { kind: "loading" };
617
+ if (state.status === "error") return {
618
+ kind: "unavailable",
619
+ reason: "load-failed"
620
+ };
621
+ if (state.rows.some(providerUsable)) return { kind: "provider-ready" };
622
+ const row = state.rows.find((candidate) => candidate.entry.provider === "deepseek-official" && candidate.entry.settingsNs === "llm-deepseek" && candidate.entry.settingsPath.length === 0);
623
+ if (row === void 0) return { kind: "adapter-absent" };
624
+ if (!row.entry.active) return {
625
+ kind: "unavailable",
626
+ reason: "provider-inactive"
627
+ };
628
+ if (state.credentialError !== null || row.credential === void 0) return {
629
+ kind: "unavailable",
630
+ reason: "credentials-unavailable"
631
+ };
632
+ if (!state.writable) return {
633
+ kind: "unavailable",
634
+ reason: "settings-read-only"
635
+ };
636
+ if (!row.credential.writable) return {
637
+ kind: "unavailable",
638
+ reason: "credential-read-only"
639
+ };
640
+ return { kind: "credential-missing" };
641
+ }
642
+ //#endregion
643
+ //#region lib/types/client/ModelListEditor.js
644
+ /**
645
+ * The model list of one pi-ai provider profile, plus the action that asks the
646
+ * provider what it serves.
647
+ *
648
+ * The list is the profile's `models` array as the card holds it: an empty list
649
+ * means "serve this route's built-in catalog", and any entry replaces that
650
+ * catalog, so a row is only ever added deliberately. Fetching asks the endpoint
651
+ * **the form currently shows** — including a key typed but not yet saved — so
652
+ * adding a provider is one pass instead of save-then-return; the reply is
653
+ * candidates the user picks from, never configuration written behind them.
654
+ *
655
+ * A provider that cannot be interrogated (an unreachable endpoint, a protocol
656
+ * with no readable listing) is not a dead end: the failure is shown next to the
657
+ * rows the user can still fill in by hand.
658
+ */
659
+ /** A row's text field, or the empty string when unset or not a string. */
660
+ function textOf(model, key) {
661
+ const value = model[key];
662
+ return typeof value === "string" ? value : "";
663
+ }
664
+ /** A row's numeric field, or `undefined` when unset or not a number. */
665
+ function numberOf(model, key) {
666
+ const value = model[key];
667
+ return typeof value === "number" ? value : void 0;
668
+ }
669
+ /** Disclosure chevron; rotates to point down while its row is open. */
670
+ function IconChevron({ open }) {
671
+ return (0, react_jsx_runtime.jsx)("svg", {
672
+ width: "14",
673
+ height: "14",
674
+ viewBox: "0 0 16 16",
675
+ fill: "none",
676
+ "aria-hidden": true,
677
+ style: {
678
+ transform: open ? "rotate(90deg)" : void 0,
679
+ transition: "transform 120ms ease"
680
+ },
681
+ children: (0, react_jsx_runtime.jsx)("path", {
682
+ d: "M6 3.5L10.5 8L6 12.5",
683
+ stroke: "currentColor",
684
+ strokeWidth: "1.5",
685
+ strokeLinecap: "round",
686
+ strokeLinejoin: "round"
687
+ })
688
+ });
689
+ }
690
+ /** Removal glyph for one model row. */
691
+ function IconTrash() {
692
+ return (0, react_jsx_runtime.jsx)("svg", {
693
+ width: "14",
694
+ height: "14",
695
+ viewBox: "0 0 16 16",
696
+ fill: "none",
697
+ "aria-hidden": true,
698
+ children: (0, react_jsx_runtime.jsx)("path", {
699
+ d: "M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9a1 1 0 001 .9h4.6a1 1 0 001-.9L12 4M6.5 6.8v4.4M9.5 6.8v4.4",
700
+ stroke: "currentColor",
701
+ strokeWidth: "1.3",
702
+ strokeLinecap: "round",
703
+ strokeLinejoin: "round"
704
+ })
705
+ });
706
+ }
707
+ /**
708
+ * What an empty capacity field is worth, shown as its placeholder so a row left
709
+ * blank does not read as a model with no capacity at all.
710
+ *
711
+ * The magnitudes are the adapter's own route-level fallbacks (`llm-pi-ai`'s
712
+ * `defaultContextWindow` and `defaultMaxTokens`), spelled the way a person
713
+ * would say them. They are a hint, not a mirror: this page counts `K` as 1000,
714
+ * so typing `256K` stores 256000 while leaving the field blank keeps the
715
+ * adapter's 262144. A deployment that overrides those defaults is not
716
+ * reflected here — nothing on this page can read them.
717
+ */
718
+ const CAPACITY_HINT = {
719
+ contextWindow: "256K",
720
+ maxTokens: "32K"
721
+ };
722
+ /**
723
+ * Spell a stored count for a field that may be unset. The spelling itself is
724
+ * {@link formatCapacity}, shared with the DeepSeek catalog editor so both
725
+ * surfaces read and write one K/M vocabulary.
726
+ * @param value - stored capacity, or `undefined` for an unset field.
727
+ * @returns the field text, empty when unset.
728
+ */
729
+ function capacitySpelling(value) {
730
+ return value === void 0 ? "" : formatCapacity(value);
731
+ }
732
+ /** Adopt a candidate, keeping whatever capacities the provider disclosed. */
733
+ function adopt(candidate) {
734
+ return {
735
+ id: candidate.id,
736
+ ...candidate.name === void 0 ? {} : { name: candidate.name },
737
+ ...candidate.contextWindow === void 0 ? {} : { contextWindow: candidate.contextWindow },
738
+ ...candidate.maxTokens === void 0 ? {} : { maxTokens: candidate.maxTokens }
739
+ };
740
+ }
741
+ /**
742
+ * Render the model list with its fetch action.
743
+ * @param props - the drafted rows, probe target, wire face, and copy.
744
+ * @returns the model-list editor.
745
+ */
746
+ function ModelListEditor(props) {
747
+ const { models, onChange, probe, api, t, disabled } = props;
748
+ const [busy, setBusy] = (0, react.useState)(false);
749
+ const [failure, setFailure] = (0, react.useState)(void 0);
750
+ const [candidates, setCandidates] = (0, react.useState)(void 0);
751
+ const [picked, setPicked] = (0, react.useState)(/* @__PURE__ */ new Set());
752
+ const [expanded, setExpanded] = (0, react.useState)(/* @__PURE__ */ new Set());
753
+ const [editing, setEditing] = (0, react.useState)(/* @__PURE__ */ new Map());
754
+ /** Buffer key for one capacity field; the row half moves when rows do. */
755
+ const bufferKey = (index, field) => `${String(index)}:${field}`;
756
+ const editCapacity = (index, field, text) => {
757
+ setEditing((current) => new Map(current).set(bufferKey(index, field), text));
758
+ patch(index, { [field]: parseCapacity(text) });
759
+ };
760
+ /** What a capacity field shows: the buffer while typing, else the stored count. */
761
+ const capacityText = (model, index, field) => editing.get(bufferKey(index, field)) ?? capacitySpelling(numberOf(model, field));
762
+ /** Drop one row's entries and shift the rows after it down, in one pass. */
763
+ const reindexOnRemove = (current, index) => {
764
+ const next = /* @__PURE__ */ new Map();
765
+ for (const [key, value] of current) {
766
+ const at = Number(key.slice(0, key.indexOf(":")));
767
+ if (at === index) continue;
768
+ next.set(at > index ? key.replace(/^\d+/, String(at - 1)) : key, value);
769
+ }
770
+ return next;
771
+ };
772
+ const toggleExpanded = (index) => {
773
+ setExpanded((current) => {
774
+ const next = new Set(current);
775
+ if (!next.delete(index)) next.add(index);
776
+ return next;
777
+ });
778
+ };
779
+ const patch = (index, next) => {
780
+ onChange(models.map((model, at) => {
781
+ if (at !== index) return model;
782
+ const cleared = new Set(Object.entries(next).filter(([, value]) => value === void 0 || value === "").map(([key]) => key));
783
+ return Object.fromEntries(Object.entries({
784
+ ...model,
785
+ ...next
786
+ }).filter(([key]) => !cleared.has(key)));
787
+ }));
788
+ };
789
+ const fetchModels = async () => {
790
+ setBusy(true);
791
+ setFailure(void 0);
792
+ try {
793
+ const response = await api.llm.discoverModels({
794
+ settingsNs: probe.settingsNs,
795
+ ...probe.provider === void 0 ? {} : { provider: probe.provider },
796
+ ...probe.baseURL === void 0 || probe.baseURL.length === 0 ? {} : { baseURL: probe.baseURL },
797
+ ...probe.api === void 0 ? {} : { api: probe.api },
798
+ ...probe.apiKey === void 0 ? {} : { apiKey: probe.apiKey }
799
+ });
800
+ if (!response.result.ok) {
801
+ setFailure(response.result.error.message);
802
+ return;
803
+ }
804
+ const found = response.result.value.models;
805
+ if (found.length === 0) {
806
+ setFailure(t("fetchEmpty"));
807
+ return;
808
+ }
809
+ const known = new Set(models.map((model) => textOf(model, "id")));
810
+ setCandidates(found);
811
+ setPicked(new Set(found.filter((model) => !known.has(model.id)).map((model) => model.id)));
812
+ } catch (error) {
813
+ setFailure(messageOf(error));
814
+ } finally {
815
+ setBusy(false);
816
+ }
817
+ };
818
+ const closePicker = () => {
819
+ setCandidates(void 0);
820
+ setPicked(/* @__PURE__ */ new Set());
821
+ };
822
+ const adoptPicked = () => {
823
+ /* v8 ignore next -- the dialog only renders with candidates loaded */
824
+ if (candidates === void 0) return;
825
+ const byId = new Map(models.map((model) => [textOf(model, "id"), model]));
826
+ for (const candidate of candidates) {
827
+ if (!picked.has(candidate.id)) continue;
828
+ byId.set(candidate.id, byId.get(candidate.id) ?? adopt(candidate));
829
+ }
830
+ onChange([...byId.values()]);
831
+ closePicker();
832
+ };
833
+ const toggle = (id) => {
834
+ setPicked((current) => {
835
+ const next = new Set(current);
836
+ if (!next.delete(id)) next.add(id);
837
+ return next;
838
+ });
839
+ };
840
+ const askable = probe.provider !== void 0 || probe.baseURL !== void 0 && probe.baseURL.length > 0;
841
+ return (0, react_jsx_runtime.jsxs)("section", {
842
+ className: ModelsSection_module_css_default["modelCatalog"],
843
+ "aria-label": t("models"),
844
+ children: [
845
+ (0, react_jsx_runtime.jsxs)("div", {
846
+ className: ModelsSection_module_css_default["modelListHead"],
847
+ children: [
848
+ (0, react_jsx_runtime.jsxs)("div", {
849
+ className: ModelsSection_module_css_default["modelCatalogHeading"],
850
+ children: [(0, react_jsx_runtime.jsx)("span", {
851
+ className: ModelsSection_module_css_default["modelCatalogTitle"],
852
+ children: t("models")
853
+ }), props.overridden === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
854
+ className: ModelsSection_module_css_default["modelCatalogMeta"],
855
+ children: props.overridden ? t("modelsCustomized") : t("modelsInherited")
856
+ })]
857
+ }),
858
+ props.overridden === true && props.onReset !== void 0 ? (0, react_jsx_runtime.jsx)("button", {
859
+ type: "button",
860
+ className: ModelsSection_module_css_default["linkButton"],
861
+ disabled,
862
+ onClick: props.onReset,
863
+ children: t("resetModels")
864
+ }) : null,
865
+ (0, react_jsx_runtime.jsx)("button", {
866
+ type: "button",
867
+ className: ModelsSection_module_css_default["linkButton"],
868
+ disabled: disabled || busy || !askable || props.probeBlocked !== void 0,
869
+ title: props.probeBlocked !== void 0 ? t(props.probeBlocked) : askable ? void 0 : t("fetchNeedsBaseUrl"),
870
+ onClick: () => {
871
+ fetchModels();
872
+ },
873
+ children: busy ? t("fetching") : t("fetchModels")
874
+ })
875
+ ]
876
+ }),
877
+ models.length === 0 ? (0, react_jsx_runtime.jsx)("p", {
878
+ className: ModelsSection_module_css_default["modelEmpty"],
879
+ children: t("modelsEmpty")
880
+ }) : null,
881
+ models.map((model, index) => (0, react_jsx_runtime.jsxs)("div", {
882
+ className: ModelsSection_module_css_default["modelEntry"],
883
+ children: [(0, react_jsx_runtime.jsxs)("div", {
884
+ className: ModelsSection_module_css_default["modelRow"],
885
+ children: [
886
+ (0, react_jsx_runtime.jsx)("input", {
887
+ className: ModelsSection_module_css_default["input"],
888
+ type: "text",
889
+ value: textOf(model, "id"),
890
+ placeholder: t("modelId"),
891
+ "aria-label": `${t("modelId")} ${index + 1}`,
892
+ disabled,
893
+ onChange: (event) => {
894
+ patch(index, { id: event.target.value });
895
+ }
896
+ }),
897
+ (0, react_jsx_runtime.jsx)("input", {
898
+ className: ModelsSection_module_css_default["input"],
899
+ type: "text",
900
+ value: textOf(model, "name"),
901
+ placeholder: t("modelName"),
902
+ "aria-label": `${t("modelName")} ${index + 1}`,
903
+ disabled,
904
+ onChange: (event) => {
905
+ patch(index, { name: event.target.value === "" ? void 0 : event.target.value });
906
+ }
907
+ }),
908
+ (0, react_jsx_runtime.jsx)("button", {
909
+ type: "button",
910
+ className: ModelsSection_module_css_default["iconButton"],
911
+ "aria-label": `${t("modelAdvanced")} ${index + 1}`,
912
+ "aria-expanded": expanded.has(index),
913
+ title: t("modelAdvanced"),
914
+ onClick: () => {
915
+ toggleExpanded(index);
916
+ },
917
+ children: (0, react_jsx_runtime.jsx)(IconChevron, { open: expanded.has(index) })
918
+ }),
919
+ (0, react_jsx_runtime.jsx)("button", {
920
+ type: "button",
921
+ className: `${ModelsSection_module_css_default["iconButton"]} ${ModelsSection_module_css_default["iconButtonDanger"]}`,
922
+ "aria-label": `${t("removeModel")} ${index + 1}`,
923
+ title: t("removeModel"),
924
+ disabled,
925
+ onClick: () => {
926
+ onChange(models.filter((_model, at) => at !== index));
927
+ setExpanded((current) => {
928
+ const next = /* @__PURE__ */ new Set();
929
+ for (const at of current) if (at < index) next.add(at);
930
+ else if (at > index) next.add(at - 1);
931
+ return next;
932
+ });
933
+ setEditing((current) => reindexOnRemove(current, index));
934
+ },
935
+ children: (0, react_jsx_runtime.jsx)(IconTrash, {})
936
+ })
937
+ ]
938
+ }), expanded.has(index) ? (0, react_jsx_runtime.jsxs)("div", {
939
+ className: ModelsSection_module_css_default["modelAdvanced"],
940
+ children: [(0, react_jsx_runtime.jsxs)("label", {
941
+ className: ModelsSection_module_css_default["modelField"],
942
+ children: [(0, react_jsx_runtime.jsx)("span", {
943
+ className: ModelsSection_module_css_default["modelFieldLabel"],
944
+ children: t("modelContextWindow")
945
+ }), (0, react_jsx_runtime.jsx)("input", {
946
+ className: ModelsSection_module_css_default["input"],
947
+ type: "text",
948
+ inputMode: "numeric",
949
+ value: capacityText(model, index, "contextWindow"),
950
+ placeholder: CAPACITY_HINT.contextWindow,
951
+ "aria-label": `${t("modelContextWindow")} ${index + 1}`,
952
+ disabled,
953
+ onChange: (event) => {
954
+ editCapacity(index, "contextWindow", event.target.value);
955
+ }
956
+ })]
957
+ }), (0, react_jsx_runtime.jsxs)("label", {
958
+ className: ModelsSection_module_css_default["modelField"],
959
+ children: [(0, react_jsx_runtime.jsx)("span", {
960
+ className: ModelsSection_module_css_default["modelFieldLabel"],
961
+ children: t("modelMaxTokens")
962
+ }), (0, react_jsx_runtime.jsx)("input", {
963
+ className: ModelsSection_module_css_default["input"],
964
+ type: "text",
965
+ inputMode: "numeric",
966
+ value: capacityText(model, index, "maxTokens"),
967
+ placeholder: CAPACITY_HINT.maxTokens,
968
+ "aria-label": `${t("modelMaxTokens")} ${index + 1}`,
969
+ disabled,
970
+ onChange: (event) => {
971
+ editCapacity(index, "maxTokens", event.target.value);
972
+ }
973
+ })]
974
+ })]
975
+ }) : null]
976
+ }, index)),
977
+ (0, react_jsx_runtime.jsx)("button", {
978
+ type: "button",
979
+ className: ModelsSection_module_css_default["addModelButton"],
980
+ disabled,
981
+ onClick: () => {
982
+ onChange([...models, { id: "" }]);
983
+ },
984
+ children: t("addModel")
985
+ }),
986
+ failure !== void 0 ? (0, react_jsx_runtime.jsx)("p", {
987
+ className: ModelsSection_module_css_default["error"],
988
+ children: failure
989
+ }) : null,
990
+ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
991
+ open: candidates !== void 0,
992
+ onClose: closePicker,
993
+ title: t("fetchTitle"),
994
+ closeLabel: t("close"),
995
+ description: t("fetchDescription"),
996
+ className: ModelsSection_module_css_default["fetchDialog"],
997
+ footer: (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
998
+ variant: "outline",
999
+ onClick: closePicker,
1000
+ children: t("cancel")
1001
+ }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1002
+ variant: "outline",
1003
+ onClick: adoptPicked,
1004
+ children: t("fetchAdopt")
1005
+ })] }),
1006
+ children: (0, react_jsx_runtime.jsx)("ul", {
1007
+ className: ModelsSection_module_css_default["candidateList"],
1008
+ children: (candidates ?? []).map((candidate) => (0, react_jsx_runtime.jsx)("li", {
1009
+ className: ModelsSection_module_css_default["candidate"],
1010
+ children: (0, react_jsx_runtime.jsxs)("label", {
1011
+ className: ModelsSection_module_css_default["candidateLabel"],
1012
+ children: [(0, react_jsx_runtime.jsx)("input", {
1013
+ type: "checkbox",
1014
+ checked: picked.has(candidate.id),
1015
+ onChange: () => {
1016
+ toggle(candidate.id);
1017
+ }
1018
+ }), (0, react_jsx_runtime.jsx)("span", {
1019
+ className: ModelsSection_module_css_default["candidateId"],
1020
+ children: candidate.id
1021
+ })]
1022
+ })
1023
+ }, candidate.id))
1024
+ })
1025
+ })
1026
+ ]
1027
+ });
1028
+ }
1029
+ //#endregion
1030
+ //#region lib/types/client/CustomProviderCard.js
1031
+ /**
1032
+ * The card that declares a provider pi-ai does not ship — an OpenAI-compatible
1033
+ * gateway, a self-hosted server, or a provider newer than the installed
1034
+ * catalog.
1035
+ *
1036
+ * This is a create, not an edit, which is why it is its own card rather than
1037
+ * the provider editor with extra fields: the route id is being *chosen* here,
1038
+ * and the settings address does not exist until it is. One `settings.mutate`
1039
+ * sets the whole profile at `providers.<route>`; the key travels separately
1040
+ * through `credentials.set` under the reference the profile records, exactly as
1041
+ * an existing provider's key does.
1042
+ *
1043
+ * The three fields a hand-declared route cannot default — endpoint, protocol,
1044
+ * and at least one model — are required here rather than at load, so the
1045
+ * failure names the field while the user is still looking at it.
1046
+ *
1047
+ * There is deliberately no reasoning-effort control, here or on the editor
1048
+ * card: effort is a per-MODEL capability, and the models under one provider
1049
+ * disagree about it, so a provider-scoped control can only be set to a value
1050
+ * some of them reject. The composer's model picker offers each model its own
1051
+ * levels instead.
1052
+ */
1053
+ /** The settings namespace a hand-declared provider is written into. */
1054
+ const NS$1 = "llm-pi-ai";
1055
+ /**
1056
+ * A route id usable as a settings key AND as the stem of a credential name.
1057
+ * The leading letter is the second half of that: `deriveKeyRef` uppercases the
1058
+ * id and replaces every non-alphanumeric run with `_`, and a credential
1059
+ * reference is a POSIX shell identifier, which cannot start with a digit. A
1060
+ * digit-leading id passes every check this card makes and then fails at the
1061
+ * credential seam with a raw regular expression the user cannot act on.
1062
+ */
1063
+ const ROUTE_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
1064
+ /**
1065
+ * Render the custom-provider creation card.
1066
+ * @param props - existing routes, protocol choices, wire faces, and copy.
1067
+ * @returns the creation card.
1068
+ */
1069
+ function CustomProviderCard(props) {
1070
+ const { taken, protocols, api, t } = props;
1071
+ const [openedAt] = (0, react.useState)(() => props.revision);
1072
+ const [route, setRoute] = (0, react.useState)("");
1073
+ const [displayName, setDisplayName] = (0, react.useState)("");
1074
+ const [baseURL, setBaseURL] = (0, react.useState)("");
1075
+ const [protocol, setProtocol] = (0, react.useState)(protocols[0] ?? "");
1076
+ const [keyDraft, setKeyDraft] = (0, react.useState)("");
1077
+ const [models, setModels] = (0, react.useState)([]);
1078
+ const [busy, setBusy] = (0, react.useState)(false);
1079
+ const [failure, setFailure] = (0, react.useState)(void 0);
1080
+ /**
1081
+ * The profile write landed. Only the key write can still be outstanding, so
1082
+ * the fields that describe the provider are settled and the retry path is
1083
+ * the credential alone.
1084
+ */
1085
+ const [committed, setCommitted] = (0, react.useState)(false);
1086
+ const disabled = props.readOnly || busy;
1087
+ /** Everything but the key stops being editable once the provider exists. */
1088
+ const profileDisabled = disabled || committed;
1089
+ const routeInvalid = route.length > 0 && !ROUTE_PATTERN.test(route);
1090
+ const routeTaken = taken.includes(route);
1091
+ const modelFailure = validateDeepSeekModels(models);
1092
+ const keyFailure = apiKeyFailure(keyDraft);
1093
+ const keyValue = keyDraft.trim();
1094
+ const ready = route.length > 0 && !routeInvalid && !routeTaken && baseURL.length > 0 && models.length > 0 && modelFailure === void 0 && keyFailure === void 0;
1095
+ const hint = failure !== void 0 || ready || keyFailure !== void 0 || route.length === 0 || routeInvalid || routeTaken ? void 0 : baseURL.length === 0 ? t("customNeedsBaseUrl") : modelFailure !== void 0 ? `${t("model")} ${String(modelFailure.index + 1)}: ${t(modelFailure.key)}` : t("customNeedsModels");
1096
+ /** Perform the create, returning a failure message or undefined. */
1097
+ const createOnce = async () => {
1098
+ const keyRef = deriveKeyRef(route);
1099
+ const storesKey = keyValue.length > 0;
1100
+ if (!committed) {
1101
+ const profile = {
1102
+ ...displayName.length === 0 ? {} : { displayName },
1103
+ ...storesKey ? { apiKeyEnv: keyRef } : {},
1104
+ api: protocol,
1105
+ baseURL,
1106
+ models: models.map((model) => ({ ...model }))
1107
+ };
1108
+ const response = await api.settings.mutate({
1109
+ ns: NS$1,
1110
+ ops: [{
1111
+ op: "set",
1112
+ path: ["providers", route],
1113
+ value: profile
1114
+ }],
1115
+ expectedRevision: openedAt
1116
+ });
1117
+ if (!response.result.ok) return response.result.error.message;
1118
+ setCommitted(true);
1119
+ }
1120
+ if (storesKey) {
1121
+ const stored = await api.credentials.set({
1122
+ ref: keyRef,
1123
+ value: keyValue
1124
+ });
1125
+ if (!stored.result.ok) return stored.result.error.message;
1126
+ }
1127
+ };
1128
+ const create = async () => {
1129
+ setBusy(true);
1130
+ setFailure(void 0);
1131
+ try {
1132
+ const outcome = await createOnce();
1133
+ if (outcome !== void 0) {
1134
+ setFailure(outcome);
1135
+ return;
1136
+ }
1137
+ props.onClose(true);
1138
+ } catch (error) {
1139
+ setFailure(messageOf(error));
1140
+ } finally {
1141
+ setBusy(false);
1142
+ }
1143
+ };
1144
+ return (0, react_jsx_runtime.jsxs)("div", {
1145
+ className: ModelsSection_module_css_default["editor"],
1146
+ children: [
1147
+ (0, react_jsx_runtime.jsx)("div", {
1148
+ className: ModelsSection_module_css_default["editorHeader"],
1149
+ children: (0, react_jsx_runtime.jsx)("span", {
1150
+ className: ModelsSection_module_css_default["editorTitle"],
1151
+ children: t("customTitle")
1152
+ })
1153
+ }),
1154
+ (0, react_jsx_runtime.jsxs)("div", {
1155
+ className: ModelsSection_module_css_default["field"],
1156
+ children: [(0, react_jsx_runtime.jsx)("span", {
1157
+ className: ModelsSection_module_css_default["fieldLabel"],
1158
+ children: t("customRoute")
1159
+ }), (0, react_jsx_runtime.jsx)("input", {
1160
+ className: ModelsSection_module_css_default["input"],
1161
+ type: "text",
1162
+ value: route,
1163
+ placeholder: "acme-gateway",
1164
+ "aria-label": t("customRoute"),
1165
+ disabled: profileDisabled,
1166
+ onChange: (event) => {
1167
+ setRoute(event.target.value);
1168
+ }
1169
+ })]
1170
+ }),
1171
+ routeInvalid || routeTaken ? (0, react_jsx_runtime.jsx)("p", {
1172
+ className: ModelsSection_module_css_default["error"],
1173
+ children: t(routeInvalid ? "customRouteInvalid" : "customRouteTaken")
1174
+ }) : (0, react_jsx_runtime.jsx)("p", {
1175
+ className: ModelsSection_module_css_default["advancedHint"],
1176
+ children: t("customRouteHint")
1177
+ }),
1178
+ (0, react_jsx_runtime.jsxs)("div", {
1179
+ className: ModelsSection_module_css_default["field"],
1180
+ children: [(0, react_jsx_runtime.jsx)("span", {
1181
+ className: ModelsSection_module_css_default["fieldLabel"],
1182
+ children: t("customDisplayName")
1183
+ }), (0, react_jsx_runtime.jsx)("input", {
1184
+ className: ModelsSection_module_css_default["input"],
1185
+ type: "text",
1186
+ value: displayName,
1187
+ placeholder: route.length === 0 ? t("customDisplayName") : route,
1188
+ "aria-label": t("customDisplayName"),
1189
+ disabled: profileDisabled,
1190
+ onChange: (event) => {
1191
+ setDisplayName(event.target.value);
1192
+ }
1193
+ })]
1194
+ }),
1195
+ (0, react_jsx_runtime.jsxs)("div", {
1196
+ className: ModelsSection_module_css_default["field"],
1197
+ children: [(0, react_jsx_runtime.jsx)("span", {
1198
+ className: ModelsSection_module_css_default["fieldLabel"],
1199
+ children: t("baseUrl")
1200
+ }), (0, react_jsx_runtime.jsx)("input", {
1201
+ className: ModelsSection_module_css_default["input"],
1202
+ type: "text",
1203
+ value: baseURL,
1204
+ placeholder: "https://gateway.example/v1",
1205
+ "aria-label": t("baseUrl"),
1206
+ disabled: profileDisabled,
1207
+ onChange: (event) => {
1208
+ setBaseURL(event.target.value);
1209
+ }
1210
+ })]
1211
+ }),
1212
+ (0, react_jsx_runtime.jsxs)("div", {
1213
+ className: ModelsSection_module_css_default["field"],
1214
+ children: [(0, react_jsx_runtime.jsx)("span", {
1215
+ className: ModelsSection_module_css_default["fieldLabel"],
1216
+ children: t("customApi")
1217
+ }), (0, react_jsx_runtime.jsx)("select", {
1218
+ className: `${ModelsSection_module_css_default["input"]} ${ModelsSection_module_css_default["selectInput"]}`,
1219
+ value: protocol,
1220
+ "aria-label": t("customApi"),
1221
+ disabled: profileDisabled,
1222
+ onChange: (event) => {
1223
+ setProtocol(event.target.value);
1224
+ },
1225
+ children: protocols.map((choice) => (0, react_jsx_runtime.jsx)("option", {
1226
+ value: choice,
1227
+ children: choice
1228
+ }, choice))
1229
+ })]
1230
+ }),
1231
+ (0, react_jsx_runtime.jsxs)("div", {
1232
+ className: ModelsSection_module_css_default["field"],
1233
+ children: [
1234
+ (0, react_jsx_runtime.jsx)("span", {
1235
+ className: ModelsSection_module_css_default["fieldLabel"],
1236
+ children: t("keyInput")
1237
+ }),
1238
+ (0, react_jsx_runtime.jsx)("input", {
1239
+ className: ModelsSection_module_css_default["input"],
1240
+ type: "password",
1241
+ autoComplete: "off",
1242
+ value: keyDraft,
1243
+ placeholder: t("keyPlaceholder"),
1244
+ "aria-label": t("keyInput"),
1245
+ disabled,
1246
+ onChange: (event) => {
1247
+ setKeyDraft(event.target.value);
1248
+ }
1249
+ }),
1250
+ keyFailure === void 0 ? null : (0, react_jsx_runtime.jsx)("p", {
1251
+ className: ModelsSection_module_css_default["error"],
1252
+ children: t(keyFailure === "keyBlank" ? "keyBlankNew" : keyFailure)
1253
+ })
1254
+ ]
1255
+ }),
1256
+ (0, react_jsx_runtime.jsx)(ModelListEditor, {
1257
+ models,
1258
+ onChange: setModels,
1259
+ probe: {
1260
+ settingsNs: NS$1,
1261
+ baseURL,
1262
+ api: protocol,
1263
+ ...keyValue.length === 0 ? {} : { apiKey: keyValue }
1264
+ },
1265
+ probeBlocked: keyFailure === "keyBlank" ? "keyBlankNew" : keyFailure,
1266
+ api,
1267
+ t,
1268
+ disabled: profileDisabled
1269
+ }),
1270
+ failure !== void 0 ? (0, react_jsx_runtime.jsx)("p", {
1271
+ className: ModelsSection_module_css_default["error"],
1272
+ children: failure
1273
+ }) : null,
1274
+ hint === void 0 ? null : (0, react_jsx_runtime.jsx)("p", {
1275
+ className: ModelsSection_module_css_default["advancedHint"],
1276
+ children: hint
1277
+ }),
1278
+ (0, react_jsx_runtime.jsx)(EditorFooter, {
1279
+ t,
1280
+ busy,
1281
+ submitDisabled: disabled || !ready,
1282
+ submitLabel: "create",
1283
+ submitBusyLabel: "creating",
1284
+ onCancel: () => {
1285
+ props.onClose(committed);
1286
+ },
1287
+ onSubmit: () => {
1288
+ create();
1289
+ }
1290
+ })
1291
+ ]
1292
+ });
1293
+ }
1294
+ //#endregion
1295
+ //#region lib/types/client/ProviderEditor.js
1296
+ /**
1297
+ * One provider's editor card, hand-written per adapter family: the primary
1298
+ * field is a single write-only **API key** input (the page never asks for an
1299
+ * environment-variable name — a typed key stores through `credentials.set`
1300
+ * under the profile's reference, deriving `<ROUTE>_API_KEY` when the profile
1301
+ * has none. The pi-ai profile records that derivation as `apiKeyEnv` only when
1302
+ * a key is entered; a blank key materializes a reference-free profile for
1303
+ * provider-native authentication);
1304
+ * the collapsed 自定义设置 area carries the per-family extras (`baseURL` for
1305
+ * both families, DeepSeek's id/name/context-window model catalog, and the
1306
+ * display name and wire protocol of a pi-ai route the adapter does not ship —
1307
+ * the two fields the create card asked that route for, editable here for the
1308
+ * same reason).
1309
+ * Reasoning effort is deliberately absent: it is a per-MODEL capability, and
1310
+ * the models under one provider disagree about it, so a provider-scoped
1311
+ * control can only be set to a value some of them reject. The composer's
1312
+ * model picker offers each model its own levels; `settings.yaml` keeps the
1313
+ * profile field for a deployment that knows its route. Everything else stays
1314
+ * owned by `settings.yaml`. Profile edits land as minimal `settings.mutate`
1315
+ * path ops against the stored section — the card names only the fields it can
1316
+ * see instead of rebuilding the whole subtree from a partial descriptor.
1317
+ */
1318
+ /** The public DeepSeek endpoint shown as the deepseek base-URL placeholder. */
1319
+ const DEEPSEEK_PUBLIC_BASE_URL = "https://api.deepseek.com";
1320
+ /** A user-section subtree as a plain draft object (absent → empty). */
1321
+ function draftAt(namespace, path) {
1322
+ const subtree = (0, _deepseek_ai_dsh_client_schema_form.getPath)(namespace.user, path);
1323
+ if (typeof subtree !== "object" || subtree === null || Array.isArray(subtree)) return {};
1324
+ return structuredClone(subtree);
1325
+ }
1326
+ /**
1327
+ * The minimal path ops carrying `after` over `before`, both as the card sees
1328
+ * them. Only keys the card observed are named; fields absent from both sides
1329
+ * produce no op, which is why edits are path-addressed rather than a rebuilt
1330
+ * section.
1331
+ * @param base - path of the edited subtree inside the user section.
1332
+ * @param before - the subtree as loaded, or undefined when it is new.
1333
+ * @param after - the subtree as edited.
1334
+ * @returns ordered set/unset ops; empty when nothing changed.
1335
+ */
1336
+ function pathOps(base, before, after) {
1337
+ const previous = typeof before === "object" && before !== null && !Array.isArray(before) ? before : {};
1338
+ const ops = [];
1339
+ for (const [key, value] of Object.entries(after)) {
1340
+ if (JSON.stringify(previous[key]) === JSON.stringify(value)) continue;
1341
+ ops.push({
1342
+ op: "set",
1343
+ path: [...base, key],
1344
+ value
1345
+ });
1346
+ }
1347
+ for (const key of Object.keys(previous)) if (!(key in after)) ops.push({
1348
+ op: "unset",
1349
+ path: [...base, key]
1350
+ });
1351
+ return ops;
1352
+ }
1353
+ /** The editor layout the owning namespace selects. */
1354
+ function layoutOf(ns) {
1355
+ if (ns === "llm-deepseek") return "deepseek";
1356
+ if (ns === "llm-pi-ai") return "pi-ai";
1357
+ return "unknown";
1358
+ }
1359
+ /** The credential reference this profile resolves keys through. */
1360
+ function refFor(namespace, path, provider) {
1361
+ const profile = (0, _deepseek_ai_dsh_client_schema_form.getPath)(namespace.value, path);
1362
+ const named = typeof profile === "object" && profile !== null ? profile.apiKeyEnv : void 0;
1363
+ return typeof named === "string" && named.length > 0 ? named : deriveKeyRef(provider);
1364
+ }
1365
+ /**
1366
+ * Render one provider's editing card.
1367
+ * @param props - the addressed profile plus wire faces and copy.
1368
+ * @returns the editor card.
1369
+ */
1370
+ function ProviderEditor(props) {
1371
+ const { namespace, settingsPath, api, t } = props;
1372
+ const [draft, setDraft] = (0, react.useState)(() => draftAt(namespace, settingsPath));
1373
+ const [keyDraft, setKeyDraft] = (0, react.useState)("");
1374
+ const [keyState, setKeyState] = (0, react.useState)(void 0);
1375
+ const [busy, setBusy] = (0, react.useState)(false);
1376
+ const [failure, setFailure] = (0, react.useState)(void 0);
1377
+ const [committedOriginal, setCommittedOriginal] = (0, react.useState)(() => (0, _deepseek_ai_dsh_client_schema_form.getPath)(namespace.user, settingsPath));
1378
+ const [expectedRevision, setExpectedRevision] = (0, react.useState)(() => namespace.revision);
1379
+ const root = (0, react.useMemo)(() => (0, _deepseek_ai_dsh_client_schema_form.rehydrateSchema)(namespace.schema), [namespace.schema]);
1380
+ const node = (0, react.useMemo)(() => (0, _deepseek_ai_dsh_client_schema_form.nodeAtPath)(root, settingsPath), [root, settingsPath]);
1381
+ const fallback = (0, _deepseek_ai_dsh_client_schema_form.getPath)(namespace.value, settingsPath);
1382
+ const disabled = props.readOnly || busy;
1383
+ const layout = layoutOf(namespace.ns);
1384
+ const keyRef = refFor(namespace, settingsPath, props.provider);
1385
+ const protocols = (0, react.useMemo)(() => layout === "pi-ai" ? protocolChoices(namespace) : [], [layout, namespace]);
1386
+ (0, react.useEffect)(() => {
1387
+ let stale = false;
1388
+ setKeyState(void 0);
1389
+ api.credentials.describe({ refs: [keyRef] }).then((response) => {
1390
+ if (stale || !response.result.ok) return;
1391
+ setKeyState(response.result.value.credentials[keyRef]);
1392
+ }, () => void 0);
1393
+ return () => {
1394
+ stale = true;
1395
+ };
1396
+ }, [api.credentials, keyRef]);
1397
+ const stringAt = (source, key) => {
1398
+ const value = (0, _deepseek_ai_dsh_client_schema_form.getPath)(source, [key]);
1399
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
1400
+ };
1401
+ const setField = (key, next) => {
1402
+ const value = next === void 0 || next.trim().length === 0 ? void 0 : next;
1403
+ setDraft((current) => value === void 0 ? (0, _deepseek_ai_dsh_client_schema_form.deletePath)(current, [key]) : (0, _deepseek_ai_dsh_client_schema_form.setPath)(current, [key], value));
1404
+ };
1405
+ const modelFailure = validateDeepSeekModels((0, _deepseek_ai_dsh_client_schema_form.getPath)(draft, ["models"]));
1406
+ const keyFailure = apiKeyFailure(keyDraft);
1407
+ const keyValue = keyDraft.trim();
1408
+ const probeApi = stringAt(draft, "api") ?? stringAt(fallback, "api");
1409
+ const probeBaseURL = stringAt(draft, "baseURL") ?? stringAt(fallback, "baseURL");
1410
+ const probe = {
1411
+ settingsNs: namespace.ns,
1412
+ provider: props.provider,
1413
+ ...probeBaseURL === void 0 ? {} : { baseURL: probeBaseURL },
1414
+ ...probeApi === void 0 ? {} : { api: probeApi },
1415
+ ...keyValue.length === 0 ? {} : { apiKey: keyValue }
1416
+ };
1417
+ /**
1418
+ * The write for this card, or a failure message. Every edit travels as
1419
+ * path ops against the STORED section: the draft comes from the redacted
1420
+ * descriptor, so a wholesale replace rebuilt from it could delete fields
1421
+ * outside the card. Ops name only the fields this card can see.
1422
+ */
1423
+ const applyOnce = async () => {
1424
+ const ns = namespace.ns;
1425
+ const next = layout === "pi-ai" && stringAt(draft, "apiKeyEnv") === void 0 && stringAt(fallback, "apiKeyEnv") === void 0 && keyValue.length > 0 ? (0, _deepseek_ai_dsh_client_schema_form.setPath)(draft, ["apiKeyEnv"], keyRef) : draft;
1426
+ {
1427
+ const failure = validateDeepSeekModels((0, _deepseek_ai_dsh_client_schema_form.getPath)(next, ["models"]));
1428
+ /* v8 ignore next 3 -- unreachable from the card: the same failure disables submit */
1429
+ if (failure !== void 0) return `${t("model")} ${String(failure.index + 1)}: ${t(failure.key)}`;
1430
+ }
1431
+ /* v8 ignore next -- apply is only reachable from the rendered card, which required a resolved node */
1432
+ if (node !== void 0 && settingsPath.length === 0) {
1433
+ const sectionError = (0, _deepseek_ai_dsh_client_schema_form.validateDraft)(node, next);
1434
+ if (sectionError !== void 0) return sectionError;
1435
+ }
1436
+ const ops = layout === "pi-ai" && fallback === void 0 && committedOriginal === void 0 && Object.keys(next).length === 0 ? [{
1437
+ op: "set",
1438
+ path: [...settingsPath],
1439
+ value: {}
1440
+ }] : pathOps(settingsPath, committedOriginal, next);
1441
+ if (ops.length > 0) {
1442
+ const response = await api.settings.mutate({
1443
+ ns,
1444
+ ops,
1445
+ expectedRevision
1446
+ });
1447
+ if (!response.result.ok) return response.result.error.code === "settings-conflict" ? t("conflict") : response.result.error.message;
1448
+ setCommittedOriginal((0, _deepseek_ai_dsh_client_schema_form.getPath)(response.result.value.user, settingsPath));
1449
+ setExpectedRevision(response.result.value.revision);
1450
+ setDraft(next);
1451
+ }
1452
+ if (keyValue.length > 0) {
1453
+ const stored = await api.credentials.set({
1454
+ ref: keyRef,
1455
+ value: keyValue
1456
+ });
1457
+ if (!stored.result.ok) return stored.result.error.message;
1458
+ }
1459
+ setKeyDraft("");
1460
+ };
1461
+ const apply = async () => {
1462
+ setBusy(true);
1463
+ setFailure(void 0);
1464
+ try {
1465
+ const failure = await applyOnce();
1466
+ if (failure !== void 0) {
1467
+ setFailure(failure);
1468
+ return;
1469
+ }
1470
+ props.onClose(true);
1471
+ } catch (error) {
1472
+ setFailure(messageOf(error));
1473
+ } finally {
1474
+ setBusy(false);
1475
+ }
1476
+ };
1477
+ if (node === void 0) return (0, react_jsx_runtime.jsx)("p", {
1478
+ className: ModelsSection_module_css_default["error"],
1479
+ children: `${props.provider}: unresolvable settings path`
1480
+ });
1481
+ const keyLocked = keyState?.writable === false;
1482
+ /**
1483
+ * The catalog beneath the user layer: what the composition entry pinned, or
1484
+ * else the schema default that `resolve` would supply. The effective value
1485
+ * cannot answer this — it still carries the stored override until the unset
1486
+ * is applied, so reading it would echo that override straight back the
1487
+ * moment reset drops it, leaving the rows unchanged until a reload.
1488
+ */
1489
+ const inheritedModels = () => {
1490
+ return (0, _deepseek_ai_dsh_client_schema_form.getPath)(namespace.base, [...settingsPath, "models"]) ?? (0, _deepseek_ai_dsh_client_schema_form.nodeAtPath)(root, [...settingsPath, "models"])?.meta.default;
1491
+ };
1492
+ /**
1493
+ * The curated fields of one known adapter family. The family arrives
1494
+ * narrowed so the per-family branches below are total: an unknown namespace
1495
+ * renders the hint instead and never reaches this body.
1496
+ */
1497
+ const curatedFields = (family) => {
1498
+ const ownsIdentity = family === "pi-ai" && props.declared === true;
1499
+ const customModels = (0, _deepseek_ai_dsh_client_schema_form.getPath)(draft, ["models"]);
1500
+ const modelsOverridden = (0, _deepseek_ai_dsh_client_schema_form.hasPath)(draft, ["models"]);
1501
+ const models = modelDrafts(modelsOverridden ? customModels : inheritedModels());
1502
+ const defaultContextWindow = (0, _deepseek_ai_dsh_client_schema_form.getPath)(fallback, ["defaultContextWindow"]);
1503
+ const defaultMaxTokens = (0, _deepseek_ai_dsh_client_schema_form.getPath)(fallback, ["maxTokens"]);
1504
+ const keyPlaceholder = keyLocked ? t("keyEnvLocked") : keyState?.configured === true ? t("keyStored") : family === "pi-ai" ? t("keyPlaceholderNative") : t("keyPlaceholder");
1505
+ /** What both family editors take: the rows, whose layer owns them, and the two writes. */
1506
+ const catalogProps = {
1507
+ models,
1508
+ overridden: modelsOverridden,
1509
+ t,
1510
+ disabled,
1511
+ onChange: (next) => {
1512
+ setDraft((current) => (0, _deepseek_ai_dsh_client_schema_form.setPath)(current, ["models"], next));
1513
+ },
1514
+ onReset: () => {
1515
+ setDraft((current) => (0, _deepseek_ai_dsh_client_schema_form.deletePath)(current, ["models"]));
1516
+ }
1517
+ };
1518
+ return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsxs)("div", {
1519
+ className: ModelsSection_module_css_default["field"],
1520
+ children: [
1521
+ (0, react_jsx_runtime.jsx)("span", {
1522
+ className: ModelsSection_module_css_default["fieldLabel"],
1523
+ children: t("keyInput")
1524
+ }),
1525
+ (0, react_jsx_runtime.jsx)("input", {
1526
+ className: ModelsSection_module_css_default["input"],
1527
+ type: "password",
1528
+ autoComplete: "off",
1529
+ value: keyDraft,
1530
+ placeholder: keyPlaceholder,
1531
+ "aria-label": t("keyInput"),
1532
+ disabled: disabled || keyLocked,
1533
+ onChange: (event) => {
1534
+ setKeyDraft(event.target.value);
1535
+ }
1536
+ }),
1537
+ keyFailure === void 0 ? null : (0, react_jsx_runtime.jsx)("p", {
1538
+ className: ModelsSection_module_css_default["error"],
1539
+ children: t(keyFailure)
1540
+ })
1541
+ ]
1542
+ }), (0, react_jsx_runtime.jsxs)("details", {
1543
+ className: ModelsSection_module_css_default["customized"],
1544
+ children: [(0, react_jsx_runtime.jsx)("summary", {
1545
+ className: ModelsSection_module_css_default["customizedSummary"],
1546
+ children: t("customized")
1547
+ }), (0, react_jsx_runtime.jsxs)("div", {
1548
+ className: ModelsSection_module_css_default["customizedBody"],
1549
+ children: [
1550
+ ownsIdentity ? (0, react_jsx_runtime.jsxs)("div", {
1551
+ className: ModelsSection_module_css_default["field"],
1552
+ children: [(0, react_jsx_runtime.jsx)("span", {
1553
+ className: ModelsSection_module_css_default["fieldLabel"],
1554
+ children: t("customDisplayName")
1555
+ }), (0, react_jsx_runtime.jsx)("input", {
1556
+ className: ModelsSection_module_css_default["input"],
1557
+ type: "text",
1558
+ value: stringAt(draft, "displayName") ?? "",
1559
+ placeholder: stringAt((0, _deepseek_ai_dsh_client_schema_form.getPath)(namespace.base, settingsPath), "displayName") ?? props.provider,
1560
+ "aria-label": t("customDisplayName"),
1561
+ disabled,
1562
+ onChange: (event) => {
1563
+ setField("displayName", event.target.value);
1564
+ }
1565
+ })]
1566
+ }) : null,
1567
+ (0, react_jsx_runtime.jsxs)("div", {
1568
+ className: ModelsSection_module_css_default["field"],
1569
+ children: [(0, react_jsx_runtime.jsx)("span", {
1570
+ className: ModelsSection_module_css_default["fieldLabel"],
1571
+ children: t("baseUrl")
1572
+ }), (0, react_jsx_runtime.jsx)("input", {
1573
+ className: ModelsSection_module_css_default["input"],
1574
+ type: "text",
1575
+ value: stringAt(draft, "baseURL") ?? "",
1576
+ placeholder: family === "deepseek" ? DEEPSEEK_PUBLIC_BASE_URL : stringAt(fallback, "baseURL") ?? t("baseUrlDefault"),
1577
+ "aria-label": t("baseUrl"),
1578
+ disabled,
1579
+ onChange: (event) => {
1580
+ setField("baseURL", event.target.value === "" ? void 0 : event.target.value);
1581
+ }
1582
+ })]
1583
+ }),
1584
+ ownsIdentity ? (0, react_jsx_runtime.jsxs)("div", {
1585
+ className: ModelsSection_module_css_default["field"],
1586
+ children: [(0, react_jsx_runtime.jsx)("span", {
1587
+ className: ModelsSection_module_css_default["fieldLabel"],
1588
+ children: t("customApi")
1589
+ }), (0, react_jsx_runtime.jsxs)("select", {
1590
+ className: `${ModelsSection_module_css_default["input"]} ${ModelsSection_module_css_default["selectInput"]}`,
1591
+ value: probeApi ?? "",
1592
+ "aria-label": t("customApi"),
1593
+ disabled,
1594
+ onChange: (event) => {
1595
+ setField("api", event.target.value);
1596
+ },
1597
+ children: [probeApi === void 0 ? (0, react_jsx_runtime.jsx)("option", {
1598
+ value: "",
1599
+ children: t("customApiUnset")
1600
+ }) : null, protocols.map((choice) => (0, react_jsx_runtime.jsx)("option", {
1601
+ value: choice,
1602
+ children: choice
1603
+ }, choice))]
1604
+ })]
1605
+ }) : null,
1606
+ family === "deepseek" ? (0, react_jsx_runtime.jsx)(DeepSeekModelsEditor, {
1607
+ ...catalogProps,
1608
+ defaultContextWindow: typeof defaultContextWindow === "number" ? defaultContextWindow : void 0,
1609
+ defaultMaxTokens: typeof defaultMaxTokens === "number" ? defaultMaxTokens : void 0
1610
+ }) : (0, react_jsx_runtime.jsx)(ModelListEditor, {
1611
+ ...catalogProps,
1612
+ probe,
1613
+ probeBlocked: keyFailure,
1614
+ api
1615
+ })
1616
+ ]
1617
+ })]
1618
+ })] });
1619
+ };
1620
+ return (0, react_jsx_runtime.jsxs)("div", {
1621
+ className: ModelsSection_module_css_default["editor"],
1622
+ children: [
1623
+ props.hideTitle === true ? null : (0, react_jsx_runtime.jsxs)("div", {
1624
+ className: ModelsSection_module_css_default["editorHeader"],
1625
+ children: [(0, react_jsx_runtime.jsx)("span", {
1626
+ className: ModelsSection_module_css_default["editorTitle"],
1627
+ children: props.displayName
1628
+ }), props.provider !== props.displayName ? (0, react_jsx_runtime.jsx)("span", {
1629
+ className: ModelsSection_module_css_default["editorRoute"],
1630
+ children: props.provider
1631
+ }) : null]
1632
+ }),
1633
+ layout === "unknown" ? (0, react_jsx_runtime.jsx)("p", {
1634
+ className: ModelsSection_module_css_default["advancedHint"],
1635
+ children: `${t("advancedHint")} (${namespace.ns})`
1636
+ }) : curatedFields(layout),
1637
+ failure !== void 0 ? (0, react_jsx_runtime.jsx)("p", {
1638
+ className: ModelsSection_module_css_default["error"],
1639
+ children: failure
1640
+ }) : null,
1641
+ modelFailure === void 0 ? null : (0, react_jsx_runtime.jsx)("p", {
1642
+ className: ModelsSection_module_css_default["advancedHint"],
1643
+ children: `${t("model")} ${String(modelFailure.index + 1)}: ${t(modelFailure.key)}`
1644
+ }),
1645
+ (0, react_jsx_runtime.jsx)(EditorFooter, {
1646
+ t,
1647
+ busy,
1648
+ submitDisabled: disabled || layout === "unknown" || modelFailure !== void 0 || keyFailure !== void 0,
1649
+ submitLabel: "apply",
1650
+ submitBusyLabel: "applying",
1651
+ onCancel: () => {
1652
+ props.onClose(false);
1653
+ },
1654
+ onSubmit: () => {
1655
+ apply();
1656
+ }
1657
+ })
1658
+ ]
1659
+ });
1660
+ }
1661
+ //#endregion
1662
+ //#region lib/types/client/ModelsSection.js
1663
+ /**
1664
+ * Models settings section: the provider rows joined from the configurable
1665
+ * directory, settings namespaces, and credential states, with one editor
1666
+ * card at a time. Rows expose only confirmed API-key state through accessible
1667
+ * solid configured or missing dots. A whole-section provider without a
1668
+ * configured key renders as its open setup card instead of a row, but only in
1669
+ * the first-run posture — no provider on the page can serve requests yet — and
1670
+ * only until the user closes that card; the add flow is a card carrying the
1671
+ * dormant-provider select. Each card kind owns its own open state, so closing
1672
+ * one never discards a draft in another. Every mutation writes through the
1673
+ * wire, while a provider removal first requires confirmation; the page
1674
+ * re-renders from pushed invalidations or the post-apply reload.
1675
+ */
1676
+ /** Render an editor for either the setup posture or an expanded provider row. */
1677
+ function renderProviderEditor({ target, ...props }) {
1678
+ return (0, react_jsx_runtime.jsx)(ProviderEditor, {
1679
+ provider: target.provider,
1680
+ displayName: target.displayName,
1681
+ settingsPath: target.settingsPath,
1682
+ ...target.declared === true ? { declared: true } : {},
1683
+ ...props
1684
+ });
1685
+ }
1686
+ /**
1687
+ * Remove one user-added provider and its page-managed credential. Credential
1688
+ * removal comes first so a second-step failure leaves the provider row visible
1689
+ * and the whole operation safely retryable; both unsets are idempotent.
1690
+ * The settings removal names the profile rather than rebuilding its whole
1691
+ * namespace from a partial view.
1692
+ * @param api - settings and credential wire faces.
1693
+ * @param controller - the page store to refresh.
1694
+ * @param target - the provider's settings address and optional managed credential.
1695
+ * @returns the failure message, or undefined once the write and reload landed.
1696
+ */
1697
+ async function removeProviderProfile(api, controller, target) {
1698
+ try {
1699
+ if (target.credentialRef !== void 0) {
1700
+ const credential = await api.credentials.unset({ ref: target.credentialRef });
1701
+ if (!credential.result.ok) return credential.result.error.message;
1702
+ }
1703
+ const response = await api.settings.mutate({
1704
+ ns: target.settingsNs,
1705
+ ops: [{
1706
+ op: "unset",
1707
+ path: [...target.settingsPath]
1708
+ }]
1709
+ });
1710
+ if (!response.result.ok) return response.result.error.message;
1711
+ } catch (error) {
1712
+ return messageOf(error);
1713
+ }
1714
+ await controller.load();
1715
+ }
1716
+ /**
1717
+ * Whether a whole-section provider still needs its first key: an unconfigured
1718
+ * credential opens the setup card instead of showing a row. This is the
1719
+ * first-run posture alone — a user who can already reach some provider gets an
1720
+ * ordinary row with the missing-key dot, since nothing here is blocking them.
1721
+ * @param row - the joined provider row.
1722
+ * @param anyUsable - whether any joined row can already serve requests.
1723
+ * @returns whether to render the setup card.
1724
+ */
1725
+ function needsSetup(row, anyUsable) {
1726
+ if (anyUsable) return false;
1727
+ if (row.entry.settingsPath.length > 0) return false;
1728
+ return row.credential?.configured !== true;
1729
+ }
1730
+ function targetOf(row) {
1731
+ const managedRef = deriveKeyRef(row.entry.provider);
1732
+ const credentialRef = row.apiKeyEnv === managedRef && row.credential?.configured === true && row.credential.writable ? managedRef : void 0;
1733
+ return {
1734
+ provider: row.entry.provider,
1735
+ displayName: row.entry.displayName,
1736
+ settingsNs: row.entry.settingsNs,
1737
+ settingsPath: row.entry.settingsPath,
1738
+ ...credentialRef === void 0 ? {} : { credentialRef },
1739
+ ...row.entry.declared === true ? { declared: true } : {}
1740
+ };
1741
+ }
1742
+ /** Stable visible and accessible identity for one provider target. */
1743
+ function providerTargetLabel(target) {
1744
+ return target.provider === target.displayName ? target.provider : `${target.displayName} (${target.provider})`;
1745
+ }
1746
+ /** Replace the one provider placeholder in localized destructive-action copy. */
1747
+ function providerCopy(template, target) {
1748
+ return template.replace("{provider}", () => providerTargetLabel(target));
1749
+ }
1750
+ /**
1751
+ * Render the Models section content column.
1752
+ * @param props - slot-delivered injected dependencies.
1753
+ * @returns the section, or null while the shell has not injected yet.
1754
+ */
1755
+ function ModelsSection(props) {
1756
+ const { controller, useSnapshot, api, t } = props;
1757
+ if (controller === void 0 || useSnapshot === void 0 || api === void 0 || t === void 0) return null;
1758
+ return (0, react_jsx_runtime.jsx)(Loaded, { injected: {
1759
+ controller,
1760
+ useSnapshot,
1761
+ api,
1762
+ t
1763
+ } });
1764
+ }
1765
+ function Loaded({ injected }) {
1766
+ const { controller, api, t } = injected;
1767
+ const state = injected.useSnapshot((snapshot) => snapshot);
1768
+ const [editing, setEditing] = (0, react.useState)(void 0);
1769
+ const [adding, setAdding] = (0, react.useState)(false);
1770
+ const [deleteTarget, setDeleteTarget] = (0, react.useState)(void 0);
1771
+ const [deleting, setDeleting] = (0, react.useState)(false);
1772
+ const [deleteFailure, setDeleteFailure] = (0, react.useState)(void 0);
1773
+ const [savedTarget, setSavedTarget] = (0, react.useState)(void 0);
1774
+ const [declaring, setDeclaring] = (0, react.useState)(false);
1775
+ const [dismissedSetup, setDismissedSetup] = (0, react.useState)(() => /* @__PURE__ */ new Set());
1776
+ const announceSaved = (target) => {
1777
+ controller.load().then(() => {
1778
+ setSavedTarget(target);
1779
+ });
1780
+ };
1781
+ const closeEditor = (changed, target) => {
1782
+ setEditing(void 0);
1783
+ setAdding(false);
1784
+ setDeclaring(false);
1785
+ if (changed) announceSaved(target);
1786
+ };
1787
+ /**
1788
+ * Close a setup card, which owns none of the state above: the row-editor,
1789
+ * add, and declare cards each own one of those, so clearing them here would
1790
+ * discard a draft the user opened beside this card. Dismissal is this card's
1791
+ * own — the provider falls back to an ordinary row for the rest of the
1792
+ * session, and reopens through Edit.
1793
+ */
1794
+ const closeSetup = (changed, target) => {
1795
+ setDismissedSetup((previous) => new Set([...previous, target.provider]));
1796
+ if (changed) announceSaved(target);
1797
+ };
1798
+ const closeDelete = () => {
1799
+ if (deleting) return;
1800
+ setDeleteTarget(void 0);
1801
+ setDeleteFailure(void 0);
1802
+ };
1803
+ const confirmDelete = () => {
1804
+ /* v8 ignore next -- the action only renders with a target and is disabled while a deletion is pending */
1805
+ if (deleteTarget === void 0 || deleting) return;
1806
+ setDeleting(true);
1807
+ setDeleteFailure(void 0);
1808
+ removeProviderProfile(api, controller, deleteTarget).then((failure) => {
1809
+ if (failure !== void 0) {
1810
+ setDeleteFailure(failure);
1811
+ return;
1812
+ }
1813
+ setDeleteTarget(void 0);
1814
+ }).finally(() => {
1815
+ setDeleting(false);
1816
+ });
1817
+ };
1818
+ if (state.status === "idle") controller.load();
1819
+ if (state.status === "error") {
1820
+ /* v8 ignore next -- an error status always carries text; the fallback satisfies the nullable type */
1821
+ const errorText = state.error ?? "";
1822
+ return (0, react_jsx_runtime.jsxs)("div", {
1823
+ className: ModelsSection_module_css_default["section"],
1824
+ children: [(0, react_jsx_runtime.jsx)("p", {
1825
+ className: ModelsSection_module_css_default["error"],
1826
+ children: `${t("loadFailed")}: ${errorText}`
1827
+ }), (0, react_jsx_runtime.jsx)("button", {
1828
+ type: "button",
1829
+ className: ModelsSection_module_css_default["secondaryButton"],
1830
+ onClick: () => {
1831
+ controller.load();
1832
+ },
1833
+ children: t("retry")
1834
+ })]
1835
+ });
1836
+ }
1837
+ const savedRow = savedTarget === void 0 ? void 0 : state.rows.find((row) => row.entry.provider === savedTarget.provider);
1838
+ const savedIdentity = savedRow === void 0 ? savedTarget : {
1839
+ provider: savedRow.entry.provider,
1840
+ displayName: savedRow.entry.displayName
1841
+ };
1842
+ const anyUsable = state.rows.some(providerUsable);
1843
+ const configured = state.rows.filter((row) => row.configured);
1844
+ const addable = state.rows.filter((row) => !row.configured && row.entry.settingsNs !== "");
1845
+ const addTarget = adding ? editing : void 0;
1846
+ const addNamespace = addTarget === void 0 ? void 0 : state.namespaces.get(addTarget.settingsNs);
1847
+ const protocols = protocolChoices(state.namespaces.get("llm-pi-ai"));
1848
+ return (0, react_jsx_runtime.jsxs)("div", {
1849
+ className: ModelsSection_module_css_default["section"],
1850
+ children: [
1851
+ (0, react_jsx_runtime.jsx)("h2", {
1852
+ className: ModelsSection_module_css_default["title"],
1853
+ children: t("title")
1854
+ }),
1855
+ (0, react_jsx_runtime.jsx)("p", {
1856
+ className: ModelsSection_module_css_default["intro"],
1857
+ children: t("intro")
1858
+ }),
1859
+ !state.writable && state.status === "ready" ? (0, react_jsx_runtime.jsx)("p", {
1860
+ className: ModelsSection_module_css_default["notice"],
1861
+ children: t("readOnly")
1862
+ }) : null,
1863
+ savedIdentity === void 0 ? null : (0, react_jsx_runtime.jsx)("p", {
1864
+ className: ModelsSection_module_css_default["savedNotice"],
1865
+ role: "status",
1866
+ "aria-live": "polite",
1867
+ children: providerCopy(t("savedProvider"), savedIdentity)
1868
+ }),
1869
+ (0, react_jsx_runtime.jsx)("ul", {
1870
+ className: ModelsSection_module_css_default["rows"],
1871
+ children: configured.map((row) => {
1872
+ const target = targetOf(row);
1873
+ const namespace = state.namespaces.get(target.settingsNs);
1874
+ /* v8 ignore next -- the join marks a row configured only when its namespace resolved */
1875
+ if (namespace === void 0) return null;
1876
+ if (needsSetup(row, anyUsable) && !dismissedSetup.has(row.entry.provider)) return (0, react_jsx_runtime.jsx)("li", {
1877
+ className: ModelsSection_module_css_default["setupCard"],
1878
+ children: renderProviderEditor({
1879
+ target,
1880
+ namespace,
1881
+ api,
1882
+ t,
1883
+ readOnly: !state.writable,
1884
+ onClose: (changed) => {
1885
+ closeSetup(changed, target);
1886
+ }
1887
+ })
1888
+ }, row.entry.provider);
1889
+ const open = !adding && editing?.provider === row.entry.provider;
1890
+ const credentialConfigured = row.credential?.configured === true;
1891
+ const credentialMissing = !credentialConfigured && row.apiKeyEnv !== void 0 && row.credential?.configured === false;
1892
+ return (0, react_jsx_runtime.jsxs)("li", {
1893
+ className: ModelsSection_module_css_default["rowCard"],
1894
+ children: [(0, react_jsx_runtime.jsxs)("div", {
1895
+ className: ModelsSection_module_css_default["rowHead"],
1896
+ children: [(0, react_jsx_runtime.jsxs)("span", {
1897
+ className: ModelsSection_module_css_default["rowIdentity"],
1898
+ children: [
1899
+ (0, react_jsx_runtime.jsx)("span", {
1900
+ className: ModelsSection_module_css_default["rowName"],
1901
+ children: row.entry.displayName
1902
+ }),
1903
+ row.entry.declared === true ? (0, react_jsx_runtime.jsx)("span", {
1904
+ className: ModelsSection_module_css_default["rowTag"],
1905
+ children: t("customTag")
1906
+ }) : null,
1907
+ credentialConfigured ? (0, react_jsx_runtime.jsx)("span", {
1908
+ className: `${ModelsSection_module_css_default["credentialDot"]} ${ModelsSection_module_css_default["credentialDotConfigured"]}`,
1909
+ role: "img",
1910
+ "aria-label": t("credentialConfigured"),
1911
+ title: t("credentialConfigured")
1912
+ }) : credentialMissing ? (0, react_jsx_runtime.jsx)("span", {
1913
+ className: `${ModelsSection_module_css_default["credentialDot"]} ${ModelsSection_module_css_default["credentialDotMissing"]}`,
1914
+ role: "img",
1915
+ "aria-label": t("credentialMissing"),
1916
+ title: t("credentialMissing")
1917
+ }) : null
1918
+ ]
1919
+ }), (0, react_jsx_runtime.jsxs)("span", {
1920
+ className: ModelsSection_module_css_default["rowActions"],
1921
+ children: [(0, react_jsx_runtime.jsx)("button", {
1922
+ type: "button",
1923
+ className: ModelsSection_module_css_default["secondaryButton"],
1924
+ "aria-label": providerCopy(t("editProvider"), target),
1925
+ onClick: () => {
1926
+ setSavedTarget(void 0);
1927
+ setDeclaring(false);
1928
+ setAdding(false);
1929
+ setEditing(open ? void 0 : target);
1930
+ },
1931
+ children: t("edit")
1932
+ }), row.removable ? (0, react_jsx_runtime.jsx)("button", {
1933
+ type: "button",
1934
+ className: ModelsSection_module_css_default["dangerButton"],
1935
+ "aria-label": providerCopy(t("removeProvider"), target),
1936
+ disabled: !state.writable,
1937
+ onClick: () => {
1938
+ setSavedTarget(void 0);
1939
+ setDeleteFailure(void 0);
1940
+ setDeleteTarget(target);
1941
+ },
1942
+ children: t("remove")
1943
+ }) : null]
1944
+ })]
1945
+ }), open ? renderProviderEditor({
1946
+ target,
1947
+ namespace,
1948
+ api,
1949
+ t,
1950
+ readOnly: !state.writable,
1951
+ onClose: (changed) => {
1952
+ closeEditor(changed, target);
1953
+ }
1954
+ }) : null]
1955
+ }, row.entry.provider);
1956
+ })
1957
+ }),
1958
+ (0, react_jsx_runtime.jsx)("div", {
1959
+ className: ModelsSection_module_css_default["addBlock"],
1960
+ children: addTarget !== void 0 && addNamespace !== void 0 ? (0, react_jsx_runtime.jsxs)("div", {
1961
+ className: ModelsSection_module_css_default["addCard"],
1962
+ children: [(0, react_jsx_runtime.jsxs)("div", {
1963
+ className: ModelsSection_module_css_default["field"],
1964
+ children: [(0, react_jsx_runtime.jsx)("span", {
1965
+ className: ModelsSection_module_css_default["fieldLabel"],
1966
+ children: t("provider")
1967
+ }), (0, react_jsx_runtime.jsx)("select", {
1968
+ className: `${ModelsSection_module_css_default["input"]} ${ModelsSection_module_css_default["selectInput"]}`,
1969
+ value: addTarget.provider,
1970
+ "aria-label": t("provider"),
1971
+ onChange: (event) => {
1972
+ const row = addable.find((candidate) => candidate.entry.provider === event.target.value);
1973
+ /* v8 ignore next -- the select only lists addable rows */
1974
+ if (row === void 0) return;
1975
+ setEditing(targetOf(row));
1976
+ },
1977
+ children: addable.map((row) => (0, react_jsx_runtime.jsx)("option", {
1978
+ value: row.entry.provider,
1979
+ children: row.entry.displayName
1980
+ }, row.entry.provider))
1981
+ })]
1982
+ }), (0, react_jsx_runtime.jsx)(ProviderEditor, {
1983
+ provider: addTarget.provider,
1984
+ displayName: addTarget.displayName,
1985
+ hideTitle: true,
1986
+ namespace: addNamespace,
1987
+ settingsPath: addTarget.settingsPath,
1988
+ api,
1989
+ t,
1990
+ readOnly: !state.writable,
1991
+ onClose: (changed) => {
1992
+ closeEditor(changed, addTarget);
1993
+ }
1994
+ }, addTarget.provider)]
1995
+ }) : declaring ? (0, react_jsx_runtime.jsx)("div", {
1996
+ className: ModelsSection_module_css_default["addCard"],
1997
+ children: (0, react_jsx_runtime.jsx)(CustomProviderCard, {
1998
+ taken: state.rows.map((row) => row.entry.provider),
1999
+ protocols,
2000
+ /* v8 ignore next -- the card only opens from a button disabled without this namespace */
2001
+ revision: state.namespaces.get("llm-pi-ai")?.revision ?? 0,
2002
+ api,
2003
+ t,
2004
+ readOnly: !state.writable,
2005
+ onClose: (changed) => {
2006
+ setDeclaring(false);
2007
+ if (changed) controller.load();
2008
+ }
2009
+ })
2010
+ }) : (0, react_jsx_runtime.jsxs)("div", {
2011
+ className: ModelsSection_module_css_default["addActions"],
2012
+ children: [(0, react_jsx_runtime.jsxs)("button", {
2013
+ type: "button",
2014
+ className: ModelsSection_module_css_default["addButton"],
2015
+ disabled: addable.length === 0 || !state.writable,
2016
+ onClick: () => {
2017
+ const first = addable[0];
2018
+ /* v8 ignore next -- the button is disabled while nothing is addable */
2019
+ if (first === void 0) return;
2020
+ setSavedTarget(void 0);
2021
+ setDeclaring(false);
2022
+ setAdding(true);
2023
+ setEditing(targetOf(first));
2024
+ },
2025
+ children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 14 }), t("add")]
2026
+ }), (0, react_jsx_runtime.jsxs)("button", {
2027
+ type: "button",
2028
+ className: ModelsSection_module_css_default["addButton"],
2029
+ disabled: protocols.length === 0 || !state.writable,
2030
+ onClick: () => {
2031
+ setSavedTarget(void 0);
2032
+ setAdding(false);
2033
+ setEditing(void 0);
2034
+ setDeclaring(true);
2035
+ },
2036
+ children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 14 }), t("customAdd")]
2037
+ })]
2038
+ })
2039
+ }),
2040
+ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
2041
+ open: deleteTarget !== void 0,
2042
+ onClose: closeDelete,
2043
+ title: deleteTarget === void 0 ? "" : providerCopy(t("deleteTitle"), deleteTarget),
2044
+ closeLabel: t("close"),
2045
+ description: deleteTarget === void 0 ? "" : providerCopy(deleteTarget.credentialRef === void 0 ? t("deleteDescription") : t("deleteDescriptionWithCredential"), deleteTarget),
2046
+ className: ModelsSection_module_css_default["deleteDialog"],
2047
+ footer: (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2048
+ variant: "outline",
2049
+ autoFocus: true,
2050
+ disabled: deleting,
2051
+ onClick: closeDelete,
2052
+ children: t("cancel")
2053
+ }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2054
+ variant: "outline",
2055
+ className: ModelsSection_module_css_default["deleteConfirm"],
2056
+ disabled: deleting,
2057
+ onClick: confirmDelete,
2058
+ children: deleteTarget === void 0 ? "" : providerCopy(deleting ? t("deleting") : t("deleteConfirm"), deleteTarget)
2059
+ })] }),
2060
+ children: deleteFailure === void 0 ? null : (0, react_jsx_runtime.jsx)("p", {
2061
+ className: ModelsSection_module_css_default["error"],
2062
+ children: deleteFailure
2063
+ })
2064
+ })
2065
+ ]
2066
+ });
2067
+ }
2068
+ //#endregion
2069
+ //#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-settings-models/src/client/DeepSeekOnboardingDialog.module.css.mjs
2070
+ const css = ".GL8Viq_page{z-index:1;box-sizing:border-box;width:min(640px,100vw - 64px);max-height:100vh;color:var(--dsw-alias-label-primary);padding:clamp(104px,18vh,156px) 0 40px;position:relative;overflow-y:auto}.GL8Viq_brand{color:var(--dsw-alias-label-primary);align-items:center;margin-bottom:42px;display:flex}.GL8Viq_title{letter-spacing:-.02em;outline:none;margin:0;font-size:28px;font-weight:600;line-height:36px}.GL8Viq_description{color:var(--dsw-alias-label-secondary);margin:16px 0 0;font-size:16px;line-height:28px}.GL8Viq_actions{justify-content:flex-end;align-items:center;gap:12px;margin-top:32px;display:flex}.GL8Viq_primary{min-width:132px}.GL8Viq_brand,.GL8Viq_title,.GL8Viq_description,.GL8Viq_actions{animation:.28s cubic-bezier(.23,1,.32,1) both GL8Viq_credential-enter}.GL8Viq_title{animation-delay:40ms}.GL8Viq_description{animation-delay:80ms}.GL8Viq_actions{animation-delay:.12s}@keyframes GL8Viq_credential-enter{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){.GL8Viq_brand,.GL8Viq_title,.GL8Viq_description,.GL8Viq_actions{animation:none}}@media (width<=560px){.GL8Viq_page{width:calc(100vw - 40px);padding-top:64px}.GL8Viq_brand{margin-bottom:30px}.GL8Viq_actions{flex-direction:column-reverse;align-items:stretch;margin-top:32px}.GL8Viq_primary,.GL8Viq_later{width:100%}}";
2071
+ const tagId = "@deepseek-ai/dsh-client-ui-settings-models/DeepSeekOnboardingDialog.module.css";
2072
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
2073
+ const tag = document.createElement("style");
2074
+ tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-settings-models";
2075
+ tag.dataset.pluginCss = tagId;
2076
+ tag.textContent = css;
2077
+ document.head.appendChild(tag);
2078
+ }
2079
+ var DeepSeekOnboardingDialog_module_css_default = {
2080
+ "credential-enter": "GL8Viq_credential-enter",
2081
+ "actions": "GL8Viq_actions",
2082
+ "primary": "GL8Viq_primary",
2083
+ "page": "GL8Viq_page",
2084
+ "description": "GL8Viq_description",
2085
+ "later": "GL8Viq_later",
2086
+ "title": "GL8Viq_title",
2087
+ "brand": "GL8Viq_brand"
2088
+ };
2089
+ //#endregion
2090
+ //#region lib/types/client/DeepSeekOnboardingDialog.js
2091
+ /**
2092
+ * Official-DeepSeek first-run step. Readiness comes from the same
2093
+ * provider/settings/credential join as the Models page: any provider the user
2094
+ * can already talk to ends the step, and only a user with none is offered the
2095
+ * official DeepSeek route. The prompt itself only routes to that page's single
2096
+ * credential editor.
2097
+ */
2098
+ /* v8 ignore next 3 -- closed-union defaults only defend future source widening */
2099
+ function assertNever(_value) {
2100
+ throw new Error("unexpected DeepSeek onboarding state");
2101
+ }
2102
+ /**
2103
+ * Prompt a first-run user to open Models while no provider can serve requests
2104
+ * and the official adapter exists with an unconfigured effective credential.
2105
+ * @param props - settings-shell owner state and Models feature dependencies.
2106
+ * @returns the onboarding page or null when onboarding needs no intervention.
2107
+ */
2108
+ function DeepSeekOnboardingDialog(props) {
2109
+ const { complete, openSection, controller, useSnapshot, t } = props;
2110
+ const state = useSnapshot((snapshot) => snapshot);
2111
+ const readiness = onboardingReadiness(state);
2112
+ const titleRef = (0, react.useRef)(null);
2113
+ (0, react.useEffect)(() => {
2114
+ if (state.status === "idle") controller.load();
2115
+ }, [controller, state.status]);
2116
+ (0, react.useEffect)(() => {
2117
+ if (readiness.kind === "adapter-absent" || readiness.kind === "provider-ready" || readiness.kind === "unavailable") complete();
2118
+ }, [complete, readiness.kind]);
2119
+ (0, react.useEffect)(() => {
2120
+ if (readiness.kind === "credential-missing") titleRef.current?.focus();
2121
+ }, [readiness.kind]);
2122
+ const openModels = () => {
2123
+ complete();
2124
+ openSection("models");
2125
+ };
2126
+ switch (readiness.kind) {
2127
+ case "loading":
2128
+ case "adapter-absent":
2129
+ case "provider-ready":
2130
+ case "unavailable": return null;
2131
+ case "credential-missing": break;
2132
+ /* v8 ignore next -- every current readiness variant is handled above */
2133
+ default: return assertNever(readiness);
2134
+ }
2135
+ return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.OnboardingSurface, { children: (0, react_jsx_runtime.jsxs)("section", {
2136
+ className: DeepSeekOnboardingDialog_module_css_default["page"],
2137
+ role: "region",
2138
+ "aria-labelledby": "deepseek-onboarding-title",
2139
+ children: [
2140
+ (0, react_jsx_runtime.jsx)("div", {
2141
+ className: DeepSeekOnboardingDialog_module_css_default["brand"],
2142
+ "aria-hidden": "true",
2143
+ children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.BrandWordmark, { size: 24 })
2144
+ }),
2145
+ (0, react_jsx_runtime.jsx)("h2", {
2146
+ ref: titleRef,
2147
+ id: "deepseek-onboarding-title",
2148
+ className: DeepSeekOnboardingDialog_module_css_default["title"],
2149
+ tabIndex: -1,
2150
+ children: t("onboardingTitle")
2151
+ }),
2152
+ (0, react_jsx_runtime.jsx)("p", {
2153
+ className: DeepSeekOnboardingDialog_module_css_default["description"],
2154
+ children: t("onboardingDescription")
2155
+ }),
2156
+ (0, react_jsx_runtime.jsxs)("div", {
2157
+ className: DeepSeekOnboardingDialog_module_css_default["actions"],
2158
+ children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2159
+ variant: "ghost",
2160
+ className: DeepSeekOnboardingDialog_module_css_default["later"],
2161
+ onClick: complete,
2162
+ children: t("onboardingLater")
2163
+ }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2164
+ variant: "primary",
2165
+ className: DeepSeekOnboardingDialog_module_css_default["primary"],
2166
+ onClick: openModels,
2167
+ children: t("onboardingGoToSettings")
2168
+ })]
2169
+ })
2170
+ ]
2171
+ }) });
2172
+ }
2173
+ //#endregion
2174
+ //#region lib/types/client/locales.js
2175
+ /** Copy dictionaries for the Models settings section. */
2176
+ /** English strings (the key-set source of truth for this pair). */
2177
+ const en = {
2178
+ nav: "Models",
2179
+ title: "Models",
2180
+ intro: "Enter your API keys to use models from the following providers.",
2181
+ edit: "Edit",
2182
+ editProvider: "Edit {provider}",
2183
+ remove: "Delete",
2184
+ removeProvider: "Delete {provider}",
2185
+ deleteTitle: "Delete {provider}?",
2186
+ deleteDescription: "Deleting {provider} removes its configuration. Any credential it uses is managed elsewhere and will be kept.",
2187
+ deleteDescriptionWithCredential: "Deleting {provider} removes its configuration and stored API key.",
2188
+ deleteConfirm: "Delete {provider}",
2189
+ deleting: "Deleting {provider}…",
2190
+ add: "Add provider",
2191
+ provider: "Provider",
2192
+ close: "Close",
2193
+ cancel: "Cancel",
2194
+ apply: "Apply",
2195
+ applying: "Applying…",
2196
+ savedProvider: "Saved {provider}.",
2197
+ credentialConfigured: "API key configured",
2198
+ credentialMissing: "API key missing",
2199
+ readOnly: "The settings document is read-only in this deployment.",
2200
+ loadFailed: "Loading the provider directory failed",
2201
+ conflict: "Someone else changed these settings while this card was open. Close it and reopen to edit the current values.",
2202
+ retry: "Retry",
2203
+ keyInput: "API key",
2204
+ keyPlaceholder: "Enter your API key",
2205
+ keyPlaceholderNative: "Enter an API key, or leave blank to use environment authentication",
2206
+ keyStored: "Configured — enter a new value to replace",
2207
+ keyEnvLocked: "Provided by the launch environment (read-only)",
2208
+ customized: "Customized settings",
2209
+ baseUrl: "Base URL",
2210
+ baseUrlDefault: "Provider default",
2211
+ models: "Models",
2212
+ modelsInherited: "Using the adapter defaults",
2213
+ modelsCustomized: "Customized model catalog",
2214
+ resetModels: "Restore defaults",
2215
+ model: "Model",
2216
+ modelId: "Model ID",
2217
+ modelName: "Display name",
2218
+ modelNamePlaceholder: "Uses the model ID when empty",
2219
+ contextWindow: "Context window",
2220
+ contextWindowPlaceholder: "Uses the provider default",
2221
+ maxTokens: "Max output tokens",
2222
+ maxTokensPlaceholder: "Uses the provider default",
2223
+ modelAdvanced: "Capacities",
2224
+ addModel: "Add model",
2225
+ removeModel: "Delete model",
2226
+ modelsEmpty: "No models will be shown in the selector. Unlisted IDs can still be sent directly.",
2227
+ keyBlank: "Enter the API key, or leave the field empty to keep the stored one.",
2228
+ keyBlankNew: "Enter the API key, or leave the field empty if this provider authenticates another way.",
2229
+ keyIllegalCharacters: "This API key is not in a valid format. Please check it.",
2230
+ modelIdRequired: "Model ID is required.",
2231
+ modelIdDuplicate: "Model ID must be unique.",
2232
+ modelNameInvalid: "Display name cannot be empty.",
2233
+ modelContextInvalid: "Context window must be a positive count, like 131072, 256K, or 1M.",
2234
+ modelMaxTokensInvalid: "Max output tokens must be a positive count, like 8192, 64K, or 1M.",
2235
+ advancedHint: "Other fields live in settings.yaml; edit that section directly.",
2236
+ modelCapacityInvalid: "A capacity must be a number, optionally suffixed K or M.",
2237
+ modelDuplicate: "Each model ID may appear once.",
2238
+ modelContextWindow: "Context window",
2239
+ modelMaxTokens: "Max output tokens",
2240
+ fetchModels: "Fetch available models",
2241
+ fetching: "Asking the provider…",
2242
+ fetchNeedsBaseUrl: "Enter the base URL first, then fetch.",
2243
+ fetchEmpty: "The provider listed no models. Add them by hand.",
2244
+ fetchTitle: "Choose models to add",
2245
+ fetchDescription: "These are the models this provider has available. Choose the ones to add.",
2246
+ fetchAdopt: "Add selected",
2247
+ customAdd: "Add a custom provider",
2248
+ customTitle: "Custom provider",
2249
+ customTag: "Custom",
2250
+ customRoute: "Provider ID",
2251
+ customRouteHint: "Lowercase identifier, starting with a letter, that uniquely names this provider in requests and as its credential name.",
2252
+ customRouteInvalid: "Start with a lowercase letter; then lowercase letters, digits, and dashes.",
2253
+ customRouteTaken: "A provider already uses this ID.",
2254
+ customDisplayName: "Display name",
2255
+ customApi: "API protocol",
2256
+ customApiUnset: "Not selected",
2257
+ customNeedsBaseUrl: "A custom provider needs a base URL.",
2258
+ customNeedsModels: "A custom provider needs at least one model.",
2259
+ create: "Create provider",
2260
+ creating: "Creating…",
2261
+ onboardingTitle: "Add an API key to get started",
2262
+ onboardingDescription: "Configure the official DeepSeek provider to start building.",
2263
+ onboardingGoToSettings: "Go to settings",
2264
+ onboardingLater: "Configure later"
2265
+ };
2266
+ /** Chinese strings (same keys as {@link en}). */
2267
+ const zh = {
2268
+ nav: "模型",
2269
+ title: "模型",
2270
+ intro: "填入各提供方的 API 密钥即可使用其模型。",
2271
+ edit: "编辑",
2272
+ editProvider: "编辑 {provider}",
2273
+ remove: "删除",
2274
+ removeProvider: "删除 {provider}",
2275
+ deleteTitle: "删除 {provider}?",
2276
+ deleteDescription: "删除 {provider} 会移除其配置;其使用的凭证(如有)由其他位置管理,将会保留。",
2277
+ deleteDescriptionWithCredential: "删除 {provider} 会移除其配置和存储的 API 密钥。",
2278
+ deleteConfirm: "删除 {provider}",
2279
+ deleting: "正在删除 {provider}…",
2280
+ add: "添加提供方",
2281
+ provider: "提供方",
2282
+ close: "关闭",
2283
+ cancel: "取消",
2284
+ apply: "保存",
2285
+ applying: "保存中…",
2286
+ savedProvider: "已保存 {provider}。",
2287
+ credentialConfigured: "API 密钥已配置",
2288
+ credentialMissing: "API 密钥缺失",
2289
+ readOnly: "当前部署的设置文档为只读。",
2290
+ loadFailed: "加载提供方目录失败",
2291
+ conflict: "这张卡片打开期间,这些设置已被其他地方改动。请关闭后重新打开,在当前值上编辑。",
2292
+ retry: "重试",
2293
+ keyInput: "API 密钥",
2294
+ keyPlaceholder: "输入 API 密钥",
2295
+ keyPlaceholderNative: "输入 API 密钥,或留空使用环境认证",
2296
+ keyStored: "已配置——输入新值可替换",
2297
+ keyEnvLocked: "由启动环境提供(只读)",
2298
+ customized: "自定义设置",
2299
+ baseUrl: "API 地址",
2300
+ baseUrlDefault: "提供方默认",
2301
+ models: "模型目录",
2302
+ modelsInherited: "正在使用适配器默认模型",
2303
+ modelsCustomized: "已自定义模型目录",
2304
+ resetModels: "恢复默认模型",
2305
+ model: "模型",
2306
+ modelId: "模型 ID",
2307
+ modelName: "显示名称",
2308
+ modelNamePlaceholder: "留空时使用模型 ID",
2309
+ contextWindow: "上下文窗口",
2310
+ contextWindowPlaceholder: "使用提供方默认值",
2311
+ maxTokens: "最大输出 token 数",
2312
+ maxTokensPlaceholder: "使用提供方默认值",
2313
+ modelAdvanced: "容量",
2314
+ addModel: "添加模型",
2315
+ removeModel: "删除模型",
2316
+ modelsEmpty: "模型选择器中将不显示任何模型;目录外 ID 仍可直接发送。",
2317
+ keyBlank: "请输入 API 密钥;留空则保持已存储的密钥。",
2318
+ keyBlankNew: "请输入 API 密钥;若该提供方以其他方式鉴权,可以留空。",
2319
+ keyIllegalCharacters: "该 API 密钥格式错误,请检查。",
2320
+ modelIdRequired: "模型 ID 不能为空。",
2321
+ modelIdDuplicate: "模型 ID 不能重复。",
2322
+ modelNameInvalid: "显示名称不能为空。",
2323
+ modelContextInvalid: "上下文窗口必须是正数,例如 131072、256K 或 1M。",
2324
+ modelMaxTokensInvalid: "最大输出 token 数必须是正数,例如 8192、64K 或 1M。",
2325
+ advancedHint: "其余字段在 settings.yaml 中,请直接编辑对应段。",
2326
+ modelCapacityInvalid: "容量需为数字,可加 K 或 M 后缀。",
2327
+ modelDuplicate: "每个模型 ID 只能出现一次。",
2328
+ modelContextWindow: "上下文窗口",
2329
+ modelMaxTokens: "最大输出 token",
2330
+ fetchModels: "获取可用模型",
2331
+ fetching: "正在询问提供方…",
2332
+ fetchNeedsBaseUrl: "请先填写 API 地址,再获取。",
2333
+ fetchEmpty: "该提供方没有列出任何模型,请手动添加。",
2334
+ fetchTitle: "选择要添加的模型",
2335
+ fetchDescription: "以下是模型提供方的可用模型,勾选要添加的模型。",
2336
+ fetchAdopt: "添加所选",
2337
+ customAdd: "添加自定义提供方",
2338
+ customTitle: "自定义提供方",
2339
+ customTag: "自定义",
2340
+ customRoute: "Provider ID",
2341
+ customRouteHint: "以小写字母开头的标识,在请求中唯一标识该提供方,并用于派生凭据名。",
2342
+ customRouteInvalid: "需以小写字母开头,之后可用小写字母、数字和短横线。",
2343
+ customRouteTaken: "已有提供方使用了这个 ID。",
2344
+ customDisplayName: "显示名称",
2345
+ customApi: "API 协议",
2346
+ customApiUnset: "未选择",
2347
+ customNeedsBaseUrl: "自定义提供方需要填写 API 地址。",
2348
+ customNeedsModels: "自定义提供方至少需要一个模型。",
2349
+ create: "创建提供方",
2350
+ creating: "创建中…",
2351
+ onboardingTitle: "添加一个 API Key 开始使用",
2352
+ onboardingDescription: "配置 DeepSeek 官方模型,即可开始使用。",
2353
+ onboardingGoToSettings: "前往配置",
2354
+ onboardingLater: "稍后配置"
2355
+ };
2356
+ //#endregion
2357
+ //#region lib/types/client/index.js
2358
+ /** Dictionary namespace owned by this plugin. */
2359
+ const NS = "settings.models";
2360
+ /**
2361
+ * Refetch the page snapshot only after its first load: an unopened Models
2362
+ * page must not fetch on background invalidations.
2363
+ * @param controller - the page store.
2364
+ */
2365
+ function refreshIfLoaded(controller) {
2366
+ if (controller.store.getSnapshot().status === "idle") return;
2367
+ controller.load();
2368
+ }
2369
+ /**
2370
+ * Required services (cordis fiber inject). The target slot is declared by
2371
+ * ui-settings' apply, whose activation order relative to this one is NOT
2372
+ * constrained; registration depends on each slot through `slots.inject()`.
2373
+ */
2374
+ const inject = [
2375
+ "slots",
2376
+ "locale",
2377
+ "connection",
2378
+ "remote"
2379
+ ];
2380
+ /**
2381
+ * Register the Models section once the `settings.section` declaration is on
2382
+ * the ledger, wire its store to the connection, and keep it fresh on every
2383
+ * pushed invalidation (settings, credentials, or provider topology).
2384
+ * @param ctx - client root context.
2385
+ */
2386
+ function apply(ctx) {
2387
+ ctx.effect(() => ctx.locale.register(NS, {
2388
+ zh,
2389
+ en
2390
+ }), "ui-settings-models: copy dictionaries");
2391
+ const connection = ctx.get("connection");
2392
+ const controller = new ModelsSettingsStore(connection.api);
2393
+ const useSnapshot = (0, _deepseek_ai_dsh_client_web_react.bindSnapshotSelector)(controller.store);
2394
+ const t = ctx.locale.bind(NS);
2395
+ const injected = () => ({
2396
+ controller,
2397
+ useSnapshot,
2398
+ api: connection.api,
2399
+ t
2400
+ });
2401
+ const onboardingInjected = () => ({
2402
+ controller,
2403
+ useSnapshot,
2404
+ t
2405
+ });
2406
+ ctx.effect(() => {
2407
+ const refresh = () => {
2408
+ refreshIfLoaded(controller);
2409
+ };
2410
+ const disposers = [
2411
+ ctx.remote.$on("settings/document-updated", refresh),
2412
+ ctx.remote.$on("credentials/updated", refresh),
2413
+ ctx.remote.$on("llm/adapters-updated", refresh),
2414
+ ctx.on("connection/reset", refresh)
2415
+ ];
2416
+ return () => {
2417
+ for (const dispose of disposers) dispose();
2418
+ };
2419
+ }, "ui-settings-models: pushed invalidations");
2420
+ ctx.slots.inject("settings.section", () => ctx.slots.register({
2421
+ name: "settings.section",
2422
+ id: "models",
2423
+ order: 10,
2424
+ label: () => t("nav"),
2425
+ inject: injected
2426
+ }, ModelsSection));
2427
+ ctx.slots.inject("settings.onboarding", () => ctx.slots.register({
2428
+ name: "settings.onboarding",
2429
+ id: "deepseek-official",
2430
+ order: 0,
2431
+ inject: onboardingInjected
2432
+ }, DeepSeekOnboardingDialog));
2433
+ }
2434
+ //#endregion
2435
+ exports.apply = apply;
2436
+ exports.inject = inject;
2437
+ exports.refreshIfLoaded = refreshIfLoaded;
2438
+ return module.exports;
2439
+ }
2440
+ });
2441
+
2442
+ //# sourceMappingURL=client.js.map