dsh-opendesign-corouter 0.1.13 → 0.1.14

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/README.md CHANGED
@@ -32,7 +32,7 @@ dsh plugin --profile web add dsh-opendesign-corouter
32
32
  也可打开 [Actions → CI](https://github.com/KouzakiUmi/dsh-opendesign-corouter/actions/workflows/ci.yml),从成功构建下载 **`dsh-opendesign-corouter-build`** artifact。登录 GitHub 后解压 ZIP,取得 `.tgz` 与 `.sha256`,再安装本地包:
33
33
 
34
34
  ```console
35
- dsh plugin --profile web add /absolute/path/to/dsh-opendesign-corouter-0.1.13.tgz
35
+ dsh plugin --profile web add /absolute/path/to/dsh-opendesign-corouter-0.1.14.tgz
36
36
  ```
37
37
 
38
38
  `web` 只是示例,请替换为目标 Profile。Desktop 使用桌面安装器提供的 `dsh` 入口;独立公共 CLI 不能代管保留的 `desktop` Profile。安装后的启用与重载按目标 DSH 的管理流程进行。
package/lib/catalog.d.ts CHANGED
@@ -7,12 +7,12 @@
7
7
  * - group:官网首页套餐卡 `https://corouter.open-design.ai/zh/` 的
8
8
  * `data-model-module="design-plan"` 12 款归 `plan`;其余在售对话模型归 `paid`。
9
9
  * - `plan` 原有 12 款的 contextWindow / maxOutputTokens 与原模态
10
- * 来自 Go 侧 `dsh-opendesign-go` 0.1.9 的 MODEL_DEFAULTS(同一 `amr-link` endpoint 部署资料),
11
- * 作为部署参考,尚无官网能力数值的独立佐证;图片模态按最新证据单独核验。
10
+ * 来自同网关客户端 `dsh-opendesign-go` 0.1.9 的 MODEL_DEFAULTS;该表标为厂商资料,
11
+ * 不能当作网关实测上限。图片模态按最新证据单独核验。
12
12
  * - 其余上下文窗口采用厂商公开资料或明确标注的暂定参考,逐型号来源见
13
13
  * docs/model-context.md;CoRouter 实际限制未验证,可以通过模型设置覆盖。
14
14
  * - `gpt-6.1-terra` 的 maxOutputTokens / inputModalities 取自厂商型号文档;
15
- * 仅补充其他型号的上下文,不改变最大输出默认值。
15
+ * 其余型号仅补充上下文参考,不新增目录最大输出能力字段。
16
16
  * - 客户端桌面安装(Open Design 0.26.1)不内联 CoRouter 目录;其
17
17
  * `vela model preset --format json` 只有 11 个旧预设 id(见 docs/client-evidence.md),
18
18
  * 与本表不同代,故不用于本目录。
package/lib/client.d.ts CHANGED
@@ -30,6 +30,7 @@ export interface FormValues {
30
30
  quotaRefreshSeconds?: number;
31
31
  requestTimeoutMs?: number;
32
32
  streamIdleTimeoutMs?: number;
33
+ maxRequestImageBytes?: number;
33
34
  }
34
35
  export interface FormSnapshot {
35
36
  status: 'loading' | 'ready' | 'unavailable';
package/lib/client.js CHANGED
@@ -20024,6 +20024,11 @@ function parseModelSettingsMap(value) {
20024
20024
  return out;
20025
20025
  }
20026
20026
 
20027
+ // src/image-budget.ts
20028
+ var MIN_REQUEST_IMAGE_BYTES = 1024 * 1024;
20029
+ var DEFAULT_MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024;
20030
+ var MAX_REQUEST_IMAGE_BYTES = 100 * 1024 * 1024;
20031
+
20027
20032
  // src/remote.ts
20028
20033
  var MAX_REVISION = 256;
20029
20034
  var MAX_JOB_ID = 128;
@@ -20212,7 +20217,8 @@ function parseStatusConfig(value) {
20212
20217
  ...value.modelSettings === void 0 ? {} : { modelSettings: parseModelSettingsMap(value.modelSettings) },
20213
20218
  ...value.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: positiveInteger(value.requestTimeoutMs, "\u8BF7\u6C42\u8D85\u65F6", 36e5, 1e3) },
20214
20219
  ...value.streamIdleTimeoutMs === void 0 ? {} : { streamIdleTimeoutMs: positiveInteger(value.streamIdleTimeoutMs, "\u6D41\u7A7A\u95F2\u8D85\u65F6", 18e5, 1e3) },
20215
- ...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) }
20220
+ ...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) },
20221
+ ...value.maxRequestImageBytes === void 0 ? {} : { maxRequestImageBytes: positiveInteger(value.maxRequestImageBytes, "\u8BF7\u6C42\u56FE\u7247\u9884\u7B97", MAX_REQUEST_IMAGE_BYTES, MIN_REQUEST_IMAGE_BYTES) }
20216
20222
  };
