dsh-opendesign-corouter 0.1.11 → 0.1.12
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 +2 -2
- package/SECURITY.md +1 -0
- package/lib/adapter.d.ts +2 -0
- package/lib/catalog.d.ts +4 -3
- package/lib/claude-capabilities.d.ts +8 -0
- package/lib/claude-parameters.d.ts +3 -0
- package/lib/client.d.ts +4 -1
- package/lib/client.js +121 -13
- package/lib/device-auth.d.ts +1 -1
- package/lib/generated/typert.host.js +12 -1
- package/lib/generated/typert.remote-client.js +12 -1
- package/lib/index.js +450 -116
- package/lib/index.js.map +4 -4
- package/lib/model-settings.d.ts +4 -3
- package/lib/protocols/messages.d.ts +5 -7
- package/lib/protocols/types.d.ts +10 -1
- package/lib/remote.d.ts +2 -0
- package/lib/replay-key.d.ts +13 -0
- package/package.json +1 -1
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.
|
|
35
|
+
dsh plugin --profile web add /absolute/path/to/dsh-opendesign-corouter-0.1.12.tgz
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
`web` 只是示例,请替换为目标 Profile。Desktop 使用桌面安装器提供的 `dsh` 入口;独立公共 CLI 不能代管保留的 `desktop` Profile。安装后的启用与重载按目标 DSH 的管理流程进行。
|
|
@@ -55,7 +55,7 @@ dsh plugin --profile web add /absolute/path/to/dsh-opendesign-corouter-0.1.11.tg
|
|
|
55
55
|
| `opendesign-corouter-plan` | 13 | Core / Design Plan 附赠通道,含预检确认覆盖的 MiniMax M3.1 Flash |
|
|
56
56
|
| `opendesign-corouter-paid` | 26 | Plan 套餐模型及其他钱包付费模型 |
|
|
57
57
|
|
|
58
|
-
上表为内置目录。模型页可通过当前配置网关的 OpenAI 兼容 `/models`
|
|
58
|
+
上表为内置目录。模型页可通过当前配置网关的 OpenAI 兼容 `/models` 接口刷新目录,逐个启用或停用模型、控制图片输入,并配置温度、top-p、默认输出上限、上下文预算及思考深度。高级参数默认折叠,图片输入可手动覆盖或恢复自动。未知模态保持未知并尝试发送图片;实际支持情况由网关决定。[图片能力证据](docs/model-capabilities.md)。
|
|
59
59
|
|
|
60
60
|
推理协议可选 **OpenAI Chat Completions、OpenAI Responses、Anthropic Messages**。模型发现始终使用当前网关的 OpenAI 兼容 `/models` 接口,不随推理协议切换。
|
|
61
61
|
|
package/SECURITY.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
- 推理、桌面控制面和控制台 Cookie 分属独立通道,不互相替代鉴权材料。
|
|
4
4
|
- API Key 与设备授权的 controlKey / runtimeKey 仅经 DSH 凭据服务写入插件专属记录;设置页只读取存在性和状态,不回填秘密。
|
|
5
|
+
- Claude Messages 使用凭据服务中的插件专属随机绑定密钥,确保同一网关切换推理 Key 时不向新身份回放旧签名;会话和备份包含上游签名及加密思考元数据。无凭据服务时绑定仅在当前插件实例内有效。
|
|
5
6
|
- 桌面配置只读。仅支持已核实的生产环境,控制令牌只能发送到 `https://amr-api.open-design.ai`。控制台和推理请求禁止自动跟随重定向。
|
|
6
7
|
- 设备授权双令牌原子保存;runtimeKey 只自动提供给请求快照中的官方推理 origin,controlKey 只发往官方控制面。旧 Cookie grant 保留只读兼容。
|
|
7
8
|
- 推理自定义地址由用户显式配置;除本机回环外要求 HTTPS,拒绝 URL 内嵌凭据、查询串与片段。
|
package/lib/adapter.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface AdapterOptions {
|
|
|
9
9
|
imageDataUrl?(image: ImageAttachmentRef, signal: AbortSignal): Promise<string | undefined>;
|
|
10
10
|
onEmptyTurn?(): void;
|
|
11
11
|
fetch?: typeof fetch;
|
|
12
|
+
/** Caller-owned random binding-secret bytes from the Host credential service. */
|
|
13
|
+
replayBindingSecret?(signal: AbortSignal): Promise<Uint8Array>;
|
|
12
14
|
}
|
|
13
15
|
export declare class CoRouterAdapter extends LlmAdapter {
|
|
14
16
|
#private;
|
package/lib/catalog.d.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* 详情页内联 `data-model="{...}"` JSON(公开页面,2026-10-26)。
|
|
7
7
|
* - group:官网首页套餐卡 `https://corouter.open-design.ai/zh/` 的
|
|
8
8
|
* `data-model-module="design-plan"` 12 款归 `plan`;其余在售对话模型归 `paid`。
|
|
9
|
-
* - `plan` 原有 12 款的 contextWindow / maxOutputTokens
|
|
9
|
+
* - `plan` 原有 12 款的 contextWindow / maxOutputTokens 与原模态
|
|
10
10
|
* 来自 Go 侧 `dsh-opendesign-go` 0.1.9 的 MODEL_DEFAULTS(同一 `amr-link` endpoint 部署资料),
|
|
11
|
-
*
|
|
11
|
+
* 作为部署参考,尚无官网能力数值的独立佐证;图片模态按最新证据单独核验。
|
|
12
12
|
* - `gpt-6.1-terra` 的 contextWindow / maxOutputTokens / inputModalities 取自
|
|
13
13
|
* 厂商型号文档(1,050,000 / 128,000 / text+image,与 `gpt-6-luna` 同口径);
|
|
14
14
|
* CoRouter 网关侧未实测该型号的有效预算。
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
* 走 `/api/v1/media/*`,不应出现在对话模型列表里,避免选中后 chat 请求必败。
|
|
33
33
|
*
|
|
34
34
|
* 思考档位按厂商型号资料记录,来源见 docs/reasoning-evidence.md;网关逐路由行为未实测。
|
|
35
|
-
*
|
|
35
|
+
* 图片输入能力按精确型号的厂商资料补充,证据与网关限制见 docs/model-capabilities.md;
|
|
36
|
+
* 不可确认的模态与容量保持缺省。
|
|
36
37
|
*/
|
|
37
38
|
export interface CatalogModel {
|
|
38
39
|
id: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApiProtocol } from './protocol-options.js';
|
|
2
|
+
/** This policy is scoped to the native Messages API and evidenced model IDs. */
|
|
3
|
+
export declare function hasRestrictedClaudeSampling(model: string, protocol: ApiProtocol): boolean;
|
|
4
|
+
/** Return a validation reason without changing an explicitly requested value. */
|
|
5
|
+
export declare function claudeSamplingError(model: string, protocol: ApiProtocol, temperature: number | undefined, topP: number | undefined): string | undefined;
|
|
6
|
+
/** Vendor-documented synchronous Messages output ceiling for these exact model IDs. */
|
|
7
|
+
export declare const CLAUDE_MESSAGES_MAX_OUTPUT = 128000;
|
|
8
|
+
export declare function claudeOutputError(model: string, protocol: ApiProtocol, maxTokens: number | undefined): string | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Reject unsupported explicit overrides rather than silently changing their meaning. */
|
|
2
|
+
export declare function validateClaudeSampling(model: string, temperature: number | undefined, topP: number | undefined): void;
|
|
3
|
+
export declare function validateClaudeOutput(model: string, maxTokens: number | undefined): void;
|
package/lib/client.d.ts
CHANGED
|
@@ -120,6 +120,8 @@ export declare function modelSettingsEntry(map: ModelSettingsMap | undefined, id
|
|
|
120
120
|
* `Status.models[].enabled`, which can lag one refresh behind a reset.
|
|
121
121
|
*/
|
|
122
122
|
export declare function modelEnabled(model: StatusModel, settings: ModelSettings | undefined, authoritative?: boolean): boolean;
|
|
123
|
+
/** Manual image policy wins; automatic mode only treats an explicit catalog image modality as confirmed. */
|
|
124
|
+
export declare function modelImageInput(model: StatusModel, settings: ModelSettings | undefined): boolean;
|
|
123
125
|
export interface NumberInputSpec {
|
|
124
126
|
label: string;
|
|
125
127
|
min: number;
|
|
@@ -170,11 +172,12 @@ export interface ModelRowProps {
|
|
|
170
172
|
authoritative: boolean;
|
|
171
173
|
writable: boolean;
|
|
172
174
|
pending: boolean;
|
|
175
|
+
protocol?: ApiProtocol;
|
|
173
176
|
price?: PriceCatalog['models'][number] | undefined;
|
|
174
177
|
priceKnown?: boolean | undefined;
|
|
175
178
|
onCommit: (next: ModelSettings | undefined) => Promise<boolean>;
|
|
176
179
|
}
|
|
177
|
-
export declare function ModelRow({ model, settings, authoritative, writable, pending, price, priceKnown, onCommit }: ModelRowProps): React.DetailedReactHTMLElement<{
|
|
180
|
+
export declare function ModelRow({ model, settings, authoritative, writable, pending, protocol, price, priceKnown, onCommit }: ModelRowProps): React.DetailedReactHTMLElement<{
|
|
178
181
|
className: string;
|
|
179
182
|
}, HTMLElement>;
|
|
180
183
|
export interface ModelsProps {
|
package/lib/client.js
CHANGED
|
@@ -47,6 +47,7 @@ __export(client_exports, {
|
|
|
47
47
|
formatWindowCredits: () => formatWindowCredits,
|
|
48
48
|
inject: () => inject,
|
|
49
49
|
modelEnabled: () => modelEnabled,
|
|
50
|
+
modelImageInput: () => modelImageInput,
|
|
50
51
|
modelSettingsEntry: () => modelSettingsEntry,
|
|
51
52
|
name: () => name,
|
|
52
53
|
nextWindowResetAt: () => nextWindowResetAt,
|
|
@@ -19979,7 +19980,7 @@ function parseModelSettingsMap(value) {
|
|
|
19979
19980
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
19980
19981
|
const keys = Object.keys(value);
|
|
19981
19982
|
if (keys.length > 512) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u6700\u591A\u5141\u8BB8 512 \u4E2A\u6A21\u578B");
|
|
19982
|
-
const fields = /* @__PURE__ */ new Set(["enabled", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
19983
|
+
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
19983
19984
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
19984
19985
|
const out = {};
|
|
19985
19986
|
for (const id of keys) {
|
|
@@ -19996,6 +19997,10 @@ function parseModelSettingsMap(value) {
|
|
|
19996
19997
|
if (typeof settings.enabled !== "boolean") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 enabled \u5FC5\u987B\u662F\u5E03\u5C14\u503C");
|
|
19997
19998
|
parsed.enabled = settings.enabled;
|
|
19998
19999
|
}
|
|
20000
|
+
if (settings.imageInput !== void 0) {
|
|
20001
|
+
if (typeof settings.imageInput !== "boolean") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 imageInput \u5FC5\u987B\u662F\u5E03\u5C14\u503C");
|
|
20002
|
+
parsed.imageInput = settings.imageInput;
|
|
20003
|
+
}
|
|
19999
20004
|
for (const [field, max] of [["temperature", 2], ["topP", 1]]) {
|
|
20000
20005
|
const item = settings[field];
|
|
20001
20006
|
if (item === void 0) continue;
|
|
@@ -20067,6 +20072,12 @@ function parseEfforts(value) {
|
|
|
20067
20072
|
if (!Array.isArray(value) || value.length > 16) throw new Error("\u6A21\u578B\u601D\u8003\u6863\u4F4D\u683C\u5F0F\u65E0\u6548");
|
|
20068
20073
|
return value.map((item) => text(item, "\u601D\u8003\u6863\u4F4D", 32));
|
|
20069
20074
|
}
|
|
20075
|
+
function parseModalities(value) {
|
|
20076
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > 2) throw new Error("\u6A21\u578B\u8F93\u5165\u6A21\u6001\u683C\u5F0F\u65E0\u6548");
|
|
20077
|
+
const modes = value.map((item) => member(item, ["text", "image"], "\u6A21\u578B\u8F93\u5165\u6A21\u6001"));
|
|
20078
|
+
if (!modes.includes("text") || new Set(modes).size !== modes.length) throw new Error("\u6A21\u578B\u8F93\u5165\u6A21\u6001\u683C\u5F0F\u65E0\u6548");
|
|
20079
|
+
return modes;
|
|
20080
|
+
}
|
|
20070
20081
|
function member(value, allowed, label) {
|
|
20071
20082
|
const hit = allowed.find((candidate) => candidate === value);
|
|
20072
20083
|
if (hit === void 0) throw new Error(`${label} \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185`);
|
|
@@ -20181,6 +20192,7 @@ function parseStatusModel(value) {
|
|
|
20181
20192
|
name: text(value.name, "\u6A21\u578B\u540D", 128),
|
|
20182
20193
|
group: member(value.group, MODEL_GROUPS, "\u6A21\u578B\u5206\u7EC4"),
|
|
20183
20194
|
...value.enabled === void 0 ? {} : { enabled: flag(value.enabled, "\u6A21\u578B\u542F\u7528\u72B6\u6001") },
|
|
20195
|
+
...value.inputModalities === void 0 ? {} : { inputModalities: parseModalities(value.inputModalities) },
|
|
20184
20196
|
...value.contextWindow === void 0 ? {} : { contextWindow: positiveInteger(value.contextWindow, "\u4E0A\u4E0B\u6587\u9884\u7B97", 1e8) },
|
|
20185
20197
|
...value.maxOutputTokens === void 0 ? {} : { maxOutputTokens: positiveInteger(value.maxOutputTokens, "\u6700\u5927\u8F93\u51FA", 1e7) },
|
|
20186
20198
|
...value.reasoningEfforts === void 0 ? {} : { reasoningEfforts: parseEfforts(value.reasoningEfforts) }
|
|
@@ -20287,6 +20299,32 @@ function modelReasoningEfforts(model, protocol) {
|
|
|
20287
20299
|
return model.reasoningEfforts?.filter((effort) => protocolAcceptsEffort(protocol, effort));
|
|
20288
20300
|
}
|
|
20289
20301
|
|
|
20302
|
+
// src/claude-capabilities.ts
|
|
20303
|
+
var RESTRICTED_MESSAGES_SAMPLING = /* @__PURE__ */ new Set([
|
|
20304
|
+
"claude-fable-5.1",
|
|
20305
|
+
"claude-fable-5",
|
|
20306
|
+
"claude-opus-5.5",
|
|
20307
|
+
"claude-opus-5",
|
|
20308
|
+
"claude-opus-4.8",
|
|
20309
|
+
"claude-sonnet-5.5",
|
|
20310
|
+
"claude-sonnet-5",
|
|
20311
|
+
"claude-haiku-5.5"
|
|
20312
|
+
]);
|
|
20313
|
+
function hasRestrictedClaudeSampling(model, protocol) {
|
|
20314
|
+
return protocol === "messages" && RESTRICTED_MESSAGES_SAMPLING.has(model);
|
|
20315
|
+
}
|
|
20316
|
+
function claudeSamplingError(model, protocol, temperature, topP) {
|
|
20317
|
+
if (!hasRestrictedClaudeSampling(model, protocol)) return void 0;
|
|
20318
|
+
if (temperature !== void 0 && topP !== void 0) return "\u6B64 Claude \u6A21\u578B\u7684 Messages \u8BF7\u6C42\u4E0D\u80FD\u540C\u65F6\u8BBE\u7F6E\u6E29\u5EA6\u548C Top P\uFF0C\u8BF7\u81F3\u5C11\u6E05\u7A7A\u4E00\u9879\u3002";
|
|
20319
|
+
if (temperature !== void 0 && temperature !== 1) return "\u6B64 Claude \u6A21\u578B\u7684 Messages \u8BF7\u6C42\u4EC5\u63A5\u53D7\u9ED8\u8BA4\u6E29\u5EA6 1\uFF0C\u8BF7\u6E05\u7A7A\u6216\u6539\u4E3A 1\u3002";
|
|
20320
|
+
if (topP !== void 0 && topP !== 0.99) return "\u6B64 Claude \u6A21\u578B\u7684 Messages \u8BF7\u6C42\u4EC5\u63A5\u53D7\u9ED8\u8BA4 Top P 0.99\uFF0C\u8BF7\u6E05\u7A7A\u6216\u6539\u4E3A 0.99\u3002";
|
|
20321
|
+
return void 0;
|
|
20322
|
+
}
|
|
20323
|
+
var CLAUDE_MESSAGES_MAX_OUTPUT = 128e3;
|
|
20324
|
+
function claudeOutputError(model, protocol, maxTokens) {
|
|
20325
|
+
return hasRestrictedClaudeSampling(model, protocol) && maxTokens !== void 0 && maxTokens > CLAUDE_MESSAGES_MAX_OUTPUT ? "\u6B64 Claude \u6A21\u578B\u7684 Messages \u6700\u5927\u8F93\u51FA\u4E3A 128000\uFF0C\u8BF7\u51CF\u5C0F\u8F93\u51FA\u4E0A\u9650\u3002" : void 0;
|
|
20326
|
+
}
|
|
20327
|
+
|
|
20290
20328
|
// src/client.ts
|
|
20291
20329
|
var h = React.createElement;
|
|
20292
20330
|
var SETTINGS_NS = "llm-opendesign-corouter";
|
|
@@ -20343,6 +20381,7 @@ function installStyles() {
|
|
|
20343
20381
|
.odc-notice{padding:9px 11px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent);font-size:12px;line-height:1.6}.odc-notice[data-kind=error]{color:var(--dsw-alias-state-error-primary,inherit);color:color-mix(in srgb,var(--dsw-alias-state-error-primary,CanvasText) 85%,var(--dsw-alias-label-primary,CanvasText))}
|
|
20344
20382
|
.odc-model-groups{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:12px}.odc-model-list{display:grid;gap:6px;margin:10px 0 0;padding:0;list-style:none}.odc-model-item{padding:9px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent);min-width:0}.odc-model-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;flex-wrap:wrap}.odc-model-switch{min-width:0;flex:1 1 190px}.odc-model-item strong,.odc-model-item code{display:block;overflow-wrap:anywhere}.odc-model-item strong{font-size:12px;font-weight:600}.odc-model-item code{margin-top:2px;color:var(--dsw-alias-label-secondary,inherit);font-size:11px}.odc-model-meta{margin-top:6px!important;color:var(--dsw-alias-label-secondary,inherit);font-size:11px;overflow-wrap:anywhere}.odc-model-count{color:var(--dsw-alias-label-secondary,inherit);font-size:11px;font-weight:400}.odc-chip{display:inline-flex;align-items:center;padding:1px 7px;border:1px solid var(--dsw-alias-border-l3,transparent);border-radius:999px;color:var(--dsw-alias-label-secondary,inherit);font-size:10px;line-height:1.6}
|
|
20345
20383
|
.odc-model-details{margin-top:8px}.odc-model-details>summary{cursor:pointer;color:var(--dsw-alias-label-secondary,inherit);font-size:11px;line-height:1.7}.odc-model-editor{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:2px 10px;margin-top:8px}
|
|
20384
|
+
.odc-model-image{display:flex;align-items:center;gap:4px 10px;flex-wrap:wrap;margin-top:6px;padding:4px 0;border-top:1px solid var(--dsw-alias-border-l4,transparent)}.odc-model-image .odc-switch{flex:1 1 210px;min-width:0;min-height:34px;padding:2px 0}.odc-model-image .odc-switch>span{display:flex;align-items:baseline;gap:4px 8px;flex-wrap:wrap}.odc-model-image .odc-button{flex:none}
|
|
20346
20385
|
.odc-field{display:grid;gap:6px;margin-top:14px}.odc-field-compact{margin-top:8px}.odc-field label,.odc-switch-text{font-size:12px;font-weight:550}.odc-input{width:100%;min-width:0;min-height:34px;padding:7px 9px;border:1px solid var(--dsw-alias-border-l3,transparent);border-radius:8px;background:var(--dsw-alias-bg-layer-2,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12px}.odc-field-compact .odc-input{min-height:30px;padding:5px 8px;font-size:11px}.odc-input::placeholder{color:var(--dsw-alias-label-secondary,inherit);opacity:1}.odc-input:disabled{opacity:.55}
|
|
20347
20386
|
.odc-input option{background:var(--dsw-alias-bg-layer-2,Canvas);color:var(--dsw-alias-label-primary,CanvasText)}
|
|
20348
20387
|
.odc-input,.odc-button:not(.odc-button-primary),.odc-tab[aria-selected=true]{border-color:var(--dsw-alias-border-l3,CanvasText);border-color:color-mix(in srgb,var(--dsw-alias-label-primary,CanvasText) 55%,var(--dsw-alias-bg-layer-2,Canvas))}
|
|
@@ -20718,6 +20757,7 @@ function writeModelSettings(map2, id, next) {
|
|
|
20718
20757
|
}
|
|
20719
20758
|
const entry = {};
|
|
20720
20759
|
if (next.enabled !== void 0) entry.enabled = next.enabled;
|
|
20760
|
+
if (next.imageInput !== void 0) entry.imageInput = next.imageInput;
|
|
20721
20761
|
if (next.temperature !== void 0) entry.temperature = next.temperature;
|
|
20722
20762
|
if (next.topP !== void 0) entry.topP = next.topP;
|
|
20723
20763
|
if (next.maxTokens !== void 0) entry.maxTokens = next.maxTokens;
|
|
@@ -20735,6 +20775,15 @@ function modelEnabled(model, settings, authoritative = true) {
|
|
|
20735
20775
|
if (authoritative) return true;
|
|
20736
20776
|
return model.enabled !== false;
|
|
20737
20777
|
}
|
|
20778
|
+
function modelImageInput(model, settings) {
|
|
20779
|
+
if (settings?.imageInput !== void 0) return settings.imageInput;
|
|
20780
|
+
return model.inputModalities === void 0 ? true : model.inputModalities.includes("image");
|
|
20781
|
+
}
|
|
20782
|
+
function imageInputSource(model, settings) {
|
|
20783
|
+
if (settings.imageInput !== void 0) return settings.imageInput ? "\u624B\u52A8 \xB7 \u5F00\u542F" : "\u624B\u52A8 \xB7 \u5173\u95ED";
|
|
20784
|
+
if (model.inputModalities === void 0) return "\u81EA\u52A8 \xB7 \u672A\u77E5\uFF0C\u5C1D\u8BD5\u53D1\u9001";
|
|
20785
|
+
return model.inputModalities.includes("image") ? "\u81EA\u52A8 \xB7 \u652F\u6301\u56FE\u7247" : "\u81EA\u52A8 \xB7 \u4EC5\u6587\u672C";
|
|
20786
|
+
}
|
|
20738
20787
|
var DECIMAL_TEXT = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/u;
|
|
20739
20788
|
function parseNumberInput(raw, spec) {
|
|
20740
20789
|
const text2 = raw.trim();
|
|
@@ -20799,7 +20848,7 @@ var NUMERIC_FIELDS = {
|
|
|
20799
20848
|
contextWindow: { label: "\u4E0A\u4E0B\u6587\u9884\u7B97\uFF08tokens\uFF09", hint: "\u6B63\u6574\u6570\uFF1B\u7559\u7A7A\u7EE7\u627F\u76EE\u5F55\u9ED8\u8BA4\u3002", min: 1, max: MAX_CONTEXT_WINDOW, integer: true }
|
|
20800
20849
|
};
|
|
20801
20850
|
var NUMERIC_ORDER = ["temperature", "topP", "maxTokens", "contextWindow"];
|
|
20802
|
-
function OptionalNumberField({ id, field, value, disabled, resetToken, onSave }) {
|
|
20851
|
+
function OptionalNumberField({ id, field, value, disabled, restricted = false, invalid = false, maxOutputLimit, resetToken, onSave }) {
|
|
20803
20852
|
const spec = NUMERIC_FIELDS[field];
|
|
20804
20853
|
const mounted = useMounted();
|
|
20805
20854
|
const [draft, setDraft] = React.useState(void 0);
|
|
@@ -20843,11 +20892,11 @@ function OptionalNumberField({ id, field, value, disabled, resetToken, onSave })
|
|
|
20843
20892
|
type: "number",
|
|
20844
20893
|
inputMode: "decimal",
|
|
20845
20894
|
min: spec.min,
|
|
20846
|
-
max: spec.max,
|
|
20847
|
-
step: spec.integer === true ? 1 : 0.1,
|
|
20895
|
+
max: maxOutputLimit ?? spec.max,
|
|
20896
|
+
step: spec.integer === true ? 1 : field === "topP" ? 0.01 : 0.1,
|
|
20848
20897
|
value: draft ?? (value === void 0 ? "" : String(value)),
|
|
20849
20898
|
disabled,
|
|
20850
|
-
"aria-invalid": error62 !== void 0,
|
|
20899
|
+
"aria-invalid": error62 !== void 0 || invalid,
|
|
20851
20900
|
"aria-describedby": `${id}-hint`,
|
|
20852
20901
|
onChange: (event) => setDraft(event.target.value),
|
|
20853
20902
|
onBlur: () => {
|
|
@@ -20858,7 +20907,7 @@ function OptionalNumberField({ id, field, value, disabled, resetToken, onSave })
|
|
|
20858
20907
|
className: error62 === void 0 ? "odc-hint" : "odc-hint odc-field-error",
|
|
20859
20908
|
id: `${id}-hint`,
|
|
20860
20909
|
...error62 === void 0 ? {} : { role: "alert" }
|
|
20861
|
-
}, error62 ?? spec.hint)
|
|
20910
|
+
}, error62 ?? (restricted ? field === "temperature" ? "Messages \u4EC5\u63A5\u53D7 1\uFF1B\u5EFA\u8BAE\u7559\u7A7A\uFF0C\u4E14\u52FF\u540C\u65F6\u8BBE\u7F6E Top P\u3002" : "Messages \u4EC5\u63A5\u53D7 0.99\uFF1B\u5EFA\u8BAE\u7559\u7A7A\uFF0C\u4E14\u52FF\u540C\u65F6\u8BBE\u7F6E\u6E29\u5EA6\u3002" : maxOutputLimit !== void 0 ? `Messages \u6700\u5927\u8F93\u51FA ${maxOutputLimit}\uFF1B\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002` : spec.hint))
|
|
20862
20911
|
);
|
|
20863
20912
|
}
|
|
20864
20913
|
function EffortField({ id, model, value, disabled, onChange }) {
|
|
@@ -20913,12 +20962,17 @@ function PriceDetails({ tiers }) {
|
|
|
20913
20962
|
h("dl", null, [["\u8F93\u5165", tier.input], ["\u8F93\u51FA", tier.output], ["\u7F13\u5B58\u8BFB\u53D6", tier.cacheRead], ["\u7F13\u5B58\u5199\u5165", tier.cacheWrite]].map(([label, value]) => h("div", { key: label }, h("dt", null, label), h("dd", null, priceAmount(value, tier.currency)))))
|
|
20914
20963
|
)));
|
|
20915
20964
|
}
|
|
20916
|
-
function ModelRow({ model, settings, authoritative, writable, pending, price, priceKnown = false, onCommit }) {
|
|
20965
|
+
function ModelRow({ model, settings, authoritative, writable, pending, protocol = "chat-completions", price, priceKnown = false, onCommit }) {
|
|
20917
20966
|
const id = React.useId();
|
|
20918
20967
|
const mounted = useMounted();
|
|
20919
20968
|
const [error62, setError] = React.useState(void 0);
|
|
20920
20969
|
const [resetToken, setResetToken] = React.useState(0);
|
|
20921
20970
|
const enabled = modelEnabled(model, settings, authoritative);
|
|
20971
|
+
const imageInput = modelImageInput(model, settings);
|
|
20972
|
+
const imageInputManual = settings.imageInput !== void 0;
|
|
20973
|
+
const samplingRestricted = hasRestrictedClaudeSampling(model.id, protocol);
|
|
20974
|
+
const samplingError = claudeSamplingError(model.id, protocol, settings.temperature, settings.topP);
|
|
20975
|
+
const outputError = claudeOutputError(model.id, protocol, settings.maxTokens);
|
|
20922
20976
|
const hasOverrides = Object.keys(settings).length > 0;
|
|
20923
20977
|
const commit = async (next) => {
|
|
20924
20978
|
const saved = await onCommit(next);
|
|
@@ -20929,6 +20983,20 @@ function ModelRow({ model, settings, authoritative, writable, pending, price, pr
|
|
|
20929
20983
|
const next = { ...settings };
|
|
20930
20984
|
if (value === void 0) delete next[key];
|
|
20931
20985
|
else next[key] = value;
|
|
20986
|
+
if ((key === "temperature" || key === "topP") && value !== void 0) {
|
|
20987
|
+
const reason = claudeSamplingError(model.id, protocol, next.temperature, next.topP);
|
|
20988
|
+
if (reason !== void 0) {
|
|
20989
|
+
setError(reason);
|
|
20990
|
+
return false;
|
|
20991
|
+
}
|
|
20992
|
+
}
|
|
20993
|
+
if (key === "maxTokens" && value !== void 0) {
|
|
20994
|
+
const reason = claudeOutputError(model.id, protocol, value);
|
|
20995
|
+
if (reason !== void 0) {
|
|
20996
|
+
setError(reason);
|
|
20997
|
+
return false;
|
|
20998
|
+
}
|
|
20999
|
+
}
|
|
20932
21000
|
const output2 = next.maxTokens ?? model.maxOutputTokens;
|
|
20933
21001
|
const context = next.contextWindow ?? model.contextWindow;
|
|
20934
21002
|
if (output2 !== void 0 && context !== void 0 && output2 >= context) {
|
|
@@ -20943,6 +21011,14 @@ function ModelRow({ model, settings, authoritative, writable, pending, price, pr
|
|
|
20943
21011
|
setResetToken((token) => token + 1);
|
|
20944
21012
|
await commit(void 0);
|
|
20945
21013
|
};
|
|
21014
|
+
const restoreImageInput = async () => {
|
|
21015
|
+
if (!imageInputManual) return;
|
|
21016
|
+
const next = { ...settings };
|
|
21017
|
+
delete next.imageInput;
|
|
21018
|
+
setError(void 0);
|
|
21019
|
+
await commit(next);
|
|
21020
|
+
};
|
|
21021
|
+
const imageDisabledReason = pending ? " \xB7 \u6B63\u5728\u4FDD\u5B58" : !writable ? " \xB7 \u914D\u7F6E\u4E0D\u53EF\u5199" : "";
|
|
20946
21022
|
const facts = [
|
|
20947
21023
|
`\u4E0A\u4E0B\u6587 ${formatTokens(model.contextWindow)}`,
|
|
20948
21024
|
`\u6700\u5927\u8F93\u51FA ${formatTokens(model.maxOutputTokens)}`,
|
|
@@ -20977,11 +21053,38 @@ function ModelRow({ model, settings, authoritative, writable, pending, price, pr
|
|
|
20977
21053
|
)
|
|
20978
21054
|
),
|
|
20979
21055
|
price !== void 0 ? h("p", { className: "odc-price-summary" }, `\u5B98\u7F51\u53C2\u8003 \xB7 ${price.tiers[0].label} \xB7 \u8F93\u5165 ${priceAmount(price.tiers[0].input, price.tiers[0].currency)} / \u8F93\u51FA ${priceAmount(price.tiers[0].output, price.tiers[0].currency)} \xB7 ${priceUnit(price.tiers[0])}${price.tiers.length > 1 ? ` \xB7 \u5171 ${price.tiers.length} \u6863` : ""}`) : priceKnown ? h("p", { className: "odc-price-summary" }, "\u5B98\u7F51\u6682\u672A\u5217\u51FA\u6B64\u6A21\u578B\u4EF7\u683C") : null,
|
|
21056
|
+
h(
|
|
21057
|
+
"div",
|
|
21058
|
+
{ className: "odc-model-image" },
|
|
21059
|
+
h(Switch, {
|
|
21060
|
+
checked: imageInput,
|
|
21061
|
+
disabled: !writable || pending,
|
|
21062
|
+
label: "\u56FE\u7247\u8F93\u5165",
|
|
21063
|
+
ariaLabel: `${model.name} \u56FE\u7247\u8F93\u5165`,
|
|
21064
|
+
hint: imageInputSource(model, settings) + imageDisabledReason,
|
|
21065
|
+
onChange: (checked) => {
|
|
21066
|
+
setError(void 0);
|
|
21067
|
+
void commit({ ...settings, imageInput: checked });
|
|
21068
|
+
}
|
|
21069
|
+
}),
|
|
21070
|
+
imageInputManual ? h("button", {
|
|
21071
|
+
className: "odc-button odc-button-small",
|
|
21072
|
+
type: "button",
|
|
21073
|
+
disabled: !writable || pending,
|
|
21074
|
+
"aria-label": `${model.name} \u6062\u590D\u56FE\u7247\u8F93\u5165\u81EA\u52A8`,
|
|
21075
|
+
title: "\u4EC5\u79FB\u9664\u56FE\u7247\u8F93\u5165\u624B\u52A8\u8986\u76D6\uFF0C\u4FDD\u7559\u5176\u4ED6\u6A21\u578B\u8BBE\u7F6E",
|
|
21076
|
+
onClick: () => {
|
|
21077
|
+
void restoreImageInput();
|
|
21078
|
+
}
|
|
21079
|
+
}, "\u6062\u590D\u81EA\u52A8") : null
|
|
21080
|
+
),
|
|
20980
21081
|
h(
|
|
20981
21082
|
"details",
|
|
20982
21083
|
{ className: "odc-model-details" },
|
|
20983
21084
|
h("summary", { "aria-label": `${model.name} \u53C2\u6570\u8BBE\u7F6E${price === void 0 ? "" : "\u4E0E\u4EF7\u683C"}` }, `${price === void 0 ? "\u53C2\u6570\u8BBE\u7F6E" : "\u53C2\u6570\u4E0E\u4EF7\u683C"} \xB7 ${hasOverrides ? "\u5DF2\u81EA\u5B9A\u4E49" : "\u4F7F\u7528\u9ED8\u8BA4\u503C"}`),
|
|
20984
21085
|
h("p", { className: "odc-model-meta" }, facts),
|
|
21086
|
+
samplingRestricted && model.id === "claude-opus-4.8" ? h("p", { className: "odc-hint" }, "\u5382\u5546\u9ED8\u8BA4\u5173\u95ED\u601D\u8003\uFF0C\u9009\u62E9\u601D\u8003\u6DF1\u5EA6\u53EF\u542F\u7528\u81EA\u9002\u5E94\u601D\u8003\uFF1B\u7F51\u5173\u5B9E\u9645\u884C\u4E3A\u53EF\u80FD\u4E0D\u540C\u3002") : null,
|
|
21087
|
+
samplingRestricted && model.maxOutputTokens === void 0 && settings.maxTokens === void 0 ? h("p", { className: "odc-hint" }, "Messages \u9ED8\u8BA4\u6700\u5927\u8F93\u51FA 4096\uFF1B\u8F83\u9AD8\u601D\u8003\u6DF1\u5EA6\u53EF\u80FD\u9700\u8981\u589E\u5927\u3002") : null,
|
|
20985
21088
|
price === void 0 ? null : h(PriceDetails, { tiers: price.tiers }),
|
|
20986
21089
|
h("p", { className: "odc-hint" }, "\u6570\u503C\u79BB\u5F00\u8F93\u5165\u6846\u540E\u4FDD\u5B58\uFF0C\u7559\u7A7A\u7EE7\u627F\u9ED8\u8BA4\u3002"),
|
|
20987
21090
|
h(
|
|
@@ -20993,6 +21096,9 @@ function ModelRow({ model, settings, authoritative, writable, pending, price, pr
|
|
|
20993
21096
|
field: key,
|
|
20994
21097
|
value: settings[key],
|
|
20995
21098
|
disabled: !writable || pending,
|
|
21099
|
+
restricted: samplingRestricted && (key === "temperature" || key === "topP"),
|
|
21100
|
+
invalid: samplingError !== void 0 && settings[key] !== void 0 && (key === "temperature" || key === "topP") || key === "maxTokens" && outputError !== void 0,
|
|
21101
|
+
maxOutputLimit: samplingRestricted && key === "maxTokens" ? CLAUDE_MESSAGES_MAX_OUTPUT : void 0,
|
|
20996
21102
|
resetToken,
|
|
20997
21103
|
onSave: (value) => saveField(key, value)
|
|
20998
21104
|
})),
|
|
@@ -21014,7 +21120,7 @@ function ModelRow({ model, settings, authoritative, writable, pending, price, pr
|
|
|
21014
21120
|
error62 !== void 0 ? h("p", { className: "odc-hint odc-field-error", role: "alert" }, error62) : null
|
|
21015
21121
|
);
|
|
21016
21122
|
}
|
|
21017
|
-
function ModelGroup({ title, group, models, settingsMap, authoritative, writable, pending, onCommit, prices }) {
|
|
21123
|
+
function ModelGroup({ title, group, models, settingsMap, authoritative, writable, pending, protocol, onCommit, prices }) {
|
|
21018
21124
|
const [query, setQuery] = React.useState("");
|
|
21019
21125
|
const [expanded, setExpanded] = React.useState(false);
|
|
21020
21126
|
const id = React.useId();
|
|
@@ -21048,6 +21154,7 @@ function ModelGroup({ title, group, models, settingsMap, authoritative, writable
|
|
|
21048
21154
|
authoritative,
|
|
21049
21155
|
writable,
|
|
21050
21156
|
pending,
|
|
21157
|
+
protocol,
|
|
21051
21158
|
price: prices?.models.find((entry) => entry.id === model.id),
|
|
21052
21159
|
priceKnown: prices !== void 0 && (prices.state !== "error" || prices.stale),
|
|
21053
21160
|
onCommit: (next) => onCommit(model.id, next)
|
|
@@ -21132,8 +21239,8 @@ function Models({ status, formSnapshot, setFormField, pendingField, onRefreshMod
|
|
|
21132
21239
|
models.length === 0 ? h("p", { className: "odc-hint", role: "status" }, "\u6682\u65E0\u53EF\u7528\u6A21\u578B\uFF1B\u53EF\u5237\u65B0\u6A21\u578B\u5217\u8868\u540E\u91CD\u8BD5\u3002") : h(
|
|
21133
21240
|
"div",
|
|
21134
21241
|
{ className: "odc-model-groups" },
|
|
21135
|
-
h(ModelGroup, { title: "\u5957\u9910\u8D60\u9001\u6A21\u578B", group: "plan", models, settingsMap, authoritative, writable, pending, onCommit: commit, prices }),
|
|
21136
|
-
h(ModelGroup, { title: "\u4ED8\u8D39\u6A21\u578B", group: "paid", models, settingsMap, authoritative, writable, pending, onCommit: commit, prices })
|
|
21242
|
+
h(ModelGroup, { title: "\u5957\u9910\u8D60\u9001\u6A21\u578B", group: "plan", models, settingsMap, authoritative, writable, pending, protocol, onCommit: commit, prices }),
|
|
21243
|
+
h(ModelGroup, { title: "\u4ED8\u8D39\u6A21\u578B", group: "paid", models, settingsMap, authoritative, writable, pending, protocol, onCommit: commit, prices })
|
|
21137
21244
|
)
|
|
21138
21245
|
);
|
|
21139
21246
|
}
|
|
@@ -21345,12 +21452,13 @@ function Advanced({ status, formSnapshot, setFormField, pendingField }) {
|
|
|
21345
21452
|
)
|
|
21346
21453
|
);
|
|
21347
21454
|
}
|
|
21348
|
-
function Switch({ checked, disabled, label, hint, onChange }) {
|
|
21455
|
+
function Switch({ checked, disabled, label, ariaLabel, hint, onChange }) {
|
|
21456
|
+
const hintId = React.useId();
|
|
21349
21457
|
return h(
|
|
21350
21458
|
"label",
|
|
21351
21459
|
{ className: "odc-switch" },
|
|
21352
|
-
h("input", { type: "checkbox", checked, disabled, onChange: (event) => onChange(event.target.checked) }),
|
|
21353
|
-
h("span", null, h("span", { className: "odc-switch-text" }, label), h("small", { className: "odc-hint" }, hint))
|
|
21460
|
+
h("input", { type: "checkbox", checked, disabled, "aria-label": ariaLabel, "aria-describedby": hintId, onChange: (event) => onChange(event.target.checked) }),
|
|
21461
|
+
h("span", null, h("span", { className: "odc-switch-text" }, label), h("small", { className: "odc-hint", id: hintId }, hint))
|
|
21354
21462
|
);
|
|
21355
21463
|
}
|
|
21356
21464
|
function loginInFlight(state) {
|
package/lib/device-auth.d.ts
CHANGED
|
@@ -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.
|
|
6
|
+
export declare const DEVICE_AUTH_PLUGIN_VERSION = "0.1.12";
|
|
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;
|
|
@@ -43,7 +43,7 @@ function parseModelSettingsMap(value) {
|
|
|
43
43
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
44
44
|
const keys = Object.keys(value);
|
|
45
45
|
if (keys.length > 512) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u6700\u591A\u5141\u8BB8 512 \u4E2A\u6A21\u578B");
|
|
46
|
-
const fields = /* @__PURE__ */ new Set(["enabled", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
46
|
+
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
47
47
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
48
48
|
const out = {};
|
|
49
49
|
for (const id of keys) {
|
|
@@ -60,6 +60,10 @@ function parseModelSettingsMap(value) {
|
|
|
60
60
|
if (typeof settings.enabled !== "boolean") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 enabled \u5FC5\u987B\u662F\u5E03\u5C14\u503C");
|
|
61
61
|
parsed.enabled = settings.enabled;
|
|
62
62
|
}
|
|
63
|
+
if (settings.imageInput !== void 0) {
|
|
64
|
+
if (typeof settings.imageInput !== "boolean") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 imageInput \u5FC5\u987B\u662F\u5E03\u5C14\u503C");
|
|
65
|
+
parsed.imageInput = settings.imageInput;
|
|
66
|
+
}
|
|
63
67
|
for (const [field, max] of [["temperature", 2], ["topP", 1]]) {
|
|
64
68
|
const item = settings[field];
|
|
65
69
|
if (item === void 0) continue;
|
|
@@ -131,6 +135,12 @@ function parseEfforts(value) {
|
|
|
131
135
|
if (!Array.isArray(value) || value.length > 16) throw new Error("\u6A21\u578B\u601D\u8003\u6863\u4F4D\u683C\u5F0F\u65E0\u6548");
|
|
132
136
|
return value.map((item) => text(item, "\u601D\u8003\u6863\u4F4D", 32));
|
|
133
137
|
}
|
|
138
|
+
function parseModalities(value) {
|
|
139
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > 2) throw new Error("\u6A21\u578B\u8F93\u5165\u6A21\u6001\u683C\u5F0F\u65E0\u6548");
|
|
140
|
+
const modes = value.map((item) => member(item, ["text", "image"], "\u6A21\u578B\u8F93\u5165\u6A21\u6001"));
|
|
141
|
+
if (!modes.includes("text") || new Set(modes).size !== modes.length) throw new Error("\u6A21\u578B\u8F93\u5165\u6A21\u6001\u683C\u5F0F\u65E0\u6548");
|
|
142
|
+
return modes;
|
|
143
|
+
}
|
|
134
144
|
function member(value, allowed, label) {
|
|
135
145
|
const hit = allowed.find((candidate) => candidate === value);
|
|
136
146
|
if (hit === void 0) throw new Error(`${label} \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185`);
|
|
@@ -245,6 +255,7 @@ function parseStatusModel(value) {
|
|
|
245
255
|
name: text(value.name, "\u6A21\u578B\u540D", 128),
|
|
246
256
|
group: member(value.group, MODEL_GROUPS, "\u6A21\u578B\u5206\u7EC4"),
|
|
247
257
|
...value.enabled === void 0 ? {} : { enabled: flag(value.enabled, "\u6A21\u578B\u542F\u7528\u72B6\u6001") },
|
|
258
|
+
...value.inputModalities === void 0 ? {} : { inputModalities: parseModalities(value.inputModalities) },
|
|
248
259
|
...value.contextWindow === void 0 ? {} : { contextWindow: positiveInteger(value.contextWindow, "\u4E0A\u4E0B\u6587\u9884\u7B97", 1e8) },
|
|
249
260
|
...value.maxOutputTokens === void 0 ? {} : { maxOutputTokens: positiveInteger(value.maxOutputTokens, "\u6700\u5927\u8F93\u51FA", 1e7) },
|
|
250
261
|
...value.reasoningEfforts === void 0 ? {} : { reasoningEfforts: parseEfforts(value.reasoningEfforts) }
|
|
@@ -43,7 +43,7 @@ function parseModelSettingsMap(value) {
|
|
|
43
43
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
44
44
|
const keys = Object.keys(value);
|
|
45
45
|
if (keys.length > 512) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u6700\u591A\u5141\u8BB8 512 \u4E2A\u6A21\u578B");
|
|
46
|
-
const fields = /* @__PURE__ */ new Set(["enabled", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
46
|
+
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
47
47
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
48
48
|
const out = {};
|
|
49
49
|
for (const id of keys) {
|
|
@@ -60,6 +60,10 @@ function parseModelSettingsMap(value) {
|
|
|
60
60
|
if (typeof settings.enabled !== "boolean") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 enabled \u5FC5\u987B\u662F\u5E03\u5C14\u503C");
|
|
61
61
|
parsed.enabled = settings.enabled;
|
|
62
62
|
}
|
|
63
|
+
if (settings.imageInput !== void 0) {
|
|
64
|
+
if (typeof settings.imageInput !== "boolean") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 imageInput \u5FC5\u987B\u662F\u5E03\u5C14\u503C");
|
|
65
|
+
parsed.imageInput = settings.imageInput;
|
|
66
|
+
}
|
|
63
67
|
for (const [field, max] of [["temperature", 2], ["topP", 1]]) {
|
|
64
68
|
const item = settings[field];
|
|
65
69
|
if (item === void 0) continue;
|
|
@@ -131,6 +135,12 @@ function parseEfforts(value) {
|
|
|
131
135
|
if (!Array.isArray(value) || value.length > 16) throw new Error("\u6A21\u578B\u601D\u8003\u6863\u4F4D\u683C\u5F0F\u65E0\u6548");
|
|
132
136
|
return value.map((item) => text(item, "\u601D\u8003\u6863\u4F4D", 32));
|
|
133
137
|
}
|
|
138
|
+
function parseModalities(value) {
|
|
139
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > 2) throw new Error("\u6A21\u578B\u8F93\u5165\u6A21\u6001\u683C\u5F0F\u65E0\u6548");
|
|
140
|
+
const modes = value.map((item) => member(item, ["text", "image"], "\u6A21\u578B\u8F93\u5165\u6A21\u6001"));
|
|
141
|
+
if (!modes.includes("text") || new Set(modes).size !== modes.length) throw new Error("\u6A21\u578B\u8F93\u5165\u6A21\u6001\u683C\u5F0F\u65E0\u6548");
|
|
142
|
+
return modes;
|
|
143
|
+
}
|
|
134
144
|
function member(value, allowed, label) {
|
|
135
145
|
const hit = allowed.find((candidate) => candidate === value);
|
|
136
146
|
if (hit === void 0) throw new Error(`${label} \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185`);
|
|
@@ -245,6 +255,7 @@ function parseStatusModel(value) {
|
|
|
245
255
|
name: text(value.name, "\u6A21\u578B\u540D", 128),
|
|
246
256
|
group: member(value.group, MODEL_GROUPS, "\u6A21\u578B\u5206\u7EC4"),
|
|
247
257
|
...value.enabled === void 0 ? {} : { enabled: flag(value.enabled, "\u6A21\u578B\u542F\u7528\u72B6\u6001") },
|
|
258
|
+
...value.inputModalities === void 0 ? {} : { inputModalities: parseModalities(value.inputModalities) },
|
|
248
259
|
...value.contextWindow === void 0 ? {} : { contextWindow: positiveInteger(value.contextWindow, "\u4E0A\u4E0B\u6587\u9884\u7B97", 1e8) },
|
|
249
260
|
...value.maxOutputTokens === void 0 ? {} : { maxOutputTokens: positiveInteger(value.maxOutputTokens, "\u6700\u5927\u8F93\u51FA", 1e7) },
|
|
250
261
|
...value.reasoningEfforts === void 0 ? {} : { reasoningEfforts: parseEfforts(value.reasoningEfforts) }
|