dsh-codearts 1.4.7 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import z from "@deepseek-ai/schemastery";
3
+ import "@deepseek-ai/dsh-llm";
3
4
  import { PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
4
5
  import { SettingsNamespace } from "@deepseek-ai/dsh-settings";
5
6
  import { Context } from "@deepseek-ai/cordis";
@@ -806,6 +807,13 @@ interface CodeArtsModelInfo {
806
807
  */
807
808
  contextWindowDiscovered?: number;
808
809
  maxTokens: number;
810
+ /**
811
+ * 上游声明的输出上限(用户覆盖之前的原值,issue #15)。
812
+ *
813
+ * `maxTokens` 是**生效值**:用户按模型覆盖、或进程内降档都会改它。卡片把输出上限
814
+ * 「改回跟随上游」时需要这个原值,所以只在两者不等时才带出来。
815
+ */
816
+ maxTokensDiscovered?: number;
809
817
  supportsImages: boolean;
810
818
  /**
811
819
  * 该模型可选的思考强度。
@@ -909,7 +917,13 @@ interface CodeArtsResolved {
909
917
  securityToken: string;
910
918
  }
911
919
  declare function canonicalModel(id: string): string;
912
- /** 该模型可用的 max_tokens 上限(实测值与会话内学到的更低值取小)。 */
920
+ /**
921
+ * 该模型可用的 max_tokens 上限(用户覆盖 > 实测值,再被会话内学到的更低值压住)。
922
+ *
923
+ * 用户覆盖(issue #15)就是**天花板本身**,不只是替换目录声明值:企业自定义模型的
924
+ * 实测上限是 131072,而全局 `MAX_TOKENS_CEILING` 是 65536,不给覆盖值穿透这道墙,
925
+ * 手动设置对 128K 的用例就没意义。设过头的值由降档机制(400 → 折半重发)自愈。
926
+ */
913
927
  declare function maxTokensCeilingFor(id: string): number;
914
928
  interface PreparedChatBody {
915
929
  url: string;
@@ -1007,7 +1021,8 @@ interface CodeArtsQueueStatus {
1007
1021
  * - **maxTokens 钳到该模型的实测上限**(`MEASURED_MAX_TOKENS`)。上游
1008
1022
  * `gateway/config` 给福利模型标的是 393216 / 384000,而聊天端点实测超过 65536
1009
1023
  * 就流内报 InferHub.001001005.400;DSH 会把 catalog 的 maxTokens 原样当
1010
- * max_tokens 发出去,照抄标称值等于让每个请求都失败。
1024
+ * max_tokens 发出去,照抄标称值等于让每个请求都失败。用户按模型设了覆盖值时
1025
+ * 覆盖值直接当天花板,不再被 65536 压住(issue #15)。
1011
1026
  * - contextWindow 用发现值(只影响 DSH 的上下文计量与截断余量,不影响路由);
1012
1027
  * 用户配置的按模型覆盖值与进程内学到的真实上界在这里压过发现值(issue #9)。
1013
1028
  *
@@ -1277,13 +1292,39 @@ declare class CodeArtsAccountPool {
1277
1292
  private readonly paused;
1278
1293
  /** 用户置顶的账号:选号时排在最前面,不再按「最久未用」轮它。 */
1279
1294
  private readonly preferred;
1280
- private readonly maxConcurrent;
1295
+ private maxConcurrent;
1296
+ /**
1297
+ * 按账号的上限覆盖(账号 id → 并发数,issue #16 后续)。
1298
+ *
1299
+ * 上游配额按账号算:一个号可能个人档(3 个会话)、另一个企业档(5 个)。
1300
+ * 没有覆盖的号用 `maxConcurrent` 这个默认值。
1301
+ */
1302
+ private accountCaps;
1281
1303
  private readonly now;
1282
1304
  /** 等槽位的唤醒器:槽位释放 / 池里新增账号 / 账号复活时逐个唤醒。 */
1283
1305
  private readonly waiters;
1284
1306
  constructor(ids: readonly string[], options?: PoolOptions);
1285
1307
  /** 让池与账号文档对齐:新增的进来,删掉的出去。已有账号的运行时状态保留。 */
1286
1308
  sync(ids: readonly string[]): void;
1309
+ /**
1310
+ * 调整「没有单独设置」的号的默认上限(issue #16)。
1311
+ *
1312
+ * 直接改运行时对象而不重建池:冷却、避让窗口、槽位计数都是本进程里学出来的,
1313
+ * 重建会把它们全丢掉。调大时要唤醒等槽位的请求,否则它们会睡到下一次释放。
1314
+ * 单独设过上限的号不动。
1315
+ */
1316
+ setMaxConcurrent(value: number): void;
1317
+ /**
1318
+ * 一次性替换「按账号覆盖」表(设置变更时从配置整表灌进来)。
1319
+ *
1320
+ * 表里没有的号退回默认上限;和 `setMaxConcurrent` 一样保持运行时状态不动。
1321
+ */
1322
+ setAccountCaps(caps: Readonly<Record<string, number>>): void;
1323
+ /** 单个账号设/清上限(`null` = 回到默认)。卡片上每张账号卡各有一枚加减器。 */
1324
+ setAccountCap(id: string, value: number | null): void;
1325
+ /** 当前按账号覆盖表的副本(状态接口给卡片按号显示)。 */
1326
+ accountCapOverrides(): Record<string, number>;
1327
+ private applyCaps;
1287
1328
  list(): AccountRuntime[];
1288
1329
  get(id: string): AccountRuntime | undefined;
1289
1330
  /** 账号本身可用(没被禁用、不在冷却中)。 */
@@ -1675,10 +1716,21 @@ declare function createCodeArtsShim(options: CodeArtsShimOptions): CodeArtsShim;
1675
1716
  //#region src/adapter.d.ts
1676
1717
  /** Provider route this bundle owns. Keep in sync with cordis.patch.yml. */
1677
1718
  declare const CODEARTS_PROVIDER = "codearts";
1719
+ /** 用户在 `llm-codearts.config.retryPolicy` 里可调的三个旋钮。 */
1720
+ interface CodeArtsRetryPolicyConfig {
1721
+ /** 首次请求之后最多重试几次(默认 8,覆盖 30s 冷却窗)。 */
1722
+ maxRetries?: number;
1723
+ /** 首档退避毫秒数(默认 500)。 */
1724
+ initialDelayMs?: number;
1725
+ /** 单档退避上限毫秒数(默认 10000)。 */
1726
+ maxDelayMs?: number;
1727
+ }
1678
1728
  interface CodeArtsAdapterOptions {
1679
1729
  shim: CodeArtsShim;
1680
1730
  catalog: CodeArtsCatalog;
1681
1731
  enabledModels?: () => readonly string[] | undefined;
1732
+ /** issue #14 的 `retryPolicy` 配置;缺省按默认预算(8 次)注册。 */
1733
+ retryPolicy?: CodeArtsRetryPolicyConfig;
1682
1734
  resolveAttachments?: () => AttachmentStore | undefined;
1683
1735
  }
1684
1736
  interface CodeArtsAdapter {
@@ -1870,6 +1922,43 @@ interface Config {
1870
1922
  * 进程内按实测学到的上界仍会在此基础上继续往下钳。
1871
1923
  */
1872
1924
  contextWindowOverrides?: Record<string, number>;
1925
+ /**
1926
+ * 按模型 id 强制覆盖 `maxTokens`(单次输出上限,id 大小写不敏感,issue #15)。
1927
+ *
1928
+ * 企业自定义模型实测能到 128K,而插件全局天花板是 65536(2026-09-30 对福利模型
1929
+ * 实测的值)。覆盖值直接作为该模型的天花板、可越过那道墙;设过头的值仍由
1930
+ * 「400 → 折半重发」的降档机制自愈。
1931
+ */
1932
+ maxTokensOverrides?: Record<string, number>;
1933
+ /**
1934
+ * 每个账号的本地并发上限(issue #16),缺省 2。
1935
+ *
1936
+ * 上游会话槽位随套餐不同:个人免费档实测 3、企业版实测 5(上游报错原话
1937
+ * 「并发会话数已达上限(5个)」)。默认留 1 个给 CodeArts 网页端,所以是 3−1;
1938
+ * 企业档用户调大才能用上闲置的并行槽位。改完立即生效,无需重启。
1939
+ */
1940
+ maxConcurrentPerAccount?: number;
1941
+ /**
1942
+ * 按**账号**覆盖并发上限(账号 id → 并发数,issue #16 后续)。
1943
+ *
1944
+ * 上游配额按账号算:一个号可能个人档(3 个会话)、另一个企业档(5 个)。
1945
+ * 没写在这里的号用 `maxConcurrentPerAccount`(默认 2)。卡片上每张账号卡各有一个
1946
+ * −/+,改的就是这张表;也可以直接写配置。
1947
+ */
1948
+ maxConcurrentOverrides?: Record<string, number>;
1949
+ /**
1950
+ * 宿主的请求重试预算(issue #14)。
1951
+ *
1952
+ * 账号撞上软限流/5xx 会被冷却 30s,期间所有请求回 429 交给宿主重试。宿主的
1953
+ * 默认预算(5 次指数退避 ≈15.5s)跨不过前段 30s 窗口,会变成可见的轮次失败;
1954
+ * 插件默认已对齐到 8 次(≈45.5s),这里允许按需调整。值在注册 provider 时被
1955
+ * 宿主快照,改了要重载插件才生效。
1956
+ */
1957
+ retryPolicy?: {
1958
+ maxRetries?: number;
1959
+ initialDelayMs?: number;
1960
+ maxDelayMs?: number;
1961
+ };
1873
1962
  /** 对话输入框下方那行「积分 N」是否显示。缺省 = 显示(老配置不改行为)。 */
1874
1963
  showCreditDock?: boolean;
1875
1964
  /** 等上游开流时那行「排队第 N 位」是否显示。缺省 = 显示。 */