20217
20223
  }
20218
20224
  function parseStatus(value) {
@@ -21080,7 +21086,7 @@ function ModelRow({ model, settings, authoritative, writable, pending, disabledR
21080
21086
  return false;
21081
21087
  }
21082
21088
  }
21083
- const output2 = next.maxTokens ?? model.maxOutputTokens;
21089
+ const output2 = next.maxTokens;
21084
21090
  const context = next.contextWindow ?? model.contextWindow;
21085
21091
  if (output2 !== void 0 && context !== void 0 && output2 >= context) {
21086
21092
  setError("\u6700\u5927\u8F93\u51FA\u5FC5\u987B\u5C0F\u4E8E\u4E0A\u4E0B\u6587\u9884\u7B97\uFF1B\u8BF7\u5148\u589E\u5927\u4E0A\u4E0B\u6587\u9884\u7B97\u6216\u51CF\u5C0F\u6700\u5927\u8F93\u51FA\u3002");
@@ -21301,7 +21307,7 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
21301
21307
  "div",
21302
21308
  null,
21303
21309
  h("h3", null, "\u53EF\u7528\u6A21\u578B"),
21304
- h("p", { className: "odc-hint" }, "\u6309\u5206\u7EC4\u641C\u7D22\u6A21\u578B\uFF0C\u8BBE\u7F6E\u542F\u7528\u72B6\u6001\u4E0E\u9ED8\u8BA4\u53C2\u6570\u3002\u4E0A\u4E0B\u6587\u5BB9\u91CF\u4E3A\u76EE\u5F55\u53C2\u8003\uFF0C\u7F51\u5173\u9650\u5236\u53EF\u80FD\u4E0D\u540C\uFF0C\u53EF\u5728\u6A21\u578B\u8BBE\u7F6E\u4E2D\u8986\u76D6\u3002")
21310
+ h("p", { className: "odc-hint" }, "\u6309\u5206\u7EC4\u641C\u7D22\u6A21\u578B\uFF0C\u8BBE\u7F6E\u542F\u7528\u72B6\u6001\u4E0E\u9ED8\u8BA4\u53C2\u6570\u3002\u4E0A\u4E0B\u6587\u4E3A\u53C2\u8003\u9884\u7B97\uFF1B\u5237\u65B0\u540E\u4F1A\u91C7\u7528\u7F51\u5173\u62A5\u544A\u7684\u8F83\u5C0F\u7A97\u53E3\uFF0C\u5B9E\u9645\u9650\u5236\u53EF\u80FD\u4E0D\u540C\uFF0C\u53EF\u5728\u6A21\u578B\u8BBE\u7F6E\u4E2D\u8986\u76D6\u3002")
21305
21311
  ),
21306
21312
  h(
21307
21313
  "div",
@@ -21405,6 +21411,7 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
21405
21411
  const requestTimeout = formSnapshot.value?.requestTimeoutMs ?? status?.config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
21406
21412
  const streamIdleTimeout = formSnapshot.value?.streamIdleTimeoutMs ?? status?.config.streamIdleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;
21407
21413
  const refreshSeconds = formSnapshot.value?.quotaRefreshSeconds ?? status?.config.quotaRefreshSeconds ?? DEFAULT_QUOTA_REFRESH_SECONDS;
21414
+ const imageBudget = formSnapshot.value?.maxRequestImageBytes ?? status?.config.maxRequestImageBytes ?? DEFAULT_MAX_REQUEST_IMAGE_BYTES;
21408
21415
  const selected = API_PROTOCOL_OPTIONS.find((option) => option.id === protocol);
21409
21416
  const saveKeyRef = async () => {
21410
21417
  const value = apiKeyEnv.trim();
@@ -21506,6 +21513,23 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
21506
21513
  ),
21507
21514
  h(NoticeView, { notice: keyNotice })
21508
21515
  ),
21516
+ h(
21517
+ "section",
21518
+ { className: "odc-card" },
21519
+ h("h3", null, "\u56FE\u7247\u8BF7\u6C42\u9884\u7B97"),
21520
+ h("p", { className: "odc-hint" }, "\u5386\u53F2\u56FE\u7247\u8D85\u51FA\u9884\u7B97\u65F6\uFF0C\u7531\u5BBF\u4E3B\u5C06\u6700\u65E7\u56FE\u7247\u66FF\u6362\u4E3A\u5360\u4F4D\u7B26\u5E76\u91CD\u8BD5\uFF1B\u539F\u9644\u4EF6\u4FDD\u7559\u3002\u6458\u8981\u8BF7\u6C42\u4E5F\u4F7F\u7528\u6B64\u9884\u7B97\u3002"),
21521
+ h(NumberField, {
21522
+ id: "odc-image-budget",
21523
+ label: "\u5355\u6B21\u8BF7\u6C42\u56FE\u7247\u9884\u7B97\uFF08MiB\uFF09",
21524
+ hint: "1\u2013100 MiB\uFF1B\u7F51\u5173\u9650\u5236\u8F83\u4F4E\u65F6\u53EF\u8C03\u5C0F\u3002",
21525
+ value: imageBudget / (1024 * 1024),
21526
+ min: MIN_REQUEST_IMAGE_BYTES / (1024 * 1024),
21527
+ max: MAX_REQUEST_IMAGE_BYTES / (1024 * 1024),
21528
+ integer: false,
21529
+ disabled: !writable || pendingField.includes("maxRequestImageBytes"),
21530
+ onCommit: (value) => setFormField("maxRequestImageBytes", Math.round(value * 1024 * 1024))
21531
+ })
21532
+ ),
21509
21533
  h(
21510
21534
  "section",
21511
21535
  { className: "odc-card" },
package/lib/config.d.ts CHANGED
@@ -1,6 +1,7 @@
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
+ export { DEFAULT_MAX_REQUEST_IMAGE_BYTES } from './image-budget.js';
4
5
  export declare const SETTINGS_NS = "llm-opendesign-corouter";
5
6
  export declare const PLAN_PROVIDER = "opendesign-corouter-plan";
6
7
  export declare const PAID_PROVIDER = "opendesign-corouter-paid";
@@ -15,6 +16,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
15
16
  quotaRefreshSeconds: Schema<number, number, "volatile-defined">;
16
17
  requestTimeoutMs: Schema<number, number, "volatile-defined">;
17
18
  streamIdleTimeoutMs: Schema<number, number, "volatile-defined">;
19
+ maxRequestImageBytes: Schema<number, number, "volatile-defined">;
18
20
  }>>, Schemastery.ObjectT<NoInfer<{
19
21
  apiKeyEnv: Schema<string, string, "volatile-defined">;
20
22
  baseURL: Schema<string, string, "volatile-defined">;
@@ -25,6 +27,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
25
27
  quotaRefreshSeconds: Schema<number, number, "volatile-defined">;
26
28
  requestTimeoutMs: Schema<number, number, "volatile-defined">;
27
29
  streamIdleTimeoutMs: Schema<number, number, "volatile-defined">;
30
+ maxRequestImageBytes: Schema<number, number, "volatile-defined">;
28
31
  }>>, "plain">;
29
32
  export type LiveConfig = ReturnType<typeof Config>;
30
33
  export interface RuntimeConfig {
@@ -37,6 +40,7 @@ export interface RuntimeConfig {
37
40
  apiProtocol?: ApiProtocol;
38
41
  modelSettings?: ModelSettingsMap;
39
42
  quotaRefreshSeconds?: number;
43
+ maxRequestImageBytes?: number;
40
44
  }
41
45
  export declare function assertBaseURL(raw: string): string;
42
46
  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.13";
6
+ export declare const DEVICE_AUTH_PLUGIN_VERSION = "0.1.14";
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;
@@ -86,6 +86,11 @@ function parseModelSettingsMap(value) {
86
86
  return out;
87
87
  }
88
88
 
89
+ // src/image-budget.ts
90
+ var MIN_REQUEST_IMAGE_BYTES = 1024 * 1024;
91
+ var DEFAULT_MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024;
92
+ var MAX_REQUEST_IMAGE_BYTES = 100 * 1024 * 1024;
93
+
89
94
  // src/remote.ts
90
95
  var MAX_REVISION = 256;
91
96
  var MAX_JOB_ID = 128;
@@ -274,7 +279,8 @@ function parseStatusConfig(value) {
274
279
  ...value.modelSettings === void 0 ? {} : { modelSettings: parseModelSettingsMap(value.modelSettings) },
275
280
  ...value.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: positiveInteger(value.requestTimeoutMs, "\u8BF7\u6C42\u8D85\u65F6", 36e5, 1e3) },
276
281
  ...value.streamIdleTimeoutMs === void 0 ? {} : { streamIdleTimeoutMs: positiveInteger(value.streamIdleTimeoutMs, "\u6D41\u7A7A\u95F2\u8D85\u65F6", 18e5, 1e3) },
277
- ...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) }
282
+ ...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) },
283
+ ...value.maxRequestImageBytes === void 0 ? {} : { maxRequestImageBytes: positiveInteger(value.maxRequestImageBytes, "\u8BF7\u6C42\u56FE\u7247\u9884\u7B97", MAX_REQUEST_IMAGE_BYTES, MIN_REQUEST_IMAGE_BYTES) }
278
284
  };
