@qilin-agent/client-ui-settings-models 0.0.0-stage → 3.1.4

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