dsh-edge 0.3.0 → 0.4.0-alpha.2

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