279
285
  }
280
286
  function parseStatus(value) {
@@ -86,6 +86,11 @@ function parseModelSettingsMap(value) {
86
86
  return out;
87
87
  }
88
88
 
89
+ // src/image-budget.ts
90
+ var MIN_REQUEST_IMAGE_BYTES = 1024 * 1024;
91
+ var DEFAULT_MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024;
92
+ var MAX_REQUEST_IMAGE_BYTES = 100 * 1024 * 1024;
93
+
89
94
  // src/remote.ts
90
95
  var MAX_REVISION = 256;
91
96
  var MAX_JOB_ID = 128;
@@ -274,7 +279,8 @@ function parseStatusConfig(value) {
274
279
  ...value.modelSettings === void 0 ? {} : { modelSettings: parseModelSettingsMap(value.modelSettings) },
275
280
  ...value.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: positiveInteger(value.requestTimeoutMs, "\u8BF7\u6C42\u8D85\u65F6", 36e5, 1e3) },
276
281
  ...value.streamIdleTimeoutMs === void 0 ? {} : { streamIdleTimeoutMs: positiveInteger(value.streamIdleTimeoutMs, "\u6D41\u7A7A\u95F2\u8D85\u65F6", 18e5, 1e3) },
277
- ...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) }
282
+ ...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) },
283
+ ...value.maxRequestImageBytes === void 0 ? {} : { maxRequestImageBytes: positiveInteger(value.maxRequestImageBytes, "\u8BF7\u6C42\u56FE\u7247\u9884\u7B97", MAX_REQUEST_IMAGE_BYTES, MIN_REQUEST_IMAGE_BYTES) }
278
284
  };
