dsh-opendesign-corouter 0.1.16 → 0.1.18

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.
@@ -1,6 +1,6 @@
1
1
  # 第三方代码与资料
2
2
 
3
- 本项目的消息/图片兼容处理、套餐模型元数据参考 [dsh-opendesign-go 0.1.9](https://github.com/EliteOtaku/dsh-opendesign-go)。额度归一化及登录生命周期的基础处理改编自 [dsh-subusage 0.16.2](https://github.com/KouzakiUmi/dsh-subusage);临时授权窗口的 Chrome 启动策略改编自 [dsh-subusage 0.16.3](https://github.com/KouzakiUmi/dsh-subusage) 的 `lib/cookie-login.js`。空轮判定参考 [dsh-empty-turn-guard 0.4.0](https://github.com/FYTXY/dsh-empty-turn-guard)。设置布局参考 [dsh-code-pill](https://github.com/KouzakiUmi/dsh-code-pill)。
3
+ 本项目的消息/图片兼容处理、套餐模型元数据、思考增量拼写兼容与配置写入的重试策略参考 [dsh-opendesign-go 0.1.11](https://github.com/EliteOtaku/dsh-opendesign-go)。额度归一化及登录生命周期的基础处理改编自 [dsh-subusage 0.16.2](https://github.com/KouzakiUmi/dsh-subusage);临时授权窗口的 Chrome 启动策略改编自 [dsh-subusage 0.16.3](https://github.com/KouzakiUmi/dsh-subusage) 的 `lib/cookie-login.js`。空轮判定参考 [dsh-empty-turn-guard 0.4.0](https://github.com/FYTXY/dsh-empty-turn-guard)。设置布局参考 [dsh-code-pill](https://github.com/KouzakiUmi/dsh-code-pill)。
4
4
 
5
5
  离线主题夹具使用 [DeepSeek Harness 官方主题令牌](https://github.com/deepseek-ai/deepseek-harness/blob/22ddee3792402c3e70ec5f86a63c3e3e895a2f60/packages/client/ui-theme/src/styles/design-platform.css),仅供测试,不随插件安装包分发。
6
6
 
@@ -8,7 +8,8 @@
8
8
  *
9
9
  * The coordinator talks to the Host configuration form only: it projects the value a caller
10
10
  * wants to save, hands the write to the form, and hands the value back to the form snapshot once
11
- * the write is done.
11
+ * the write is done. A clear travels the same queue but asks the form to drop the field, because
12
+ * an empty value and an unnamed field are different states for the Host.
12
13
  */
13
14
  import type { ConfigForm, FormValues } from './client.js';
14
15
  export interface ConfigWriteSnapshot {
@@ -29,6 +30,13 @@ export interface ConfigWrites {
29
30
  * already has a pending write, or when the Host rejects the write.
30
31
  */
31
32
  set(field: string, value: unknown, baseValue?: unknown): Promise<boolean>;
33
+ /**
34
+ * Queue one field clear.
35
+ *
36
+ * A cleared field goes back to being unnamed: the Host drops it from the profile instead of
37
+ * storing an empty value. Returns false when the Host offers no clear path.
38
+ */
39
+ clear(field: string): Promise<boolean>;
32
40
  /** Stop the coordinator: queued writes never start and subscribers are released. */
33
41
  dispose(): void;
34
42
  }
package/lib/client.d.ts CHANGED
@@ -7,6 +7,8 @@ import { type ApiProtocol } from './protocol-options.js';
7
7
  import type { ModelSettings, ModelSettingsMap } from './model-settings.js';
8
8
  import { type ContextWindowPresetId } from './context-budget.js';
9
9
  import { type ModelDirectoryService } from './client-context-quick.js';
10
+ /** Must match `DEFAULT_API_KEY_REF` in src/config.ts; the browser bundle keeps its own copy. */
11
+ export declare const DEFAULT_KEY_REF = "COROUTER_API_KEY";
10
12
  declare const TABS: readonly [{
11
13
  readonly id: "overview";
12
14
  readonly label: "概览";
@@ -46,6 +48,8 @@ export interface ConfigForm {
46
48
  getSnapshot(): FormSnapshot;
47
49
  subscribe(listener: () => void): () => void;
48
50
  set(field: string, value: unknown): Promise<boolean>;
51
+ /** Drop one field back to unnamed; absent on a Host that only writes values. */
52
+ unset?(field: string): Promise<boolean>;
49
53
  }
50
54
  export interface ConfigForms {
51
55
  get(namespace: string): ConfigForm;
@@ -237,9 +241,10 @@ export interface AdvancedProps {
237
241
  status: Status | undefined;
238
242
  formSnapshot: FormSnapshot;
239
243
  setFormField: (field: string, value: unknown) => Promise<boolean>;
244
+ clearFormField: (field: string) => Promise<boolean>;
240
245
  pendingField: readonly string[];
241
246
  }
242
- export declare function Advanced({ status, formSnapshot, setFormField, pendingField }: AdvancedProps): React.FunctionComponentElement<{
247
+ export declare function Advanced({ status, formSnapshot, setFormField, clearFormField, pendingField }: AdvancedProps): React.FunctionComponentElement<{
243
248
  children?: React.ReactNode | undefined;
244
249
  }>;
245
250
  /** Approval is an ordinary official link; the Host may also show it in a temporary window. */
package/lib/client.js CHANGED
@@ -32,6 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  var client_exports = {};
33
33
  __export(client_exports, {
34
34
  Advanced: () => Advanced,
35
+ DEFAULT_KEY_REF: () => DEFAULT_KEY_REF,
35
36
  LoginApproval: () => LoginApproval,
36
37
  ModelRow: () => ModelRow,
37
38
  Models: () => Models,
@@ -20238,8 +20239,11 @@ function parseStatusModel(value) {
20238
20239
  }
20239
20240
  function parseStatusConfig(value) {
20240
20241
  if (!record2(value)) throw new Error("\u914D\u7F6E\u89C6\u56FE\u5FC5\u987B\u662F\u5BF9\u8C61");
20241
- const apiKeyEnv = text(value.apiKeyEnv, "\u51ED\u636E\u5F15\u7528\u540D", MAX_ENV_REF);
20242
- if (!ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
20242
+ if (typeof value.apiKeyEnv !== "string" || value.apiKeyEnv.length > MAX_ENV_REF) {
20243
+ throw new Error(`\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u6700\u591A ${MAX_ENV_REF} \u5B57\u7B26\u7684\u5B57\u7B26\u4E32`);
20244
+ }
20245
+ const apiKeyEnv = value.apiKeyEnv;
20246
+ if (apiKeyEnv !== "" && !ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
20243
20247
  return {
20244
20248
  emptyTurnGuard: flag(value.emptyTurnGuard, "\u7A7A\u8F6E\u4FDD\u62A4\u5F00\u5173"),
20245
20249
  ...value.turnCompletionReview === void 0 ? {} : { turnCompletionReview: flag(value.turnCompletionReview, "\u7ED3\u675F\u56DE\u5408\u6838\u9A8C\u5F00\u5173") },
@@ -20415,18 +20419,24 @@ var ConfigWritesImpl = class {
20415
20419
  };
20416
20420
  }
20417
20421
  async set(field, value, baseValue) {
20422
+ return this.enqueue(field, value, baseValue, false);
20423
+ }
20424
+ async clear(field) {
20425
+ return this.enqueue(field, void 0, void 0, true);
20426
+ }
20427
+ async enqueue(field, value, baseValue, clear) {
20418
20428
  if (this.disposed) return false;
20419
20429
  const current = this.form.getSnapshot();
20420
20430
  if (!writableSnapshot(current)) return false;
20421
20431
  if (this.inflight.has(field)) return false;
20422
20432
  const baseline = baseValue !== void 0 ? baseValue : readField(current.value, field);
20423
- const task = { field, value, baseline, resolve: () => {
20433
+ const task = { field, value, baseline, clear, resolve: () => {
20424
20434
  } };
20425
20435
  const accepted = new Promise((resolve) => {
20426
20436
  task.resolve = resolve;
20427
20437
  });
20428
20438
  this.inflight.set(field, task);
20429
- this.overlay.set(field, value);
20439
+ if (!clear) this.overlay.set(field, value);
20430
20440
  this.publish();
20431
20441
  this.queue.push(task);
20432
20442
  this.drain();
@@ -20469,6 +20479,15 @@ var ConfigWritesImpl = class {
20469
20479
  if (this.disposed) return false;
20470
20480
  const current = this.form.getSnapshot();
20471
20481
  if (!writableSnapshot(current)) return false;
20482
+ if (task.clear) {
20483
+ const unset = this.form.unset;
20484
+ if (unset === void 0) return false;
20485
+ try {
20486
+ return await unset.call(this.form, task.field) === true;
20487
+ } catch {
20488
+ return false;
20489
+ }
20490
+ }
20472
20491
  let payload = task.value;
20473
20492
  if (task.field === "modelSettings") {
20474
20493
  const rebased = rebaseModelSettings(task.baseline, task.value, readField(current.value, "modelSettings"));
@@ -20821,6 +20840,7 @@ function ContextQuickControl({ provider, modelId, selecting, directoryUnavailabl
20821
20840
  // src/client.ts
20822
20841
  var h2 = React2.createElement;
20823
20842
  var SETTINGS_NS = "llm-opendesign-corouter";
20843
+ var DEFAULT_KEY_REF = "COROUTER_API_KEY";
20824
20844
  var OFFICIAL_SITE = "https://corouter.open-design.ai/zh/";
20825
20845
  var TABS = [
20826
20846
  { id: "overview", label: "\u6982\u89C8" },
@@ -22082,13 +22102,14 @@ function NumberField({ id, label, hint, value, min, max, integer: integer2, disa
22082
22102
  }, error62 ?? hint)
22083
22103
  );
22084
22104
  }
22085
- function Advanced({ status, formSnapshot, setFormField, pendingField }) {
22105
+ function Advanced({ status, formSnapshot, setFormField, clearFormField, pendingField }) {
22086
22106
  const [apiKeyEnv, setApiKeyEnv] = React2.useState(status?.config.apiKeyEnv ?? "");
22087
22107
  const [keyNotice, setKeyNotice] = React2.useState(null);
22088
22108
  const mounted = useMounted();
22109
+ const formReady = formSnapshot.status === "ready" && formSnapshot.value !== void 0;
22089
22110
  React2.useEffect(() => {
22090
- setApiKeyEnv(formSnapshot.value?.apiKeyEnv ?? status?.config.apiKeyEnv ?? "");
22091
- }, [formSnapshot.value?.apiKeyEnv, status?.config.apiKeyEnv]);
22111
+ setApiKeyEnv(formReady ? formSnapshot.value?.apiKeyEnv ?? "" : status?.config.apiKeyEnv ?? "");
22112
+ }, [formReady, formSnapshot.value?.apiKeyEnv, status?.config.apiKeyEnv]);
22092
22113
  const writable = formSnapshot.status === "ready" && formSnapshot.value !== void 0 && formSnapshot.writable;
22093
22114
  const configuredProtocol = formSnapshot.value?.apiProtocol ?? status?.config.apiProtocol;
22094
22115
  const protocol = configuredProtocol !== void 0 && API_PROTOCOL_OPTIONS.some((option) => option.id === configuredProtocol) ? configuredProtocol : "chat-completions";
@@ -22104,6 +22125,30 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
22104
22125
  const selected = API_PROTOCOL_OPTIONS.find((option) => option.id === protocol);
22105
22126
  const saveKeyRef = async () => {
22106
22127
  const value = apiKeyEnv.trim();
22128
+ if (value === "") {
22129
+ const saved = formReady ? formSnapshot.value?.apiKeyEnv : void 0;
22130
+ if (saved === void 0) {
22131
+ setKeyNotice({ kind: "status", text: `\u5F53\u524D\u672A\u586B\u5199\u5F15\u7528\u540D\uFF1B\u8BF7\u6C42\u6CBF\u7528\u9ED8\u8BA4\u5F15\u7528 ${DEFAULT_KEY_REF}\uFF0C\u65E0\u9700\u4FDD\u5B58\u3002` });
22132
+ return;
22133
+ }
22134
+ setKeyNotice(null);
22135
+ try {
22136
+ const cleared = await clearFormField("apiKeyEnv");
22137
+ if (mounted.current) {
22138
+ if (cleared) setKeyNotice({ kind: "status", text: `\u5DF2\u6E05\u9664\u5F15\u7528\u540D\uFF1B\u8BF7\u6C42\u6CBF\u7528\u9ED8\u8BA4\u5F15\u7528 ${DEFAULT_KEY_REF}\u3002` });
22139
+ else {
22140
+ setApiKeyEnv(saved);
22141
+ setKeyNotice({ kind: "error", text: "\u5F15\u7528\u540D\u672A\u6E05\u9664\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\uFF0C\u8BF7\u91CD\u8BD5\u3002" });
22142
+ }
22143
+ }
22144
+ } catch {
22145
+ if (mounted.current) {
22146
+ setApiKeyEnv(saved);
22147
+ setKeyNotice({ kind: "error", text: GENERIC_ERROR });
22148
+ }
22149
+ }
22150
+ return;
22151
+ }
22107
22152
  if (!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/u.test(value)) {
22108
22153
  setKeyNotice({ kind: "error", text: "\u5F15\u7528\u540D\u9700\u4E3A 1\u2013128 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u4E0B\u5212\u7EBF\uFF0C\u4E14\u4E0D\u80FD\u4EE5\u6570\u5B57\u5F00\u5934\u3002" });
22109
22154
  return;
@@ -22208,7 +22253,7 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
22208
22253
  "section",
22209
22254
  { className: "odc-card" },
22210
22255
  h2("h3", null, "\u51ED\u636E\u4E0E\u7F51\u5173"),
22211
- h2("p", { className: "odc-hint" }, "\u8FD9\u91CC\u53EA\u4FDD\u5B58\u51ED\u636E\u5F15\u7528\u540D\u79F0\uFF0C\u4E0D\u586B\u5199 Key \u672C\u8EAB\uFF1B\u7F51\u5173\u5730\u5740\u7531\u63D2\u4EF6\u914D\u7F6E\u6258\u7BA1\u3002"),
22256
+ h2("p", { className: "odc-hint" }, `\u8FD9\u91CC\u53EA\u4FDD\u5B58\u51ED\u636E\u5F15\u7528\u540D\u79F0\uFF0C\u4E0D\u586B\u5199 Key \u672C\u8EAB\uFF1B\u7F51\u5173\u5730\u5740\u7531\u63D2\u4EF6\u914D\u7F6E\u6258\u7BA1\u3002\u5F15\u7528\u540D\u7559\u7A7A\u65F6\u8BF7\u6C42\u6CBF\u7528 ${DEFAULT_KEY_REF}\uFF0C\u4FDD\u5B58\u7A7A\u503C\u5373\u6E05\u9664\u5DF2\u4FDD\u5B58\u7684\u5F15\u7528\u540D\u3002`),
22212
22257
  h2(
22213
22258
  "div",
22214
22259
  { className: "odc-field" },
@@ -22218,12 +22263,13 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
22218
22263
  className: "odc-input",
22219
22264
  type: "text",
22220
22265
  value: apiKeyEnv,
22266
+ placeholder: DEFAULT_KEY_REF,
22221
22267
  disabled: !writable || pendingField.includes("apiKeyEnv"),
22222
22268
  autoCapitalize: "off",
22223
22269
  spellCheck: false,
22224
22270
  onChange: (event) => setApiKeyEnv(event.target.value)
22225
22271
  }),
22226
- h2("small", { className: "odc-hint" }, "\u5F15\u7528\u540D\u5BF9\u5E94\u7684\u51ED\u636E\u4ECD\u4F18\u5148\u4E8E\u672C\u63D2\u4EF6\u4FDD\u5B58\u7684 Key\u3002")
22272
+ h2("small", { className: "odc-hint" }, "\u5F15\u7528\u540D\u5BF9\u5E94\u7684\u51ED\u636E\u4ECD\u4F18\u5148\u4E8E\u672C\u63D2\u4EF6\u4FDD\u5B58\u7684 Key\uFF1BDSH \u6A21\u578B\u9875\u53EA\u62A5\u544A\u8FD9\u91CC\u8BBE\u7F6E\u7684\u5F15\u7528\u540D\uFF0C\u4E0D\u663E\u793A\u672C\u63D2\u4EF6\u4FDD\u5B58\u7684 Key \u4E0E\u8BBE\u5907\u767B\u5F55\u3002")
22227
22273
  ),
22228
22274
  h2(
22229
22275
  "div",
@@ -22441,7 +22487,7 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
22441
22487
  if (!mounted.current || version2 !== actionVersion.current) return;
22442
22488
  setApiKey("");
22443
22489
  onStatus(next);
22444
- setNotice({ kind: "status", text: next.apiKeySource === "reference" ? `API Key \u5DF2\u4FDD\u5B58\uFF1B\u5F53\u524D\u4ECD\u4F18\u5148\u4F7F\u7528\u73AF\u5883\u6216\u51ED\u636E\u5F15\u7528 ${next.config.apiKeyEnv}\u3002` : next.apiKeySource === "stored" ? "API Key \u5DF2\u4FDD\u5B58\u5E76\u7528\u4E8E\u5F53\u524D\u7F51\u5173\u3002" : "API Key \u5DF2\u4FDD\u5B58\u3002" });
22490
+ setNotice({ kind: "status", text: next.apiKeySource === "reference" ? `API Key \u5DF2\u4FDD\u5B58\uFF1B\u5F53\u524D\u4ECD\u4F18\u5148\u4F7F\u7528\u73AF\u5883\u6216\u51ED\u636E\u5F15\u7528 ${next.config.apiKeyEnv || DEFAULT_KEY_REF}\u3002` : next.apiKeySource === "stored" ? "API Key \u5DF2\u4FDD\u5B58\u5E76\u7528\u4E8E\u5F53\u524D\u7F51\u5173\u3002" : "API Key \u5DF2\u4FDD\u5B58\u3002" });
22445
22491
  } catch {
22446
22492
  if (!mounted.current || version2 !== actionVersion.current) return;
22447
22493
  setApiKey("");
@@ -22477,7 +22523,7 @@ function Connection({ status, formSnapshot, setFormField, pendingField, caller,
22477
22523
  }
22478
22524
  }, [state, login?.jobId, busy, keyBusy, opening, status]);
22479
22525
  const desktopChecked = formSnapshot.value?.useDesktopCredential ?? status?.config.useDesktopCredential ?? true;
22480
- const keySource = status?.apiKeySource === "reference" ? `\u73AF\u5883\u6216\u51ED\u636E\u5F15\u7528\uFF08${status.config.apiKeyEnv}\uFF09` : status?.apiKeySource === "stored" ? "\u5DF2\u4FDD\u5B58\u7684 API Key" : status?.apiKeySource === "device" ? "\u8BBE\u5907\u6388\u6743" : status?.apiKeyConfigured ? "\u5C1A\u672A\u786E\u8BA4" : "\u672A\u914D\u7F6E";
22526
+ const keySource = status?.apiKeySource === "reference" ? `\u73AF\u5883\u6216\u51ED\u636E\u5F15\u7528\uFF08${status.config.apiKeyEnv || DEFAULT_KEY_REF}\uFF09` : status?.apiKeySource === "stored" ? "\u5DF2\u4FDD\u5B58\u7684 API Key" : status?.apiKeySource === "device" ? "\u8BBE\u5907\u6388\u6743" : status?.apiKeyConfigured ? "\u5C1A\u672A\u786E\u8BA4" : "\u672A\u914D\u7F6E";
22481
22527
  return h2(
22482
22528
  React2.Fragment,
22483
22529
  null,
@@ -22697,6 +22743,27 @@ function SettingsPage({ caller, form }) {
22697
22743
  }
22698
22744
  }
22699
22745
  }, [form, mounted, refresh, writes]);
22746
+ const clearFormField = React2.useCallback(async (field) => {
22747
+ const snapshot = form.getSnapshot();
22748
+ if (snapshot.status !== "ready" || snapshot.value === void 0 || !snapshot.writable || writes.getSnapshot().pendingFields.includes(field)) return false;
22749
+ if (writes.getSnapshot().pendingFields.length === 0) batchWriteFailed.current = false;
22750
+ pageBatchActive.current = true;
22751
+ setFormNotice({ kind: "status", text: "\u6B63\u5728\u4FDD\u5B58\u8BBE\u7F6E\u2026" });
22752
+ try {
22753
+ const accepted = await writes.clear(field);
22754
+ if (!accepted) batchWriteFailed.current = true;
22755
+ if (accepted && mounted.current) void loadStatus();
22756
+ return accepted;
22757
+ } catch {
22758
+ batchWriteFailed.current = true;
22759
+ return false;
22760
+ } finally {
22761
+ if (mounted.current && writes.getSnapshot().pendingFields.length === 0) {
22762
+ pageBatchActive.current = false;
22763
+ setFormNotice(batchWriteFailed.current ? { kind: "error", text: "\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u5DF2\u6062\u590D\u539F\u503C\uFF0C\u8BF7\u91CD\u8BD5\u3002" } : { kind: "status", text: "\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002" });
22764
+ }
22765
+ }
22766
+ }, [form, mounted, writes, loadStatus]);
22700
22767
  const refreshModelsBusy = React2.useRef(false);
22701
22768
  const refreshModels = React2.useCallback(async () => {
22702
22769
  if (refreshModelsBusy.current) return;
@@ -22820,7 +22887,7 @@ function SettingsPage({ caller, form }) {
22820
22887
  } else if (tab === "connection") {
22821
22888
  content = h2(Connection, { status, formSnapshot, setFormField, pendingField, caller, onLoginStatus: acceptLoginStatus, onStatus: acceptStatus });
22822
22889
  } else {
22823
- content = h2(Advanced, { status, formSnapshot, setFormField, pendingField });
22890
+ content = h2(Advanced, { status, formSnapshot, setFormField, clearFormField, pendingField });
22824
22891
  }
22825
22892
  return h2(
22826
22893
  "div",
package/lib/config.d.ts CHANGED
@@ -1,16 +1,27 @@
1
1
  import Schema from '@deepseek-ai/schemastery';
2
2
  import { type ApiProtocol } from './protocol-options.js';
3
3
  import { type ModelSettingsMap } from './model-settings.js';
4
+ import { type ModelCatalogSnapshot } from './model-catalog-snapshot.js';
4
5
  export { DEFAULT_MAX_REQUEST_IMAGE_BYTES } from './image-budget.js';
5
6
  export declare const SETTINGS_NS = "llm-opendesign-corouter";
6
7
  export declare const PLAN_PROVIDER = "opendesign-corouter-plan";
7
8
  export declare const PAID_PROVIDER = "opendesign-corouter-paid";
8
9
  export declare const DEFAULT_BASE_URL = "https://amr-link.open-design.ai/v1";
10
+ /**
11
+ * Reference resolved when no profile names one.
12
+ *
13
+ * The Host's model page reads a *named* reference out of this namespace and reports it as
14
+ * missing whenever that reference holds nothing, so an unset owner must stay unset: a schema
15
+ * default would claim the reference on every install and make the native page warn about a key
16
+ * the plugin never asked for. The plugin keeps using this default internally.
17
+ */
18
+ export declare const DEFAULT_API_KEY_REF = "COROUTER_API_KEY";
9
19
  export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
10
- apiKeyEnv: Schema<string, string, "volatile-defined">;
20
+ apiKeyEnv: Schema<string, string, "volatile">;
11
21
  baseURL: Schema<string, string, "volatile-defined">;
12
22
  apiProtocol: Schema<"chat-completions" | "responses" | "messages", "chat-completions" | "responses" | "messages", "volatile-defined">;
13
23
  modelSettings: Schema<NoInfer<import("@deepseek-ai/cosmokit").Dict<unknown, string>>, NoInfer<ModelSettingsMap>, "volatile-defined">;
24
+ modelCatalog: Schema<unknown, NoInfer<ModelCatalogSnapshot | undefined>, "volatile">;
14
25
  useDesktopCredential: Schema<boolean, boolean, "volatile-defined">;
15
26
  emptyTurnGuard: Schema<boolean, boolean, "volatile-defined">;
16
27
  turnCompletionReview: Schema<boolean, boolean, "volatile-defined">;
@@ -21,10 +32,11 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
21
32
  streamIdleTimeoutMs: Schema<number, number, "volatile-defined">;
22
33
  maxRequestImageBytes: Schema<number, number, "volatile-defined">;
23
34
  }>>, Schemastery.ObjectT<NoInfer<{
24
- apiKeyEnv: Schema<string, string, "volatile-defined">;
35
+ apiKeyEnv: Schema<string, string, "volatile">;
25
36
  baseURL: Schema<string, string, "volatile-defined">;
26
37
  apiProtocol: Schema<"chat-completions" | "responses" | "messages", "chat-completions" | "responses" | "messages", "volatile-defined">;
27
38
  modelSettings: Schema<NoInfer<import("@deepseek-ai/cosmokit").Dict<unknown, string>>, NoInfer<ModelSettingsMap>, "volatile-defined">;
39
+ modelCatalog: Schema<unknown, NoInfer<ModelCatalogSnapshot | undefined>, "volatile">;
28
40
  useDesktopCredential: Schema<boolean, boolean, "volatile-defined">;
29
41
  emptyTurnGuard: Schema<boolean, boolean, "volatile-defined">;
30
42
  turnCompletionReview: Schema<boolean, boolean, "volatile-defined">;
@@ -37,7 +49,8 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
37
49
  }>>, "plain">;
38
50
  export type LiveConfig = ReturnType<typeof Config>;
39
51
  export interface RuntimeConfig {
40
- apiKeyEnv: string;
52
+ /** Credential reference this profile names; absent when the profile names none. */
53
+ apiKeyEnv?: string;
41
54
  baseURL: string;
42
55
  useDesktopCredential: boolean;
43
56
  emptyTurnGuard: boolean;
@@ -45,6 +58,7 @@ export interface RuntimeConfig {
45
58
  streamIdleTimeoutMs: number;
46
59
  apiProtocol?: ApiProtocol;
47
60
  modelSettings?: ModelSettingsMap;
61
+ modelCatalog?: ModelCatalogSnapshot;
48
62
  quotaRefreshSeconds?: number;
49
63
  maxRequestImageBytes?: number;
50
64
  turnCompletionReview?: boolean;
@@ -52,4 +66,11 @@ export interface RuntimeConfig {
52
66
  turnReviewNoProgressLimit?: number;
53
67
  }
54
68
  export declare function assertBaseURL(raw: string): string;
69
+ /**
70
+ * The reference requests resolve when the profile names none; the profile itself stays unnamed.
71
+ *
72
+ * No default and no inherited value: a patch that leaves this field out keeps the profile
73
+ * unnamed, which is also what lets the settings page clear it instead of writing a name back.
74
+ */
75
+ export declare function apiKeyRef(config: RuntimeConfig): string;
55
76
  export declare function readConfig(config: LiveConfig): RuntimeConfig;
@@ -3,7 +3,7 @@ export interface DeviceTokens {
3
3
  runtimeKey: string;
4
4
  }
5
5
  export declare const DEVICE_AUTH_ENDPOINT = "https://amr-api.open-design.ai/api/v1/cli/device-authorizations";
6
- export declare const DEVICE_AUTH_PLUGIN_VERSION = "0.1.16";
6
+ export declare const DEVICE_AUTH_PLUGIN_VERSION = "0.1.18";
7
7
  export declare const DEVICE_REQUEST_TIMEOUT_MS = 20000;
8
8
  /** One bounded launch step of the temporary activation window. */
9
9
  export declare const DEVICE_OPEN_TIMEOUT_MS = 30000;
@@ -279,8 +279,11 @@ function parseStatusModel(value) {
279
279
  }
280
280
  function parseStatusConfig(value) {
281
281
  if (!record(value)) throw new Error("\u914D\u7F6E\u89C6\u56FE\u5FC5\u987B\u662F\u5BF9\u8C61");
282
- const apiKeyEnv = text(value.apiKeyEnv, "\u51ED\u636E\u5F15\u7528\u540D", MAX_ENV_REF);
283
- if (!ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
282
+ if (typeof value.apiKeyEnv !== "string" || value.apiKeyEnv.length > MAX_ENV_REF) {
283
+ throw new Error(`\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u6700\u591A ${MAX_ENV_REF} \u5B57\u7B26\u7684\u5B57\u7B26\u4E32`);
284
+ }
285
+ const apiKeyEnv = value.apiKeyEnv;
286
+ if (apiKeyEnv !== "" && !ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
284
287
  return {
285
288
  emptyTurnGuard: flag(value.emptyTurnGuard, "\u7A7A\u8F6E\u4FDD\u62A4\u5F00\u5173"),
286
289
  ...value.turnCompletionReview === void 0 ? {} : { turnCompletionReview: flag(value.turnCompletionReview, "\u7ED3\u675F\u56DE\u5408\u6838\u9A8C\u5F00\u5173") },
@@ -279,8 +279,11 @@ function parseStatusModel(value) {
279
279
  }
280
280
  function parseStatusConfig(value) {
281
281
  if (!record(value)) throw new Error("\u914D\u7F6E\u89C6\u56FE\u5FC5\u987B\u662F\u5BF9\u8C61");
282
- const apiKeyEnv = text(value.apiKeyEnv, "\u51ED\u636E\u5F15\u7528\u540D", MAX_ENV_REF);
283
- if (!ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
282
+ if (typeof value.apiKeyEnv !== "string" || value.apiKeyEnv.length > MAX_ENV_REF) {
283
+ throw new Error(`\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u6700\u591A ${MAX_ENV_REF} \u5B57\u7B26\u7684\u5B57\u7B26\u4E32`);
284
+ }
285
+ const apiKeyEnv = value.apiKeyEnv;
286
+ if (apiKeyEnv !== "" && !ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
284
287
  return {
285
288
  emptyTurnGuard: flag(value.emptyTurnGuard, "\u7A7A\u8F6E\u4FDD\u62A4\u5F00\u5173"),
286
289
  ...value.turnCompletionReview === void 0 ? {} : { turnCompletionReview: flag(value.turnCompletionReview, "\u7ED3\u675F\u56DE\u5408\u6838\u9A8C\u5F00\u5173") },
package/lib/index.d.ts CHANGED
@@ -50,6 +50,8 @@ export declare class OpenDesignCoRouterService extends TypertRemoteService {
50
50
  private _modelsEpoch;
51
51
  private _modelsPending;
52
52
  private _modelsController;
53
+ private _modelsWriteSerial;
54
+ private _modelsWrite;
53
55
  private _prices;
54
56
  private _pricesPending;
55
57
  modelCatalog(): readonly CatalogModel[];
@@ -57,6 +59,20 @@ export declare class OpenDesignCoRouterService extends TypertRemoteService {
57
59
  private _credentials;
58
60
  private _key;
59
61
  resolveApiKey(ref: string, baseURL?: string): Promise<string | undefined>;
62
+ /** Restore the persisted gateway catalog when it belongs to the active gateway. */
63
+ private _restoreModels;
64
+ /**
65
+ * Persist the snapshot through the Host form service.
66
+ * `unsupported` means no settings service is composed (nothing to report);
67
+ * `unavailable` means the service exists but exposes no writable form for this plugin.
68
+ *
69
+ * A settings write rewrites the whole composed profile and may rebuild the plugin tree, so
70
+ * only a concurrent revision conflict (`SETTINGS_CONFLICT`) is worth re-reading the revision
71
+ * and trying once more. Every other failure repeats identically and is reported immediately.
72
+ */
73
+ private _persistModels;
74
+ /** Serialize snapshot writes so the newest successful refresh is the last one persisted. */
75
+ private _queueModelsWrite;
60
76
  private _invalidateModels;
61
77
  private _state;
62
78
  private _conflict;