dsh-opendesign-corouter 0.1.18 → 0.2.0
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 +6 -6
- package/lib/adapter.d.ts +5 -0
- package/lib/auth.d.ts +2 -0
- package/lib/catalog.d.ts +16 -12
- package/lib/client.d.ts +4 -4
- package/lib/client.js +73 -18
- package/lib/config.d.ts +4 -4
- package/lib/device-auth.d.ts +1 -1
- package/lib/generated/typert.host.js +29 -5
- package/lib/generated/typert.remote-client.js +29 -5
- package/lib/index.d.ts +13 -13
- package/lib/index.js +1240 -720
- package/lib/index.js.map +4 -4
- package/lib/model-catalog-snapshot.d.ts +2 -0
- package/lib/model-directory.d.ts +59 -0
- package/lib/model-discovery.d.ts +1 -1
- package/lib/model-entitlements.d.ts +44 -0
- package/lib/model-settings.d.ts +3 -0
- package/lib/protocol-options.d.ts +7 -1
- package/lib/protocols/messages.d.ts +1 -1
- package/lib/protocols/responses-replay.d.ts +6 -0
- package/lib/protocols/responses.d.ts +5 -5
- package/lib/protocols/types.d.ts +4 -0
- package/lib/reasoning.d.ts +13 -0
- package/lib/remote.d.ts +10 -3
- package/package.json +1 -1
|
@@ -37,13 +37,14 @@ function validUserCode(value) {
|
|
|
37
37
|
|
|
38
38
|
// src/protocol-options.ts
|
|
39
39
|
var API_PROTOCOL_IDS = ["chat-completions", "responses", "messages"];
|
|
40
|
+
var API_PROTOCOL_SELECTION_IDS = ["auto", ...API_PROTOCOL_IDS];
|
|
40
41
|
|
|
41
42
|
// src/model-settings.ts
|
|
42
43
|
function parseModelSettingsMap(value) {
|
|
43
44
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
44
45
|
const keys = Object.keys(value);
|
|
45
46
|
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", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "contextTier", "reasoningEffort"]);
|
|
47
|
+
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "contextTier", "reasoningEffort", "apiProtocol"]);
|
|
47
48
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
48
49
|
const out = {};
|
|
49
50
|
for (const id of keys) {
|
|
@@ -56,6 +57,10 @@ function parseModelSettingsMap(value) {
|
|
|
56
57
|
if (!fields.has(field)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u542B\u6709\u4E0D\u652F\u6301\u7684\u5B57\u6BB5");
|
|
57
58
|
}
|
|
58
59
|
const parsed = {};
|
|
60
|
+
if (settings.apiProtocol !== void 0) {
|
|
61
|
+
if (!["auto", "chat-completions", "responses", "messages"].includes(String(settings.apiProtocol))) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 apiProtocol \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
62
|
+
parsed.apiProtocol = settings.apiProtocol;
|
|
63
|
+
}
|
|
59
64
|
if (settings.enabled !== void 0) {
|
|
60
65
|
if (typeof settings.enabled !== "boolean") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 enabled \u5FC5\u987B\u662F\u5E03\u5C14\u503C");
|
|
61
66
|
parsed.enabled = settings.enabled;
|
|
@@ -274,9 +279,18 @@ function parseStatusModel(value) {
|
|
|
274
279
|
...value.inputModalities === void 0 ? {} : { inputModalities: parseModalities(value.inputModalities) },
|
|
275
280
|
...value.contextWindow === void 0 ? {} : { contextWindow: positiveInteger(value.contextWindow, "\u4E0A\u4E0B\u6587\u9884\u7B97", 1e8) },
|
|
276
281
|
...value.maxOutputTokens === void 0 ? {} : { maxOutputTokens: positiveInteger(value.maxOutputTokens, "\u6700\u5927\u8F93\u51FA", 1e7) },
|
|
277
|
-
...value.reasoningEfforts === void 0 ? {} : { reasoningEfforts: parseEfforts(value.reasoningEfforts) }
|
|
282
|
+
...value.reasoningEfforts === void 0 ? {} : { reasoningEfforts: parseEfforts(value.reasoningEfforts) },
|
|
283
|
+
...value.defaultEffort === void 0 ? {} : { defaultEffort: parseEffort(value.defaultEffort) },
|
|
284
|
+
...value.nativeProtocol === void 0 ? {} : { nativeProtocol: member(value.nativeProtocol, API_PROTOCOL_IDS, "\u539F\u751F\u534F\u8BAE") },
|
|
285
|
+
...value.effectiveProtocol === void 0 ? {} : { effectiveProtocol: member(value.effectiveProtocol, API_PROTOCOL_IDS, "\u751F\u6548\u534F\u8BAE") },
|
|
286
|
+
...value.coverage === void 0 ? {} : { coverage: member(value.coverage, ["included", "not-included", "unknown"], "\u6A21\u578B\u8BA2\u9605\u8986\u76D6") }
|
|
278
287
|
};
|
|
279
288
|
}
|
|
289
|
+
function parseEffort(value) {
|
|
290
|
+
const effort = text(value, "\u9ED8\u8BA4\u601D\u8003\u6863\u4F4D", 32);
|
|
291
|
+
if (!/^[A-Za-z][A-Za-z0-9_-]*$/u.test(effort)) throw new Error("\u9ED8\u8BA4\u601D\u8003\u6863\u4F4D\u683C\u5F0F\u65E0\u6548");
|
|
292
|
+
return effort;
|
|
293
|
+
}
|
|
280
294
|
function parseStatusConfig(value) {
|
|
281
295
|
if (!record(value)) throw new Error("\u914D\u7F6E\u89C6\u56FE\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
282
296
|
if (typeof value.apiKeyEnv !== "string" || value.apiKeyEnv.length > MAX_ENV_REF) {
|
|
@@ -290,7 +304,7 @@ function parseStatusConfig(value) {
|
|
|
290
304
|
useDesktopCredential: flag(value.useDesktopCredential, "\u684C\u9762\u767B\u5F55\u6001\u5F00\u5173"),
|
|
291
305
|
baseURL: text(value.baseURL, "\u63A8\u7406\u5730\u5740", MAX_BASE_URL),
|
|
292
306
|
apiKeyEnv,
|
|
293
|
-
...value.apiProtocol === void 0 ? {} : { apiProtocol: member(value.apiProtocol,
|
|
307
|
+
...value.apiProtocol === void 0 ? {} : { apiProtocol: member(value.apiProtocol, API_PROTOCOL_SELECTION_IDS, "\u63A8\u7406\u534F\u8BAE") },
|
|
294
308
|
...value.modelSettings === void 0 ? {} : { modelSettings: parseModelSettingsMap(value.modelSettings) },
|
|
295
309
|
...value.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: positiveInteger(value.requestTimeoutMs, "\u8BF7\u6C42\u8D85\u65F6", 36e5, 1e3) },
|
|
296
310
|
...value.streamIdleTimeoutMs === void 0 ? {} : { streamIdleTimeoutMs: positiveInteger(value.streamIdleTimeoutMs, "\u6D41\u7A7A\u95F2\u8D85\u65F6", 18e5, 1e3) },
|
|
@@ -311,7 +325,7 @@ function parseStatus(value) {
|
|
|
311
325
|
ids.add(model.id);
|
|
312
326
|
}
|
|
313
327
|
const apiKeyConfigured = flag(value.apiKeyConfigured, "\u51ED\u636E\u662F\u5426\u5C31\u7EEA");
|
|
314
|
-
const apiKeySource = value.apiKeySource === void 0 ? void 0 : member(value.apiKeySource, ["reference", "stored", "device"], "\u63A8\u7406\u51ED\u636E\u6765\u6E90");
|
|
328
|
+
const apiKeySource = value.apiKeySource === void 0 ? void 0 : member(value.apiKeySource, ["reference", "stored", "device", "desktop"], "\u63A8\u7406\u51ED\u636E\u6765\u6E90");
|
|
315
329
|
if (!apiKeyConfigured && apiKeySource !== void 0) throw new Error("\u672A\u914D\u7F6E\u51ED\u636E\u65F6\u4E0D\u80FD\u6307\u5B9A\u63A8\u7406\u51ED\u636E\u6765\u6E90");
|
|
316
330
|
return {
|
|
317
331
|
revision: text(value.revision, "\u914D\u7F6E\u7248\u672C", MAX_REVISION),
|
|
@@ -326,7 +340,17 @@ function parseStatus(value) {
|
|
|
326
340
|
models: parsed,
|
|
327
341
|
...value.modelsSource === void 0 ? {} : { modelsSource: member(value.modelsSource, ["builtin", "openai"], "\u6A21\u578B\u76EE\u5F55\u6765\u6E90") },
|
|
328
342
|
...value.modelsUpdatedAt === void 0 ? {} : { modelsUpdatedAt: isoTime(value.modelsUpdatedAt, "\u6A21\u578B\u66F4\u65B0\u65F6\u95F4") },
|
|
329
|
-
...value.modelsError === void 0 ? {} : { modelsError: text(value.modelsError, "\u6A21\u578B\u66F4\u65B0\u63D0\u793A", MAX_MESSAGE) }
|
|
343
|
+
...value.modelsError === void 0 ? {} : { modelsError: text(value.modelsError, "\u6A21\u578B\u66F4\u65B0\u63D0\u793A", MAX_MESSAGE) },
|
|
344
|
+
...value.modelEntitlements === void 0 ? {} : { modelEntitlements: parseModelEntitlements(value.modelEntitlements) }
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function parseModelEntitlements(value) {
|
|
348
|
+
if (!record(value)) throw new Error("\u6A21\u578B\u6743\u76CA\u72B6\u6001\u65E0\u6548");
|
|
349
|
+
return {
|
|
350
|
+
state: member(value.state, ["verified", "partial", "unavailable"], "\u6A21\u578B\u6743\u76CA\u72B6\u6001"),
|
|
351
|
+
...value.source === void 0 ? {} : { source: member(value.source, ["device", "desktop"], "\u6A21\u578B\u6743\u76CA\u6765\u6E90") },
|
|
352
|
+
...value.tier === void 0 ? {} : { tier: text(value.tier, "\u6A21\u578B\u6743\u76CA\u5957\u9910", 32) },
|
|
353
|
+
...value.updatedAt === void 0 ? {} : { updatedAt: isoTime(value.updatedAt, "\u6A21\u578B\u6743\u76CA\u66F4\u65B0\u65F6\u95F4") }
|
|
330
354
|
};
|
|
331
355
|
}
|
|
332
356
|
function parseTurnMonitor(value) {
|
package/lib/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
2
2
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
3
3
|
import type { TurnMonitorStatus } from './turn-monitor-status.js';
|
|
4
4
|
import { fetchModelCatalog } from './model-discovery.js';
|
|
5
|
+
import { type ModelAccount, type EntitlementResult, type ModelScope } from './model-entitlements.js';
|
|
5
6
|
import { fetchPricingSnapshot } from './pricing.js';
|
|
6
7
|
import type { CatalogModel } from './catalog.js';
|
|
7
8
|
import { readConfig, type LiveConfig } from './config.js';
|
|
8
|
-
import { resolveSession } from './auth.js';
|
|
9
|
+
import { resolveSession, readDesktopCredential, type LoginGrant } from './auth.js';
|
|
9
10
|
import { type LoginOptions } from './login.js';
|
|
10
11
|
import { type ActivationLauncherOptions } from './browser-open.js';
|
|
11
12
|
import { readQuota, type QuotaSnapshot } from './quota.js';
|
|
@@ -18,11 +19,17 @@ export declare const name = "llm-opendesign-corouter";
|
|
|
18
19
|
export declare const inject: string[];
|
|
19
20
|
export interface HostDependencies {
|
|
20
21
|
resolveSession: typeof resolveSession;
|
|
22
|
+
readDesktopCredential?: typeof readDesktopCredential;
|
|
21
23
|
readQuota: typeof readQuota;
|
|
22
24
|
readDesktopQuota: typeof readDesktopQuota;
|
|
23
25
|
fetchModels?: typeof fetchModelCatalog;
|
|
26
|
+
modelAccount?: (key: string, baseURL: string, grant: LoginGrant | undefined, useDesktop: boolean) => Promise<ModelAccount | undefined>;
|
|
27
|
+
readModelScope?: (account: ModelAccount, signal?: AbortSignal) => Promise<ModelScope>;
|
|
28
|
+
readEntitlements?: (models: readonly CatalogModel[], options?: import('./model-entitlements.js').EntitlementOptions) => Promise<EntitlementResult>;
|
|
24
29
|
fetchPrices?: typeof fetchPricingSnapshot;
|
|
25
30
|
modelsChanged?: () => void;
|
|
31
|
+
/** Offline fixtures may drive the directory lifetime explicitly. Production defaults on. */
|
|
32
|
+
modelAutoRefresh?: boolean;
|
|
26
33
|
loginOptions?: LoginOptions;
|
|
27
34
|
activationOptions?: ActivationLauncherOptions;
|
|
28
35
|
}
|
|
@@ -43,24 +50,19 @@ export declare class OpenDesignCoRouterService extends TypertRemoteService {
|
|
|
43
50
|
private _quotaController;
|
|
44
51
|
guardedTurns: number;
|
|
45
52
|
turnMonitorStatus: (() => TurnMonitorStatus) | undefined;
|
|
46
|
-
private
|
|
47
|
-
private
|
|
48
|
-
private _modelsError;
|
|
53
|
+
private readonly _directory;
|
|
54
|
+
private readonly _catalogKeys;
|
|
49
55
|
private _modelsFingerprint;
|
|
50
|
-
private _modelsEpoch;
|
|
51
|
-
private _modelsPending;
|
|
52
|
-
private _modelsController;
|
|
53
|
-
private _modelsWriteSerial;
|
|
54
|
-
private _modelsWrite;
|
|
55
56
|
private _prices;
|
|
56
57
|
private _pricesPending;
|
|
57
58
|
modelCatalog(): readonly CatalogModel[];
|
|
59
|
+
modelWorkspace(): string | undefined;
|
|
60
|
+
modelCallIdentity(): import('./model-directory.js').DirectoryCallIdentity | undefined;
|
|
61
|
+
currentModelCatalog(): Promise<readonly CatalogModel[]>;
|
|
58
62
|
constructor(ctx: Context, config: () => ReturnType<typeof readConfig>, dependencies?: HostDependencies);
|
|
59
63
|
private _credentials;
|
|
60
64
|
private _key;
|
|
61
65
|
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
66
|
/**
|
|
65
67
|
* Persist the snapshot through the Host form service.
|
|
66
68
|
* `unsupported` means no settings service is composed (nothing to report);
|
|
@@ -71,8 +73,6 @@ export declare class OpenDesignCoRouterService extends TypertRemoteService {
|
|
|
71
73
|
* and trying once more. Every other failure repeats identically and is reported immediately.
|
|
72
74
|
*/
|
|
73
75
|
private _persistModels;
|
|
74
|
-
/** Serialize snapshot writes so the newest successful refresh is the last one persisted. */
|
|
75
|
-
private _queueModelsWrite;
|
|
76
76
|
private _invalidateModels;
|
|
77
77
|
private _state;
|
|
78
78
|
private _conflict;
|