279
285
  }
280
286
  function parseStatus(value) {
@@ -0,0 +1,4 @@
1
+ /** Bounds on the inline image payload in one inference or compaction request. */
2
+ export declare const MIN_REQUEST_IMAGE_BYTES: number;
3
+ export declare const DEFAULT_MAX_REQUEST_IMAGE_BYTES: number;
4
+ export declare const MAX_REQUEST_IMAGE_BYTES: number;
package/lib/index.js CHANGED
@@ -57,10 +57,12 @@ import { LlmError as LlmError13 } from "@deepseek-ai/dsh-llm";
57
57
  // src/adapter.ts
58
58
  import { createHmac, randomBytes } from "node:crypto";
59
59
  import {
60
+ IMAGE_OFFLOAD_REQUIRED_CODE,
60
61
  LlmAdapter,
61
62
  LlmError as LlmError11,
62
63
  ReasoningEffortId,
63
- assertUsableApiKey
64
+ assertUsableApiKey,
65
+ requiredImageOffload
64
66
  } from "@deepseek-ai/dsh-llm";
65
67
 
66
68
  // src/catalog.ts
@@ -322,6 +324,11 @@ function serializableTransform(callback) {
322
324
  });
323
325
  }
324
326
 
327
+ // src/image-budget.ts
328
+ var MIN_REQUEST_IMAGE_BYTES = 1024 * 1024;
329
+ var DEFAULT_MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024;
330
+ var MAX_REQUEST_IMAGE_BYTES = 100 * 1024 * 1024;
331
+
325
332
  // src/config.ts
