@prettier-ai/dsh-client-ui-settings-models 0.1.2-alpha.1

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