326
333
  var SETTINGS_NS = "llm-opendesign-corouter";
327
334
  var PLAN_PROVIDER = "opendesign-corouter-plan";
@@ -336,7 +343,8 @@ var Config = Schema.object({
336
343
  emptyTurnGuard: Schema.boolean().default(true).description("\u68C0\u6D4B DeepSeek V4.1 Flash \u5DE5\u5177\u5BF9\u8BDD\u7684\u7A7A\u56DE\u7B54\u548C\u5F02\u5E38\u7ED3\u675F\uFF1B\u6301\u7EED\u91CD\u8BD5\u76F4\u5230\u6210\u529F\u6216\u53D6\u6D88\uFF0C\u53EF\u80FD\u8BEF\u5224\u5E76\u989D\u5916\u6D88\u8017\u989D\u5EA6").volatile(),
337
344
  quotaRefreshSeconds: Schema.natural().min(5).max(3600).default(60).description("\u989D\u5EA6\u81EA\u52A8\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09").volatile(),
338
345
  requestTimeoutMs: Schema.natural().min(1e3).max(36e5).default(18e5).description("\u63A8\u7406\u8BF7\u6C42\u603B\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09").volatile(),
339
- streamIdleTimeoutMs: Schema.natural().min(1e3).max(18e5).default(3e5).description("\u6D41\u5F0F\u54CD\u5E94\u65E0\u6570\u636E\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09").volatile()
346
+ streamIdleTimeoutMs: Schema.natural().min(1e3).max(18e5).default(3e5).description("\u6D41\u5F0F\u54CD\u5E94\u65E0\u6570\u636E\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09").volatile(),
347
+ maxRequestImageBytes: Schema.natural().min(MIN_REQUEST_IMAGE_BYTES).max(MAX_REQUEST_IMAGE_BYTES).default(DEFAULT_MAX_REQUEST_IMAGE_BYTES).description("\u5355\u6B21\u8BF7\u6C42\u7684\u5185\u8054\u56FE\u7247\u9884\u7B97\uFF08\u5B57\u8282\uFF09").volatile()
340
348
  });
341
349
  function assertBaseURL(raw) {
342
350
  if (raw.length > 2048) throw new Error("\u63A8\u7406 Base URL \u6700\u591A\u5141\u8BB8 2048 \u5B57\u7B26");
@@ -362,7 +370,8 @@ function readConfig(config) {
362
370
  useDesktopCredential: config.useDesktopCredential.get(),
363
371
  emptyTurnGuard: config.emptyTurnGuard.get(),
364
372
  requestTimeoutMs: config.requestTimeoutMs.get(),
365
- streamIdleTimeoutMs: config.streamIdleTimeoutMs.get()
373
+ streamIdleTimeoutMs: config.streamIdleTimeoutMs.get(),
374
+ maxRequestImageBytes: config.maxRequestImageBytes.get()
366
375
  };
367
376
  }
368
377
 
@@ -516,6 +525,7 @@ var MESSAGES = {
516
525
  RATE_LIMIT: "OpenDesign\uFF1A\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",
517
526
  TIMEOUT: "OpenDesign\uFF1A\u8BF7\u6C42\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",
518
527
  SERVER: "OpenDesign\uFF1A\u4E0A\u6E38\u670D\u52A1\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",
528
+ REQUEST_TOO_LARGE: "OpenDesign\uFF1A\u8BF7\u6C42\u5185\u5BB9\u8D85\u8FC7\u4E0A\u6E38\u5927\u5C0F\u9650\u5236\uFF0C\u8BF7\u538B\u7F29\u5386\u53F2\u3001\u51CF\u5C11\u56FE\u7247\u6216\u7F29\u5C0F\u8F93\u5165\u540E\u91CD\u8BD5",
519
529
  INVALID_REQUEST: "OpenDesign\uFF1A\u8BF7\u6C42\u88AB\u4E0A\u6E38\u62D2\u7EDD",
520
530
  INVALID_RESPONSE: "OpenDesign\uFF1A\u4E0A\u6E38\u54CD\u5E94\u683C\u5F0F\u65E0\u6548"
521
531
  };
@@ -586,6 +596,7 @@ function classifyStatus(status) {
586
596
  if (status === 401) return "AUTH";
587
597
  if (status === 403) return "PERMISSION";
588
598
  if (status === 402) return QUOTA_EXCEEDED_CODE;
599
+ if (status === 413) return "REQUEST_TOO_LARGE";
589
600
  if (status === 429) return "RATE_LIMIT";
590
601
  if (status === 408 || status === 504) return "TIMEOUT";
591
602
  if (status >= 500) return "SERVER";
@@ -2074,6 +2085,12 @@ var CoRouterAdapter = class extends LlmAdapter {
2074
2085
  unreadableImages.add(block.attachment.attachmentId);
2075
2086
  }
2076
2087
  }
2088
+ signal.throwIfAborted();
2089
+ const imageMessages = options.messages.filter((message) => message.role === "user" || message.role === "tool");
2090
+ const imageBytes = (block) => Buffer.byteLength(images.get(block.attachment.attachmentId) ?? "", "utf8");
2091
+ const offloadCount = (maxBytes) => requiredImageOffload(imageMessages, { representation: "raw", maxBytes }, imageBytes);
2092
+ const overBudget = offloadCount(config.maxRequestImageBytes ?? DEFAULT_MAX_REQUEST_IMAGE_BYTES);
2093
+ if (overBudget > 0) throw new LlmError11("OpenDesign\uFF1A\u56FE\u7247\u8BF7\u6C42\u8D85\u51FA\u5B57\u8282\u9884\u7B97\uFF0C\u9700\u8981\u9000\u8F7D\u8F83\u65E9\u56FE\u7247\u540E\u91CD\u8BD5", IMAGE_OFFLOAD_REQUIRED_CODE, { offloadImages: overBudget });
2077
2094
  const projectedOptions = unreadableImages.size === 0 ? options : {
2078
2095
  ...options,
2079
2096
  messages: options.messages.map((message) => message.role !== "user" && message.role !== "tool" ? message : {
@@ -2144,7 +2161,16 @@ var CoRouterAdapter = class extends LlmAdapter {
2144
2161
  reader.releaseLock();
2145
2162
  }
2146
2163
  }
2147
- throw gatewayError(response.status, error);
2164
+ signal.throwIfAborted();
2165
+ const failure = gatewayError(response.status, error);
2166
+ if (response.status === 413 && failure.code === "REQUEST_TOO_LARGE") {
2167
+ const totalImageBytes = imageMessages.reduce((total, message) => total + message.content.reduce((sum, block) => sum + (block.type === "image" && !block.offloaded ? imageBytes(block) : 0), 0), 0);
2168
+ if (totalImageBytes > 0) {
2169
+ const offloadImages = offloadCount(Math.max(0, totalImageBytes - 4 * 1024 * 1024));
2170
+ if (offloadImages > 0) throw new LlmError11("OpenDesign\uFF1A\u8BF7\u6C42\u4F53\u8FC7\u5927\uFF0C\u9700\u8981\u9000\u8F7D\u8F83\u65E9\u56FE\u7247\u540E\u91CD\u8BD5", IMAGE_OFFLOAD_REQUIRED_CODE, { status: 413, offloadImages });
2171
+ }
2172
+ }
2173
+ throw failure;
2148
2174
  }
2149
2175
  const monitor = row.group === "plan" && row.id === "deepseek-v4.1-flash" && config.emptyTurnGuard && Boolean(options.tools?.length);
2150
2176
  const reportEmptyTurn = () => {
@@ -2338,6 +2364,7 @@ var DISCOVERY_TIMEOUT_MS = 2e4;
2338
2364
  var MAX_DISCOVERY_BODY_BYTES = 2 * 1024 * 1024;
2339
2365
  var MAX_MODELS = 512;
2340
2366
  var MAX_MODEL_NAME_LENGTH = 128;
2367
+ var MAX_CONTEXT_WINDOW = 1e8;
2341
2368
  var MODEL_ID = /^[A-Za-z0-9._:/-]{1,128}$/u;
2342
2369
  var MEDIA_MODEL_ID = /^(?:gpt-image-|nano-banana-|seedream-|imagen-|veo-|doubao-seedance-|sora-)/u;
2343
2370
  var MESSAGES2 = {
@@ -2406,6 +2433,21 @@ async function boundedJson(response, signal, deadline) {
2406
2433
  throw new ModelDiscoveryError("response");
2407
2434
  }
2408
2435
  }
2436
+ function gatewayContext(value) {
2437
+ const metadata2 = record(value.metadata) ? value.metadata : {};
2438
+ const candidates = [
2439
+ metadata2.context_limit,
2440
+ metadata2.contextWindowTokens,
2441
+ metadata2.context_window_tokens,
2442
+ value.contextWindowTokens,
2443
+ value.context_window_tokens,
2444
+ value.contextLength,
2445
+ value.context_length,
2446
+ value.contextWindow,
2447
+ value.context_window
2448
+ ].filter((item) => typeof item === "number" && Number.isSafeInteger(item) && item > 0 && item <= MAX_CONTEXT_WINDOW);
2449
+ return candidates.length === 0 ? void 0 : Math.min(...candidates);
2450
+ }
2409
2451
  function normalize(body) {
2410
2452
  if (!record(body) || !Array.isArray(body.data)) throw new ModelDiscoveryError("response");
2411
2453
  if (body.data.length > MAX_MODELS) throw new ModelDiscoveryError("response");
@@ -2416,13 +2458,15 @@ function normalize(body) {
2416
2458
  if (MEDIA_MODEL_ID.test(value.id) || seen.has(value.id)) continue;
2417
2459
  seen.add(value.id);
2418
2460
  const known = findModel(value.id);
2461
+ const offeredContext = gatewayContext(value);
2419
2462
  if (known) {
2420
- rows.push({ ...known });
2463
+ const contextWindow = offeredContext === void 0 ? known.contextWindow : known.contextWindow === void 0 ? offeredContext : Math.min(known.contextWindow, offeredContext);
2464
+ rows.push({ ...known, ...contextWindow === void 0 ? {} : { contextWindow } });
2421
2465
  continue;
2422
2466
  }
2423
2467
  const offered = typeof value.name === "string" ? value.name.trim() : "";
2424
2468
  const name2 = offered !== "" && offered.length <= MAX_MODEL_NAME_LENGTH ? offered : value.id;
2425
- rows.push({ id: value.id, name: name2, group: "paid" });
2469
+ rows.push({ id: value.id, name: name2, group: "paid", ...offeredContext === void 0 ? {} : { contextWindow: offeredContext } });
2426
2470
  }
2427
2471
  return rows;
2428
2472
  }
@@ -2970,7 +3014,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
2970
3014
 
2971
3015
  // src/device-auth.ts
2972
3016
  var DEVICE_AUTH_ENDPOINT = "https://amr-api.open-design.ai/api/v1/cli/device-authorizations";
2973
- var DEVICE_AUTH_PLUGIN_VERSION = "0.1.13";
3017
+ var DEVICE_AUTH_PLUGIN_VERSION = "0.1.14";
2974
3018
  var DEVICE_REQUEST_TIMEOUT_MS = 2e4;
2975
3019
  var DEVICE_RESPONSE_MAX_BYTES = 65536;
2976
3020
  var DEVICE_POLL_MIN_MS = 1e3;
@@ -4089,7 +4133,8 @@ function parseStatusConfig(value) {
4089
4133
  ...value.modelSettings === void 0 ? {} : { modelSettings: parseModelSettingsMap(value.modelSettings) },
4090
4134
  ...value.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: positiveInteger(value.requestTimeoutMs, "\u8BF7\u6C42\u8D85\u65F6", 36e5, 1e3) },
4091
4135
  ...value.streamIdleTimeoutMs === void 0 ? {} : { streamIdleTimeoutMs: positiveInteger(value.streamIdleTimeoutMs, "\u6D41\u7A7A\u95F2\u8D85\u65F6", 18e5, 1e3) },
4092
- ...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) }
4136
+ ...value.quotaRefreshSeconds === void 0 ? {} : { quotaRefreshSeconds: positiveInteger(value.quotaRefreshSeconds, "\u81EA\u52A8\u5237\u65B0\u95F4\u9694", 3600, 5) },
4137
+ ...value.maxRequestImageBytes === void 0 ? {} : { maxRequestImageBytes: positiveInteger(value.maxRequestImageBytes, "\u8BF7\u6C42\u56FE\u7247\u9884\u7B97", MAX_REQUEST_IMAGE_BYTES, MIN_REQUEST_IMAGE_BYTES) }
4093
4138
  };
4094
4139
  }
4095
4140
  function parseStatus(value) {