@eddyskywalker/dsh-chatgpt-subscription 0.38.0 → 0.38.1
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/CHANGELOG.md +12 -0
- package/README.md +3 -3
- package/lib/index.js +266 -168
- package/lib/types/host/kimi-code/adapter.d.ts.map +1 -1
- package/lib/types/host/kimi-code/mapper.d.ts +28 -19
- package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
- package/lib/types/host/kimi-code/model-catalog.d.ts +32 -0
- package/lib/types/host/kimi-code/model-catalog.d.ts.map +1 -1
- package/lib/types/host/kimi-code/types.d.ts +38 -1
- package/lib/types/host/kimi-code/types.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.38.1 - 2026-10-24
|
|
6
|
+
- **[kimi-code] 请求体上限改成按模型分档:1M 档 8 MiB、256K 档 2 MiB(`DSH_KIMI_CODE_MAX_BODY_BYTES` 仍是全局强制覆盖)**
|
|
7
|
+
- **现象**:1M 上下文档位(`k3` / `k3.1-pro` / `k3.1-pro-highspeed` / `kimi-for-coding`)的会话把中文正文写到 3–4 MB 就被本线路的本地字节守卫拒绝,请求根本没发出去;宿主压缩也救不回来——压缩请求自己同样超过那个上限,于是长会话表现为「压缩一次后仍然失败」,而服务端从未拒绝过这个体积。
|
|
8
|
+
- **根因**:这条线路对**所有**模型套用同一个 `MAX_MESSAGE_BODY_BYTES`(2,097,152)。该数字来自官方错误参考里的通用示例(`total message size N exceeds limit 2097152`),**从未针对 1M 上下文档位实测**;而 1M 窗口的正文按英文约 4 MB、按密集中文约 4.5 MB,2 MB 必然先到。官方 `kimi-cli` 全仓库没有字节守卫,说明这个上限至少不是客户端必需的。
|
|
9
|
+
- **改法(分档)**:`model-catalog.ts` 的 `KimiCodeCatalogModel` 新增必填字段 `maxRequestBodyBytes`:`k3` / `k3.1-pro` / `k3.1-pro-highspeed` / `kimi-for-coding` = **8 MiB(8,388,608)**,`k3-256k` / `kimi-for-coding-highspeed` = **2 MiB(2,097,152,保持原值)**。8 MiB 的依据是「1M 窗口的正文大小」:一个 1M token 的请求体按英文约 4 MB、按密集中文约 4.5 MB,8 MiB 留出近一倍余量,所以**字节上限不会成为 1M 会话的实际瓶颈**;真正先到的是模型自身的 token 窗口——服务端回 `Your request exceeded model token limit`,该措辞已被 `common/context-overflow.ts` 归一到 `CONTEXT_WINDOW_EXCEEDED`,压缩与重试照旧生效。8 MiB 仍是**待实测的上界**,不是文档写明的网关上限。
|
|
10
|
+
- **改法(代码)**:`types.ts` 新增 `LONG_CONTEXT_MESSAGE_BODY_BYTES`(8 × 1024 × 1024,常量定义在 `model-catalog.ts`、由 `types.ts` 重新导出,避免 ESM 循环)与 `maxRequestBodyBytesFor(model, env)`,优先级为 **env → `model.maxRequestBodyBytes` → `DEFAULT_MAX_MESSAGE_BODY_BYTES`**(注册表不认识的 id 走最保守的 2 MiB);`maxMessageBodyBytes(env)` 与其语义**原样保留**(无模型上下文的调用方仍拿 2 MiB)。`mapper.ts` 的 `assertRequestBodyFits(body, carriesVideo = false, context?, limit?)` 新增可选 `limit`,拒绝文案引用生效上限,不传时逐字节等于旧行为。`adapter.ts` 的 `bodyLimit` 改为 `carriesVideo ? MAX_VIDEO_MESSAGE_BODY_BYTES : maxRequestBodyBytesFor(<该模型的注册表行>, process.env)`,并把这个 `bodyLimit` **显式传给两处** `assertRequestBodyFits`——此前这两处各自又算一遍上限,模型档位根本到不了守卫。注册表行按 id 从 `model-catalog.ts` 取,而不是直接用线上 `/v1/models` 的条目:线上目录只报能力、从不报字节额度。
|
|
11
|
+
- **改法(env)**:`DSH_KIMI_CODE_MAX_BODY_BYTES` 仍是**全局强制覆盖、优先级最高**;空串、非有限、`0`、负数一律回落到**该模型的默认值**而不是关闭守卫(合法值会 floor,前后空格容忍)。视频档 `MAX_VIDEO_MESSAGE_BODY_BYTES`(64 MiB)不受影响。
|
|
12
|
+
- **测试**:新增 `test/kimi-code-body-limit-per-model.test.ts`(16 例)——六个条目的 `maxRequestBodyBytes` 逐一切值(8 MiB ×4 / 2 MiB ×2)、8 MiB 对两种 1M 正文密度都留有余量、resolver 的三级优先级(env 双向覆盖、模型行、未知 id 回落 2 MiB、小数 floor、空白容忍)、非法值(`''`、纯空白、`abc`、`0`、`-1`、`-2097152`、`NaN`、`huge`)回落到模型默认值而不关守卫、端到端 3.5 MB 在 `k3.1-pro` 上**能发出**(fetch 调用 1 次)而在 `k3-256k` 上被拒(fetch 0 次、文案含 `2097152`、码为 `CONTEXT_WINDOW_EXCEEDED`)、4.5 MB 能发、8.5 MB 被拒且文案含 `8388608`、env 强制把 1M 档按回 2 MiB、env 拼错仍拒、13 MB 视频照旧走 64 MiB 档、以及 `assertRequestBodyFits(body)` 无参调用仍按 2 MiB 抛错。另修正两处**依赖旧的全局 2 MB**的既有用例(**没有删任何断言**):`kimi-code-capacity.test.ts` 的「2.1 MB 请求本地即拒」与 `kimi-code-adapter.test.ts` 的「不做没做过的省略」改跑 `k3-256k`——那两处的体积仍在该档 2 MB 之上,测的行为(本地拒绝、码、文案、fetch 零调用)一条未减。
|
|
13
|
+
- **验证**:`npm run typecheck` 三工程 0 错误(退出码 0);`npx vitest run test/kimi-code**` 34 文件 / 512 例全绿;全量 `npm test` 282 文件通过 / 2 skipped、4649 passed / 8 skipped / 0 failed;`npm run build` 通过。
|
|
14
|
+
- **文档**:README 的 Kimi Code 小节把「请求体超 2 MB 本地即拒绝」改写成「按模型分档:1M 档 8 MiB / 256K 档 2 MiB」,写明 8 MiB 是待实测上界与该口径的推导、env 仍为全局覆盖且非法值回落,「上下文窗口」段落与错误处理总表里的 2 MB 措辞同步更新,并注明 `DSH_KIMI_CODE_BYTES_PER_TOKEN` 的折算基准**刻意仍是不随模型变动的 2 MiB**。
|
|
15
|
+
- **已知边界**:`DSH_KIMI_CODE_BYTES_PER_TOKEN` 的窗口折算仍以那个与模型无关的 2 MiB(设了 env 则取 env)为基准,不跟随按模型档位——它是可选的提前压缩开关而不是守卫,本次刻意不动;不想提前压缩时不设该变量即可(默认就是不设)。
|
|
16
|
+
|
|
5
17
|
## 0.38.0 - 2026-10-24
|
|
6
18
|
- **[kimi-code] 新增 K3.1 Pro 系列(与其它模型同一 OpenAI 兼容 chat completions)、只支持思考的档位、以及缓存写入这个计费项**
|
|
7
19
|
- **现象**:`k3.1-pro` / `k3.1-pro-highspeed` 不在模型目录、设置卡与能力表里;「默认思考档位」永远列着 `low` / `high` / `max` 与「关闭思考」,而 K3.1 Pro 根本关不掉(服务端 400);缓存区块只有命中率、命中 / 新处理 / 输出 tokens 与请求数,**写入**这个独立计费项一个数字都没有,看不出 5m / 1h 两档各写了多少。
|
package/README.md
CHANGED
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
- **K3.1 Pro 只支持思考模式**:关闭思考(`none`)会被服务端以 `400` 拒绝,所以它的档位只有 `low` / `high` / `max`、默认 `max`;「默认思考档位」下拉只列出勾选模型真正声明的档位,任一勾选模型允许关闭思考时它才出现,被拒时卡片上直接写明原因;
|
|
130
130
|
- **本线路对全部模型使用 OpenAI 兼容 chat completions**(与官方 agent 的 `type = "kimi"` 一致):K3.1 Pro 系列与其它模型同一协议、同一端点(`/v1/chat/completions`),Anthropic Messages 只在实时目录为某个 id 声明时启用;视频输入按官方型号表声明走,K3.1 Pro 系列可用;
|
|
131
131
|
- **K3 的长思考不会被截断**:输出上限跟随上下文窗口(保留 4096 余量),因为 `reasoning_content` 计入输出,固定 32K 会把 `max` 档的长推理中途截断并返回 `length`;调用方已知 prompt 规模时上限会被下调到放得下,未知时不做猜测;
|
|
132
|
-
-
|
|
132
|
+
- **请求体上限按模型分档:1M 档 8 MiB / 256K 档 2 MiB,本地即拒绝**:该端点最常见的 400 是 `total message size N exceeds limit 2097152`,但 `2,097,152` 来自官方文档的通用错误示例,**从未针对 1M 上下文档位实测**——1M 档的真实会话(中文正文 3–4 MB)会被本地守卫提前拦下,而宿主压缩也救不回来(压缩请求自己同样超限);官方 `kimi-cli` 全仓库没有字节守卫,说明这个上限至少不是客户端必需的。现在按模型档位:`k3` / `k3.1-pro` / `k3.1-pro-highspeed` / `kimi-for-coding` = **8 MiB(8,388,608,待实测的上界)**,`k3-256k` / `kimi-for-coding-highspeed` = **2 MiB(保持原值,窗口与上限本就对齐)**。8 MiB 的依据是「1M 窗口的正文大小」:一个 1M token 的请求体按英文约 4 MB、按密集中文约 4.5 MB,8 MiB 留出近一倍余量,所以**字节上限不会成为 1M 会话的实际瓶颈**;真正先到的是模型自身的 token 窗口——服务端回 `Your request exceeded model token limit`,该措辞已被 `common/context-overflow.ts` 归一到 `CONTEXT_WINDOW_EXCEEDED`,压缩与重试照旧生效。拦截仍按真实序列化体积,并按「循环实际做了什么」给出处方(有图可丢但丢了也补不上缺口 / 图已丢完仍超限 / 本来无图,三种情况文案不同,不再声称发生了没发生的省略);`DSH_KIMI_CODE_MAX_BODY_BYTES` 仍是**全局强制覆盖、优先级最高**,确有实测上限的部署(前置代理/网关)用它指定该档上限,取值非正整数时**回落到该模型的默认值而不是关闭守卫**;带视频的请求走 64 MiB 档,不受该变量影响;**超限时报的是可恢复的溢出码**(`CONTEXT_WINDOW_EXCEEDED`):DSH 会对该码强制压缩本轮历史并重试同一步,所以长会话的表现是「压缩一次后继续」,而不是整轮失败——官方 `kimi-cli` 从不特殊处理 `2097152`,它靠 85% 提前压缩避开,详见下文「上下文窗口」那条;
|
|
133
133
|
- **缓存是自动的,且无法手动干预**:
|
|
134
134
|
- Kimi 按请求内容哈希命中前缀缓存。实测 `prompt_cache_key` 与 Anthropic `cache_control` 标记**均被忽略**(设与不设、同 key 与异 key 命中的是同一缓存),设备 id 与协议切换也不影响;
|
|
135
135
|
- TTL 实测在 300–1800 秒之间,按 256 token 对齐;`/messages` 与 `/chat/completions` **共享同一缓存**;
|
|
@@ -548,7 +548,7 @@ DSH 设置页的「Subagent」卡片会把勾选的模型写成会话级的允
|
|
|
548
548
|
|
|
549
549
|
`kimi-code` 会像其他 Provider 一样出现在 DSH 模型选择器中。**上下文窗口**默认取模型目录值,可逐模型覆盖(用于 DSH 的压缩与溢出判断,支持 `1M` / `256K` / `200000` 等写法)——注意 `k3` 的 1M 上下文需要 Allegretto 及以上套餐,因此默认按 256K 计算,升级后再在此覆盖为 1M。
|
|
550
550
|
|
|
551
|
-
**申报的窗口默认就是目录值或你的覆盖值,不做折算**——`k3` 覆盖成 1M 就按 1M
|
|
551
|
+
**申报的窗口默认就是目录值或你的覆盖值,不做折算**——`k3` 覆盖成 1M 就按 1M 申报。撞上本档请求体上限时(1M 档 8 MiB、256K 档 2 MiB,见上一条),本地守卫抛的是 `CONTEXT_WINDOW_EXCEEDED`:DSH 会对该码**自动压缩本轮历史并重试同一步**,所以表现是「压缩一次后继续」,不是整轮失败。想要「撞墙之前就自动压缩」,可设 `DSH_KIMI_CODE_BYTES_PER_TOKEN` 启用窗口折算:申报值 = `min(声明值, floor(上限 / d))`——这里的「上限」是与模型无关的那个 2 MiB 守卫值(设了 `DSH_KIMI_CODE_MAX_BODY_BYTES` 则取它),它**刻意不跟随上面的按模型档位**:这个开关只决定「提前压缩落在哪里」,而真正兜底的仍是按模型档位的请求体守卫。取值按内容密度选——DSH 的 token 计量是固定密度(4 字符/token,见 `@deepseek-ai/dsh-token-meter`),看不见中文占 3 字节,所以「一个计量 token 占多少字节」= 4 × 每字符字节数:纯 ASCII 约 4、中英混合约 8、密集中文约 12;对应的字节墙分别是 524288 / 262144 / 174763 计量 token。实测:`d=4` → 524288(代码为主的会话在 1.68 MB 处压缩)、`d=8` → 262144(混合)、`d=12` → 174762(中文,三种密度都在墙前)。压力阈值是 `min(floor(0.8 × 窗口), 窗口 − 65536)`(`compaction-basic`:`thresholdRatio` 默认 0.8、`headroomTokens` 默认 65536、本线路不申报 `defaultMaxTokens` 故无输出预留)。该变量是**可选的提前压缩开关**而不是安全守卫:不设或拼错等于不启用,真正兜底的是上面那个恢复码。**默认思考档位**的选项跟随勾选模型自己声明的档位——`low` / `high` / `max`,以及在允许关闭思考的模型上才出现的「关闭思考」(服务对这些以外的取值直接报 400);K3.1 Pro 系列只支持思考模式,硬关会被拒(400),所以勾选它时这一档不出现,卡片上会写明原因;切换模型或切换档位都会使上下文缓存失效,建议在同一会话内保持一致。
|
|
552
552
|
|
|
553
553
|
**额度倍率**取自官方模型表并显示在设置页模型能力表的「说明」列(悬停可一并看到):`k3` = **2×**、`k3-256k` = **1×**、`kimi-for-coding` = **1×**、`kimi-for-coding-highspeed` = **3×**;`k3.1-pro` 与 `k3.1-pro-highspeed` 官方未公布相对倍率(后者只说了「约为常规版 2 倍」),因此显示为**未知**而不是猜成 2×。倍率绑定**模型 id**,与上下文长度、缓存命中率都无关——选 `k3` 就是 2×,哪怕只用几千 token。注册表不认识的新模型 id 显示为**未知**而不是猜成 1×。
|
|
554
554
|
|
|
@@ -1204,7 +1204,7 @@ npm pack --dry-run
|
|
|
1204
1204
|
|
|
1205
1205
|
Kimi Code、MiniMax Code、Command Code、Claude 遇到“输入加输出预留超限”时,插件可在 HTTP 400/422 的完整 token 计数证明输入仍能放下、且上游确实采用了请求输出上限的情况下,仅降低输出上限重试一次。消息、工具和历史保持不变,摘要请求也适用。降低后的输出仍可能截断,截断不会冒充完整摘要。Codex 不支持该输出参数,不走此恢复;输入本身超限、模糊错误或流内错误仍交给 Harness 处理。这不是对所有压缩故障的通用修复。
|
|
1206
1206
|
|
|
1207
|
-
MiniMax、Kimi、Codex、Claude、Command Code 和 Antigravity 的错误处理会将明确的上下文超限错误交给 Harness 的溢出恢复机制。该机制需要宿主启用压缩后端;它不是无条件重发同一个超限请求。认证、配额和输出截断不会因此被当作上下文超限。**请求体字节限制是唯一按线路区分的**:Kimi Code
|
|
1207
|
+
MiniMax、Kimi、Codex、Claude、Command Code 和 Antigravity 的错误处理会将明确的上下文超限错误交给 Harness 的溢出恢复机制。该机制需要宿主启用压缩后端;它不是无条件重发同一个超限请求。认证、配额和输出截断不会因此被当作上下文超限。**请求体字节限制是唯一按线路区分的**:Kimi Code 把「请求体超过本档上限(1M 档 8 MiB / 256K 档 2 MiB)」的本地拒绝与网关原文 `total message size N exceeds limit 2097152` 都归入该码(压缩确实能缩小请求体,实测这是长会话最常见的 400),其余线路的请求体拒绝仍按普通错误呈现。手动压缩仍需生成完整摘要;如果摘要请求本身超限、被截断或缺少正文,修正错误分类也不能保证它成功。请保留失败会话中的 `compaction/end` 错误、provider/model、宿主及插件版本,以便定位。
|
|
1208
1208
|
|
|
1209
1209
|
| 现象 | 处理 |
|
|
1210
1210
|
| --- | --- |
|
package/lib/index.js
CHANGED
|
@@ -23621,166 +23621,6 @@ var OllamaAccountPool = class extends AccountPoolCore {
|
|
|
23621
23621
|
}
|
|
23622
23622
|
};
|
|
23623
23623
|
//#endregion
|
|
23624
|
-
//#region src/host/kimi-code/model-catalog.ts
|
|
23625
|
-
/**
|
|
23626
|
-
* The ids the subscription serves today.
|
|
23627
|
-
*
|
|
23628
|
-
* `kimi-for-coding` is the alias that never changes: Moonshot upgrades the model
|
|
23629
|
-
* behind it in place (K2.7 Code became K2.8 Preview without a config change), so
|
|
23630
|
-
* this entry is the durable default a user can leave selected.
|
|
23631
|
-
*/
|
|
23632
|
-
const KIMI_CODE_MODELS = [
|
|
23633
|
-
{
|
|
23634
|
-
id: "k3",
|
|
23635
|
-
name: "K3",
|
|
23636
|
-
version: "K3",
|
|
23637
|
-
contextWindow: 262144,
|
|
23638
|
-
maxContextWindow: 1048576,
|
|
23639
|
-
maxTokens: 32768,
|
|
23640
|
-
inputModalities: [
|
|
23641
|
-
"text",
|
|
23642
|
-
"image",
|
|
23643
|
-
"video"
|
|
23644
|
-
],
|
|
23645
|
-
reasoningEfforts: [
|
|
23646
|
-
"low",
|
|
23647
|
-
"high",
|
|
23648
|
-
"max"
|
|
23649
|
-
],
|
|
23650
|
-
defaultReasoningEffort: "high",
|
|
23651
|
-
minimumPlan: "Moderato",
|
|
23652
|
-
contextPlan: "Allegretto",
|
|
23653
|
-
description: "The most capable flagship coding model: 2.8T parameters, 1M context window. The 1M context consumes about twice the quota of k3-256k.",
|
|
23654
|
-
supportsDynamicTools: true,
|
|
23655
|
-
quotaMultiplier: 2,
|
|
23656
|
-
speed: "regular"
|
|
23657
|
-
},
|
|
23658
|
-
{
|
|
23659
|
-
id: "k3-256k",
|
|
23660
|
-
name: "K3 (256K)",
|
|
23661
|
-
version: "K3",
|
|
23662
|
-
contextWindow: 262144,
|
|
23663
|
-
maxContextWindow: null,
|
|
23664
|
-
maxTokens: 32768,
|
|
23665
|
-
inputModalities: ["text", "image"],
|
|
23666
|
-
reasoningEfforts: [
|
|
23667
|
-
"low",
|
|
23668
|
-
"high",
|
|
23669
|
-
"max"
|
|
23670
|
-
],
|
|
23671
|
-
defaultReasoningEffort: "high",
|
|
23672
|
-
minimumPlan: "Moderato",
|
|
23673
|
-
contextPlan: null,
|
|
23674
|
-
description: "The 256K context version of K3, available to every Moderato member and above. Costs about half the quota of k3 with 1M context, and does not accept video input.",
|
|
23675
|
-
supportsDynamicTools: true,
|
|
23676
|
-
quotaMultiplier: 1,
|
|
23677
|
-
speed: "regular"
|
|
23678
|
-
},
|
|
23679
|
-
{
|
|
23680
|
-
id: "kimi-for-coding",
|
|
23681
|
-
name: "Kimi for Coding",
|
|
23682
|
-
version: "K2.8 Preview",
|
|
23683
|
-
contextWindow: 1048576,
|
|
23684
|
-
maxContextWindow: null,
|
|
23685
|
-
maxTokens: 32768,
|
|
23686
|
-
inputModalities: [
|
|
23687
|
-
"text",
|
|
23688
|
-
"image",
|
|
23689
|
-
"video"
|
|
23690
|
-
],
|
|
23691
|
-
reasoningEfforts: [
|
|
23692
|
-
"low",
|
|
23693
|
-
"high",
|
|
23694
|
-
"max"
|
|
23695
|
-
],
|
|
23696
|
-
defaultReasoningEffort: "max",
|
|
23697
|
-
minimumPlan: null,
|
|
23698
|
-
contextPlan: null,
|
|
23699
|
-
description: "Performance close to K3 with more efficient thinking, and up to 1M context on every plan. Good at code completion and routine development tasks.",
|
|
23700
|
-
supportsDynamicTools: true,
|
|
23701
|
-
quotaMultiplier: 1,
|
|
23702
|
-
speed: "regular"
|
|
23703
|
-
},
|
|
23704
|
-
{
|
|
23705
|
-
id: "kimi-for-coding-highspeed",
|
|
23706
|
-
name: "Kimi for Coding HighSpeed",
|
|
23707
|
-
version: "K2.7 Code HighSpeed",
|
|
23708
|
-
contextWindow: 262144,
|
|
23709
|
-
maxContextWindow: null,
|
|
23710
|
-
maxTokens: 32768,
|
|
23711
|
-
inputModalities: [
|
|
23712
|
-
"text",
|
|
23713
|
-
"image",
|
|
23714
|
-
"video"
|
|
23715
|
-
],
|
|
23716
|
-
reasoningEfforts: ["high"],
|
|
23717
|
-
defaultReasoningEffort: "high",
|
|
23718
|
-
minimumPlan: "Allegretto",
|
|
23719
|
-
contextPlan: null,
|
|
23720
|
-
description: "The high-speed version of K2.7 Code with the same coding ability and roughly 5-6x faster output, at 3x quota usage. Requires the Allegretto plan or above.",
|
|
23721
|
-
supportsDynamicTools: false,
|
|
23722
|
-
quotaMultiplier: 3,
|
|
23723
|
-
speed: "highspeed"
|
|
23724
|
-
},
|
|
23725
|
-
{
|
|
23726
|
-
id: "k3.1-pro",
|
|
23727
|
-
name: "K3.1 Pro",
|
|
23728
|
-
version: "K3.1 Pro",
|
|
23729
|
-
contextWindow: 262144,
|
|
23730
|
-
maxContextWindow: 1048576,
|
|
23731
|
-
maxTokens: 32768,
|
|
23732
|
-
inputModalities: [
|
|
23733
|
-
"text",
|
|
23734
|
-
"image",
|
|
23735
|
-
"video"
|
|
23736
|
-
],
|
|
23737
|
-
reasoningEfforts: [
|
|
23738
|
-
"low",
|
|
23739
|
-
"high",
|
|
23740
|
-
"max"
|
|
23741
|
-
],
|
|
23742
|
-
defaultReasoningEffort: "max",
|
|
23743
|
-
thinkingType: "only",
|
|
23744
|
-
minimumPlan: "Moderato",
|
|
23745
|
-
contextPlan: "Allegretto",
|
|
23746
|
-
description: "The K3.1 Pro flagship: 3T parameters, a 256K context window on Plus/Moderato and 1M on Pro/Allegretto and above. Thinking runs at low/high/max, defaults to max, and cannot be disabled.",
|
|
23747
|
-
supportsDynamicTools: true,
|
|
23748
|
-
quotaMultiplier: null,
|
|
23749
|
-
speed: "regular"
|
|
23750
|
-
},
|
|
23751
|
-
{
|
|
23752
|
-
id: "k3.1-pro-highspeed",
|
|
23753
|
-
name: "K3.1 Pro Highspeed",
|
|
23754
|
-
version: "K3.1 Pro Highspeed",
|
|
23755
|
-
contextWindow: 1048576,
|
|
23756
|
-
maxContextWindow: null,
|
|
23757
|
-
maxTokens: 32768,
|
|
23758
|
-
inputModalities: [
|
|
23759
|
-
"text",
|
|
23760
|
-
"image",
|
|
23761
|
-
"video"
|
|
23762
|
-
],
|
|
23763
|
-
reasoningEfforts: [
|
|
23764
|
-
"low",
|
|
23765
|
-
"high",
|
|
23766
|
-
"max"
|
|
23767
|
-
],
|
|
23768
|
-
defaultReasoningEffort: "max",
|
|
23769
|
-
thinkingType: "only",
|
|
23770
|
-
minimumPlan: "Allegretto",
|
|
23771
|
-
contextPlan: null,
|
|
23772
|
-
description: "The high-speed K3.1 Pro with a 1M context window and faster output, at about twice the quota of the regular version. Requires the Pro/Allegretto plan or above.",
|
|
23773
|
-
supportsDynamicTools: true,
|
|
23774
|
-
quotaMultiplier: null,
|
|
23775
|
-
speed: "highspeed"
|
|
23776
|
-
}
|
|
23777
|
-
];
|
|
23778
|
-
const BY_ID$1 = new Map(KIMI_CODE_MODELS.map((model) => [model.id, model]));
|
|
23779
|
-
/** Registry entry for one model id, or undefined when the id is unknown. */
|
|
23780
|
-
function kimiCodeModelDef(modelId) {
|
|
23781
|
-
return BY_ID$1.get(modelId.trim());
|
|
23782
|
-
}
|
|
23783
|
-
//#endregion
|
|
23784
23624
|
//#region src/host/common/request-images.ts
|
|
23785
23625
|
function isRecord$39(value) {
|
|
23786
23626
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -24174,6 +24014,194 @@ function imageBlockToInline$2(block, images) {
|
|
|
24174
24014
|
} : void 0;
|
|
24175
24015
|
}
|
|
24176
24016
|
//#endregion
|
|
24017
|
+
//#region src/host/kimi-code/model-catalog.ts
|
|
24018
|
+
/**
|
|
24019
|
+
* Request-body ceiling the 1M-context tier defaults to.
|
|
24020
|
+
*
|
|
24021
|
+
* The 2 MB figure this line used to apply to every model comes from the gateway's
|
|
24022
|
+
* generic error example and was never measured against a 1M window, while a real
|
|
24023
|
+
* 1M session (3-4 MB of Chinese prose) hits it long before the window is full.
|
|
24024
|
+
* The official kimi-cli ships no byte guard at all, so the ceiling is this
|
|
24025
|
+
* plugin's own safety net rather than a client requirement.
|
|
24026
|
+
*
|
|
24027
|
+
* 8 MiB is sized so bytes never become the binding limit for a 1M session: that
|
|
24028
|
+
* window's body is roughly 4 MB of English or 4.5 MB of dense Chinese, so 8 MiB
|
|
24029
|
+
* leaves nearly double the headroom. What binds first is the model's own token
|
|
24030
|
+
* window — the service answers "Your request exceeded model token limit", which
|
|
24031
|
+
* common/context-overflow.ts already normalizes to CONTEXT_WINDOW_EXCEEDED, so
|
|
24032
|
+
* compaction and retry behave exactly as they did before.
|
|
24033
|
+
*
|
|
24034
|
+
* The number is still an UPPER BOUND pending measurement, not a documented
|
|
24035
|
+
* gateway limit: a deployment that has measured its own gateway pins the real
|
|
24036
|
+
* figure with DSH_KIMI_CODE_MAX_BODY_BYTES. The 256K tier keeps 2 MB, where the
|
|
24037
|
+
* old ceiling and the window line up.
|
|
24038
|
+
*/
|
|
24039
|
+
const LONG_CONTEXT_MESSAGE_BODY_BYTES = 8 * 1024 * 1024;
|
|
24040
|
+
/**
|
|
24041
|
+
* The ids the subscription serves today.
|
|
24042
|
+
*
|
|
24043
|
+
* `kimi-for-coding` is the alias that never changes: Moonshot upgrades the model
|
|
24044
|
+
* behind it in place (K2.7 Code became K2.8 Preview without a config change), so
|
|
24045
|
+
* this entry is the durable default a user can leave selected.
|
|
24046
|
+
*/
|
|
24047
|
+
const KIMI_CODE_MODELS = [
|
|
24048
|
+
{
|
|
24049
|
+
id: "k3",
|
|
24050
|
+
name: "K3",
|
|
24051
|
+
version: "K3",
|
|
24052
|
+
contextWindow: 262144,
|
|
24053
|
+
maxContextWindow: 1048576,
|
|
24054
|
+
maxTokens: 32768,
|
|
24055
|
+
maxRequestBodyBytes: LONG_CONTEXT_MESSAGE_BODY_BYTES,
|
|
24056
|
+
inputModalities: [
|
|
24057
|
+
"text",
|
|
24058
|
+
"image",
|
|
24059
|
+
"video"
|
|
24060
|
+
],
|
|
24061
|
+
reasoningEfforts: [
|
|
24062
|
+
"low",
|
|
24063
|
+
"high",
|
|
24064
|
+
"max"
|
|
24065
|
+
],
|
|
24066
|
+
defaultReasoningEffort: "high",
|
|
24067
|
+
minimumPlan: "Moderato",
|
|
24068
|
+
contextPlan: "Allegretto",
|
|
24069
|
+
description: "The most capable flagship coding model: 2.8T parameters, 1M context window. The 1M context consumes about twice the quota of k3-256k.",
|
|
24070
|
+
supportsDynamicTools: true,
|
|
24071
|
+
quotaMultiplier: 2,
|
|
24072
|
+
speed: "regular"
|
|
24073
|
+
},
|
|
24074
|
+
{
|
|
24075
|
+
id: "k3-256k",
|
|
24076
|
+
name: "K3 (256K)",
|
|
24077
|
+
version: "K3",
|
|
24078
|
+
contextWindow: 262144,
|
|
24079
|
+
maxContextWindow: null,
|
|
24080
|
+
maxTokens: 32768,
|
|
24081
|
+
maxRequestBodyBytes: MAX_MESSAGE_BODY_BYTES,
|
|
24082
|
+
inputModalities: ["text", "image"],
|
|
24083
|
+
reasoningEfforts: [
|
|
24084
|
+
"low",
|
|
24085
|
+
"high",
|
|
24086
|
+
"max"
|
|
24087
|
+
],
|
|
24088
|
+
defaultReasoningEffort: "high",
|
|
24089
|
+
minimumPlan: "Moderato",
|
|
24090
|
+
contextPlan: null,
|
|
24091
|
+
description: "The 256K context version of K3, available to every Moderato member and above. Costs about half the quota of k3 with 1M context, and does not accept video input.",
|
|
24092
|
+
supportsDynamicTools: true,
|
|
24093
|
+
quotaMultiplier: 1,
|
|
24094
|
+
speed: "regular"
|
|
24095
|
+
},
|
|
24096
|
+
{
|
|
24097
|
+
id: "kimi-for-coding",
|
|
24098
|
+
name: "Kimi for Coding",
|
|
24099
|
+
version: "K2.8 Preview",
|
|
24100
|
+
contextWindow: 1048576,
|
|
24101
|
+
maxContextWindow: null,
|
|
24102
|
+
maxTokens: 32768,
|
|
24103
|
+
maxRequestBodyBytes: LONG_CONTEXT_MESSAGE_BODY_BYTES,
|
|
24104
|
+
inputModalities: [
|
|
24105
|
+
"text",
|
|
24106
|
+
"image",
|
|
24107
|
+
"video"
|
|
24108
|
+
],
|
|
24109
|
+
reasoningEfforts: [
|
|
24110
|
+
"low",
|
|
24111
|
+
"high",
|
|
24112
|
+
"max"
|
|
24113
|
+
],
|
|
24114
|
+
defaultReasoningEffort: "max",
|
|
24115
|
+
minimumPlan: null,
|
|
24116
|
+
contextPlan: null,
|
|
24117
|
+
description: "Performance close to K3 with more efficient thinking, and up to 1M context on every plan. Good at code completion and routine development tasks.",
|
|
24118
|
+
supportsDynamicTools: true,
|
|
24119
|
+
quotaMultiplier: 1,
|
|
24120
|
+
speed: "regular"
|
|
24121
|
+
},
|
|
24122
|
+
{
|
|
24123
|
+
id: "kimi-for-coding-highspeed",
|
|
24124
|
+
name: "Kimi for Coding HighSpeed",
|
|
24125
|
+
version: "K2.7 Code HighSpeed",
|
|
24126
|
+
contextWindow: 262144,
|
|
24127
|
+
maxContextWindow: null,
|
|
24128
|
+
maxTokens: 32768,
|
|
24129
|
+
maxRequestBodyBytes: MAX_MESSAGE_BODY_BYTES,
|
|
24130
|
+
inputModalities: [
|
|
24131
|
+
"text",
|
|
24132
|
+
"image",
|
|
24133
|
+
"video"
|
|
24134
|
+
],
|
|
24135
|
+
reasoningEfforts: ["high"],
|
|
24136
|
+
defaultReasoningEffort: "high",
|
|
24137
|
+
minimumPlan: "Allegretto",
|
|
24138
|
+
contextPlan: null,
|
|
24139
|
+
description: "The high-speed version of K2.7 Code with the same coding ability and roughly 5-6x faster output, at 3x quota usage. Requires the Allegretto plan or above.",
|
|
24140
|
+
supportsDynamicTools: false,
|
|
24141
|
+
quotaMultiplier: 3,
|
|
24142
|
+
speed: "highspeed"
|
|
24143
|
+
},
|
|
24144
|
+
{
|
|
24145
|
+
id: "k3.1-pro",
|
|
24146
|
+
name: "K3.1 Pro",
|
|
24147
|
+
version: "K3.1 Pro",
|
|
24148
|
+
contextWindow: 262144,
|
|
24149
|
+
maxContextWindow: 1048576,
|
|
24150
|
+
maxTokens: 32768,
|
|
24151
|
+
maxRequestBodyBytes: LONG_CONTEXT_MESSAGE_BODY_BYTES,
|
|
24152
|
+
inputModalities: [
|
|
24153
|
+
"text",
|
|
24154
|
+
"image",
|
|
24155
|
+
"video"
|
|
24156
|
+
],
|
|
24157
|
+
reasoningEfforts: [
|
|
24158
|
+
"low",
|
|
24159
|
+
"high",
|
|
24160
|
+
"max"
|
|
24161
|
+
],
|
|
24162
|
+
defaultReasoningEffort: "max",
|
|
24163
|
+
thinkingType: "only",
|
|
24164
|
+
minimumPlan: "Moderato",
|
|
24165
|
+
contextPlan: "Allegretto",
|
|
24166
|
+
description: "The K3.1 Pro flagship: 3T parameters, a 256K context window on Plus/Moderato and 1M on Pro/Allegretto and above. Thinking runs at low/high/max, defaults to max, and cannot be disabled.",
|
|
24167
|
+
supportsDynamicTools: true,
|
|
24168
|
+
quotaMultiplier: null,
|
|
24169
|
+
speed: "regular"
|
|
24170
|
+
},
|
|
24171
|
+
{
|
|
24172
|
+
id: "k3.1-pro-highspeed",
|
|
24173
|
+
name: "K3.1 Pro Highspeed",
|
|
24174
|
+
version: "K3.1 Pro Highspeed",
|
|
24175
|
+
contextWindow: 1048576,
|
|
24176
|
+
maxContextWindow: null,
|
|
24177
|
+
maxTokens: 32768,
|
|
24178
|
+
maxRequestBodyBytes: LONG_CONTEXT_MESSAGE_BODY_BYTES,
|
|
24179
|
+
inputModalities: [
|
|
24180
|
+
"text",
|
|
24181
|
+
"image",
|
|
24182
|
+
"video"
|
|
24183
|
+
],
|
|
24184
|
+
reasoningEfforts: [
|
|
24185
|
+
"low",
|
|
24186
|
+
"high",
|
|
24187
|
+
"max"
|
|
24188
|
+
],
|
|
24189
|
+
defaultReasoningEffort: "max",
|
|
24190
|
+
thinkingType: "only",
|
|
24191
|
+
minimumPlan: "Allegretto",
|
|
24192
|
+
contextPlan: null,
|
|
24193
|
+
description: "The high-speed K3.1 Pro with a 1M context window and faster output, at about twice the quota of the regular version. Requires the Pro/Allegretto plan or above.",
|
|
24194
|
+
supportsDynamicTools: true,
|
|
24195
|
+
quotaMultiplier: null,
|
|
24196
|
+
speed: "highspeed"
|
|
24197
|
+
}
|
|
24198
|
+
];
|
|
24199
|
+
const BY_ID$1 = new Map(KIMI_CODE_MODELS.map((model) => [model.id, model]));
|
|
24200
|
+
/** Registry entry for one model id, or undefined when the id is unknown. */
|
|
24201
|
+
function kimiCodeModelDef(modelId) {
|
|
24202
|
+
return BY_ID$1.get(modelId.trim());
|
|
24203
|
+
}
|
|
24204
|
+
//#endregion
|
|
24177
24205
|
//#region src/host/kimi-code/types.ts
|
|
24178
24206
|
const PROVIDER_ID$8 = "kimi-code";
|
|
24179
24207
|
const PROVIDER_NAME$7 = "Kimi Code";
|
|
@@ -24274,9 +24302,22 @@ function openAIUrl(suffix, region = "mainland-cn") {
|
|
|
24274
24302
|
* spanning both tiers could not express "relax the text ceiling, leave the video
|
|
24275
24303
|
* one alone", and a value chosen for a 2 MB conversation would collapse the video
|
|
24276
24304
|
* tier with it. MiniMax's video budget is likewise a bare constant.
|
|
24305
|
+
*
|
|
24306
|
+
* The text/image tier is now graded by model: this constant is what the 256K
|
|
24307
|
+
* models keep and what an unknown model falls back to, while the 1M models
|
|
24308
|
+
* declare their own, larger ceiling in the registry. {@link maxRequestBodyBytesFor}
|
|
24309
|
+
* is the resolver that applies that grade.
|
|
24277
24310
|
*/
|
|
24278
24311
|
const DEFAULT_MAX_MESSAGE_BODY_BYTES$1 = MAX_MESSAGE_BODY_BYTES;
|
|
24279
|
-
/**
|
|
24312
|
+
/**
|
|
24313
|
+
* Ceiling this process enforces when the caller has no model to key on.
|
|
24314
|
+
*
|
|
24315
|
+
* Kept alongside {@link maxRequestBodyBytesFor} rather than folded into it: this
|
|
24316
|
+
* is the answer for "what does this deployment allow at all", which the video
|
|
24317
|
+
* budget and the settings reporting paths need without naming a model. A request
|
|
24318
|
+
* that DOES name one goes through the per-model resolver below, so a 1M-tier
|
|
24319
|
+
* session gets its own tier instead of this floor.
|
|
24320
|
+
*/
|
|
24280
24321
|
function maxMessageBodyBytes$1(env = process.env) {
|
|
24281
24322
|
const raw = (env.DSH_KIMI_CODE_MAX_BODY_BYTES ?? "").trim();
|
|
24282
24323
|
if (raw === "") return DEFAULT_MAX_MESSAGE_BODY_BYTES$1;
|
|
@@ -24285,6 +24326,35 @@ function maxMessageBodyBytes$1(env = process.env) {
|
|
|
24285
24326
|
return Math.floor(parsed);
|
|
24286
24327
|
}
|
|
24287
24328
|
/**
|
|
24329
|
+
* Request-body ceiling for one model, in precedence order.
|
|
24330
|
+
*
|
|
24331
|
+
* The middleware gateway that rejects a body is shared and the sessions are not:
|
|
24332
|
+
* a 1M-tier session produces several megabytes of conversation the 256K tier
|
|
24333
|
+
* cannot, so one number for both either starves the long tier or leaves the
|
|
24334
|
+
* short one unguarded. Hence three sources, highest priority first:
|
|
24335
|
+
*
|
|
24336
|
+
* 1. DSH_KIMI_CODE_MAX_BODY_BYTES — a measured figure for THIS deployment, so it
|
|
24337
|
+
* wins over every per-model default. It still has to be a positive integer:
|
|
24338
|
+
* a typo falls through to the model's own default rather than switching the
|
|
24339
|
+
* guard off, which is the one failure this variable must never cause;
|
|
24340
|
+
* 2. the model's {@link KimiCodeCatalogModel.maxRequestBodyBytes};
|
|
24341
|
+
* 3. {@link DEFAULT_MAX_MESSAGE_BODY_BYTES}, for a model the registry does not
|
|
24342
|
+
* know — an unknown id keeps the most conservative ceiling rather than
|
|
24343
|
+
* inheriting a long-context allowance nothing has vouched for.
|
|
24344
|
+
*
|
|
24345
|
+
* @param model the registry row for the model being called, or undefined when
|
|
24346
|
+
* the id is not one this route ships.
|
|
24347
|
+
* @param env environment the override is read from, injectable for tests.
|
|
24348
|
+
*/
|
|
24349
|
+
function maxRequestBodyBytesFor(model, env = process.env) {
|
|
24350
|
+
const raw = (env.DSH_KIMI_CODE_MAX_BODY_BYTES ?? "").trim();
|
|
24351
|
+
if (raw !== "") {
|
|
24352
|
+
const parsed = Number(raw);
|
|
24353
|
+
if (Number.isFinite(parsed) && parsed > 0) return Math.floor(parsed);
|
|
24354
|
+
}
|
|
24355
|
+
return model?.maxRequestBodyBytes ?? DEFAULT_MAX_MESSAGE_BODY_BYTES$1;
|
|
24356
|
+
}
|
|
24357
|
+
/**
|
|
24288
24358
|
* Bytes one METERED token is assumed to occupy when a deployment asks this route
|
|
24289
24359
|
* to fold its published window against the byte ceiling.
|
|
24290
24360
|
*
|
|
@@ -27789,12 +27859,40 @@ function buildRequest(options, wire, images = NO_RESOLVED_IMAGES$3, preserveThin
|
|
|
27789
27859
|
recordDriftCause(trackPrefixStability(options), options.sessionId);
|
|
27790
27860
|
return wire === "anthropic" ? buildAnthropicRequest(options, images, media) : buildOpenAIRequest(options, images, preserveThinking, media);
|
|
27791
27861
|
}
|
|
27792
|
-
|
|
27862
|
+
/**
|
|
27863
|
+
* Reject a request the service would refuse for its size.
|
|
27864
|
+
*
|
|
27865
|
+
* This is the most frequently reported 400 on the coding endpoint, and it is
|
|
27866
|
+
* worth catching locally for two reasons: the message can name the actual
|
|
27867
|
+
* remedy (DSH's compaction), and a request that cannot succeed should not be
|
|
27868
|
+
* sent at all. The measured size is the real serialized body, so it accounts
|
|
27869
|
+
* for tool schemas and inlined images the caller cannot easily estimate.
|
|
27870
|
+
*
|
|
27871
|
+
* The ceiling is the caller's when it passes one, because the text/image tier is
|
|
27872
|
+
* graded by model and only the caller knows which model the turn is for; omitted,
|
|
27873
|
+
* the guard resolves the model-less default (or the video tier) itself.
|
|
27874
|
+
*
|
|
27875
|
+
* The error code is CONTEXT_OVERFLOW_CODE, not PROVIDER_ERROR, because naming the
|
|
27876
|
+
* remedy in prose is not the same as being able to act on it: DSH forces a
|
|
27877
|
+
* compaction and retries the same step only for that one code, and every other
|
|
27878
|
+
* 400-shaped failure ends the turn. A byte ceiling is answered by the same
|
|
27879
|
+
* compression a token ceiling is — the conversation shrinks either way — so the
|
|
27880
|
+
* body of the message stays as specific as it was while the code becomes one the
|
|
27881
|
+
* host can recover from.
|
|
27882
|
+
*
|
|
27883
|
+
* @param body the request body about to be serialized and sent.
|
|
27884
|
+
* @param carriesVideo whether the request attaches video, which has its own tier.
|
|
27885
|
+
* @param context what the body-fit loop already did, when it ran.
|
|
27886
|
+
* @param limit the ceiling already resolved for this request's model.
|
|
27887
|
+
* @returns the serialized body, so a caller that is about to send it does not
|
|
27888
|
+
* serialize a body of up to tens of megabytes a second time.
|
|
27889
|
+
*/
|
|
27890
|
+
function assertRequestBodyFits$1(body, carriesVideo = false, context, limit) {
|
|
27793
27891
|
const serialized = JSON.stringify(body);
|
|
27794
27892
|
const bytes = Buffer.byteLength(serialized, "utf8");
|
|
27795
|
-
const
|
|
27796
|
-
if (bytes <=
|
|
27797
|
-
throw new LlmError$1(oversizedBodyMessage(bytes,
|
|
27893
|
+
const ceiling = limit ?? (carriesVideo ? 67108864 : maxMessageBodyBytes$1());
|
|
27894
|
+
if (bytes <= ceiling) return serialized;
|
|
27895
|
+
throw new LlmError$1(oversizedBodyMessage(bytes, ceiling, body, context), CONTEXT_OVERFLOW_CODE);
|
|
27798
27896
|
}
|
|
27799
27897
|
function walkJson(value, visit) {
|
|
27800
27898
|
if (Array.isArray(value)) {
|
|
@@ -29034,7 +29132,7 @@ var KimiCodeAdapter = class extends LlmAdapter {
|
|
|
29034
29132
|
maxTokens: clampOutputToContext$1(requestedMax, promptLimit, estimatedInputTokens(requestOptions))
|
|
29035
29133
|
};
|
|
29036
29134
|
const carriesVideo = requestHasVideo(requestOptions);
|
|
29037
|
-
const bodyLimit = carriesVideo ? MAX_VIDEO_MESSAGE_BODY_BYTES :
|
|
29135
|
+
const bodyLimit = carriesVideo ? MAX_VIDEO_MESSAGE_BODY_BYTES : maxRequestBodyBytesFor(kimiCodeModelDef(entry?.id ?? options.model), process.env);
|
|
29038
29136
|
let buildOptions = boundedOptions;
|
|
29039
29137
|
let body = "";
|
|
29040
29138
|
for (let attempt = 0;; attempt++) {
|
|
@@ -29048,12 +29146,12 @@ var KimiCodeAdapter = class extends LlmAdapter {
|
|
|
29048
29146
|
excessBytes: bytes - bodyLimit
|
|
29049
29147
|
});
|
|
29050
29148
|
if (attempt > MAX_BODY_FIT_ATTEMPTS || !requestHasSendableImage(buildOptions, images)) {
|
|
29051
|
-
assertRequestBodyFits$1(built, carriesVideo, context());
|
|
29149
|
+
assertRequestBodyFits$1(built, carriesVideo, context(), bodyLimit);
|
|
29052
29150
|
throw new Error("unreachable: assertRequestBodyFits returns or throws");
|
|
29053
29151
|
}
|
|
29054
29152
|
const drop = dropOldestImagesUntilFits(buildOptions, images, bytes - bodyLimit, requestOptions);
|
|
29055
29153
|
if (drop.dropped === 0) {
|
|
29056
|
-
assertRequestBodyFits$1(built, carriesVideo, context());
|
|
29154
|
+
assertRequestBodyFits$1(built, carriesVideo, context(), bodyLimit);
|
|
29057
29155
|
throw new Error("unreachable: assertRequestBodyFits returns or throws");
|
|
29058
29156
|
}
|
|
29059
29157
|
buildOptions = drop.options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EAEV,iBAAiB,EAGjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,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,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/F,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;YAgBpD,aAAa;IA0W5B;;;;;;;;;;;;;;;OAeG;YACW,mBAAmB;IA6DjC;;;;;;;;OAQG;YACW,mBAAmB;CASlC;AAyCD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -252,7 +252,22 @@ export declare function buildAnthropicRequest(options: GenerateOptions, images?:
|
|
|
252
252
|
/** Build the body for whichever endpoint serves `wire`. */
|
|
253
253
|
export declare function buildRequest(options: GenerateOptions, wire: KimiCodeWire, images?: ResolvedRequestImages, preserveThinking?: boolean, media?: RequestMediaOptions): Record<string, unknown>;
|
|
254
254
|
/**
|
|
255
|
-
*
|
|
255
|
+
* What the body-fit loop actually did, so the remedy can describe it.
|
|
256
|
+
*
|
|
257
|
+
* Optional by design: a caller that has not run the loop leaves it undefined and
|
|
258
|
+
* gets the composition-based message, so every direct assertion of this guard
|
|
259
|
+
* keeps its exact text.
|
|
260
|
+
*/
|
|
261
|
+
export interface BodyFitContext {
|
|
262
|
+
/** How many image occurrences the loop already replaced with a placeholder. */
|
|
263
|
+
readonly droppedImages: number;
|
|
264
|
+
/** How many sendable image occurrences the body still carries. */
|
|
265
|
+
readonly sendableImagesRemaining: number;
|
|
266
|
+
/** The overflow that remained after the last drop. */
|
|
267
|
+
readonly excessBytes: number;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Reject a request the service would refuse for its size.
|
|
256
271
|
*
|
|
257
272
|
* This is the most frequently reported 400 on the coding endpoint, and it is
|
|
258
273
|
* worth catching locally for two reasons: the message can name the actual
|
|
@@ -260,6 +275,10 @@ export declare function buildRequest(options: GenerateOptions, wire: KimiCodeWir
|
|
|
260
275
|
* sent at all. The measured size is the real serialized body, so it accounts
|
|
261
276
|
* for tool schemas and inlined images the caller cannot easily estimate.
|
|
262
277
|
*
|
|
278
|
+
* The ceiling is the caller's when it passes one, because the text/image tier is
|
|
279
|
+
* graded by model and only the caller knows which model the turn is for; omitted,
|
|
280
|
+
* the guard resolves the model-less default (or the video tier) itself.
|
|
281
|
+
*
|
|
263
282
|
* The error code is CONTEXT_OVERFLOW_CODE, not PROVIDER_ERROR, because naming the
|
|
264
283
|
* remedy in prose is not the same as being able to act on it: DSH forces a
|
|
265
284
|
* compaction and retries the same step only for that one code, and every other
|
|
@@ -268,30 +287,20 @@ export declare function buildRequest(options: GenerateOptions, wire: KimiCodeWir
|
|
|
268
287
|
* body of the message stays as specific as it was while the code becomes one the
|
|
269
288
|
* host can recover from.
|
|
270
289
|
*
|
|
290
|
+
* @param body the request body about to be serialized and sent.
|
|
291
|
+
* @param carriesVideo whether the request attaches video, which has its own tier.
|
|
292
|
+
* @param context what the body-fit loop already did, when it ran.
|
|
293
|
+
* @param limit the ceiling already resolved for this request's model.
|
|
271
294
|
* @returns the serialized body, so a caller that is about to send it does not
|
|
272
295
|
* serialize a body of up to tens of megabytes a second time.
|
|
273
296
|
*/
|
|
274
|
-
|
|
275
|
-
* What the body-fit loop actually did, so the remedy can describe it.
|
|
276
|
-
*
|
|
277
|
-
* Optional by design: a caller that has not run the loop leaves it undefined and
|
|
278
|
-
* gets the composition-based message, so every direct assertion of this guard
|
|
279
|
-
* keeps its exact text.
|
|
280
|
-
*/
|
|
281
|
-
export interface BodyFitContext {
|
|
282
|
-
/** How many image occurrences the loop already replaced with a placeholder. */
|
|
283
|
-
readonly droppedImages: number;
|
|
284
|
-
/** How many sendable image occurrences the body still carries. */
|
|
285
|
-
readonly sendableImagesRemaining: number;
|
|
286
|
-
/** The overflow that remained after the last drop. */
|
|
287
|
-
readonly excessBytes: number;
|
|
288
|
-
}
|
|
289
|
-
export declare function assertRequestBodyFits(body: Record<string, unknown>, carriesVideo?: boolean, context?: BodyFitContext): string;
|
|
297
|
+
export declare function assertRequestBodyFits(body: Record<string, unknown>, carriesVideo?: boolean, context?: BodyFitContext, limit?: number): string;
|
|
290
298
|
/**
|
|
291
299
|
* How a request body splits into the parts that share the ceiling.
|
|
292
300
|
*
|
|
293
|
-
* The 2 MB
|
|
294
|
-
*
|
|
301
|
+
* The body ceiling — 2 MB on the 256K tier, larger on the 1M tier — covers
|
|
302
|
+
* images, conversation text, tool schemas and the system prompt together, but
|
|
303
|
+
* only the first is compressible by dropping something. A
|
|
295
304
|
* message that names which part dominates is the difference between a user who
|
|
296
305
|
* compacts the conversation and a user who deletes images and fails again.
|
|
297
306
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAA;AAKhC,OAAO,EAAE,uBAAuB,EAAmB,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAEnE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,CAAA;AACxD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EAItB,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EAEpB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC3B,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,qBAAq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xD;AAmBD,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,KAAK,EAAE,mBAAmB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAWzF;AAED,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAUrE"}
|
|
@@ -7,6 +7,28 @@
|
|
|
7
7
|
* a request body, or the service answers 401 "Your model id does not exist".
|
|
8
8
|
*/
|
|
9
9
|
import type { KimiCodeReasoningEffort, KimiCodeThinkingType } from '../../shared/kimi-code-contracts.ts';
|
|
10
|
+
/**
|
|
11
|
+
* Request-body ceiling the 1M-context tier defaults to.
|
|
12
|
+
*
|
|
13
|
+
* The 2 MB figure this line used to apply to every model comes from the gateway's
|
|
14
|
+
* generic error example and was never measured against a 1M window, while a real
|
|
15
|
+
* 1M session (3-4 MB of Chinese prose) hits it long before the window is full.
|
|
16
|
+
* The official kimi-cli ships no byte guard at all, so the ceiling is this
|
|
17
|
+
* plugin's own safety net rather than a client requirement.
|
|
18
|
+
*
|
|
19
|
+
* 8 MiB is sized so bytes never become the binding limit for a 1M session: that
|
|
20
|
+
* window's body is roughly 4 MB of English or 4.5 MB of dense Chinese, so 8 MiB
|
|
21
|
+
* leaves nearly double the headroom. What binds first is the model's own token
|
|
22
|
+
* window — the service answers "Your request exceeded model token limit", which
|
|
23
|
+
* common/context-overflow.ts already normalizes to CONTEXT_WINDOW_EXCEEDED, so
|
|
24
|
+
* compaction and retry behave exactly as they did before.
|
|
25
|
+
*
|
|
26
|
+
* The number is still an UPPER BOUND pending measurement, not a documented
|
|
27
|
+
* gateway limit: a deployment that has measured its own gateway pins the real
|
|
28
|
+
* figure with DSH_KIMI_CODE_MAX_BODY_BYTES. The 256K tier keeps 2 MB, where the
|
|
29
|
+
* old ceiling and the window line up.
|
|
30
|
+
*/
|
|
31
|
+
export declare const LONG_CONTEXT_MESSAGE_BODY_BYTES: number;
|
|
10
32
|
/** One model the Kimi Code endpoint serves to subscription accounts. */
|
|
11
33
|
export interface KimiCodeCatalogModel {
|
|
12
34
|
/** Exact model id to put on the wire. */
|
|
@@ -29,6 +51,16 @@ export interface KimiCodeCatalogModel {
|
|
|
29
51
|
maxContextWindow: number | null;
|
|
30
52
|
/** Floor for the dynamic wire budget, NOT a ceiling or DSH defaultMaxTokens. */
|
|
31
53
|
maxTokens: number;
|
|
54
|
+
/**
|
|
55
|
+
* Local default for the gateway request-body ceiling, graded by context tier.
|
|
56
|
+
*
|
|
57
|
+
* This is the per-model default {@link maxRequestBodyBytesFor} returns when no
|
|
58
|
+
* environment override is set. It is NOT a documented gateway limit: the 1M
|
|
59
|
+
* tier's 8 MiB is a still-unmeasured upper bound (see
|
|
60
|
+
* {@link LONG_CONTEXT_MESSAGE_BODY_BYTES}), and the 256K tier keeps the 2 MiB
|
|
61
|
+
* figure this line applied to every model before the split.
|
|
62
|
+
*/
|
|
63
|
+
maxRequestBodyBytes: number;
|
|
32
64
|
/** Input the model accepts; DSH only maps the text and image entries. */
|
|
33
65
|
inputModalities: readonly ('text' | 'image' | 'video')[];
|
|
34
66
|
/** Thinking levels the model accepts, in escalating order. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/model-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/model-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAGxG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,+BAA+B,QAAkB,CAAA;AAE9D,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;I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B,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* https://www.kimi.com/code/docs/en/kimi-code/error-reference.html
|
|
19
19
|
*/
|
|
20
20
|
import type { KimiCodeReasoningEffort, KimiCodeRegion, KimiCodeThinkingType, KimiCodeWire } from '../../shared/kimi-code-contracts.ts';
|
|
21
|
+
import { LONG_CONTEXT_MESSAGE_BODY_BYTES, type KimiCodeCatalogModel } from './model-catalog.ts';
|
|
21
22
|
export declare const PROVIDER_ID = "kimi-code";
|
|
22
23
|
export declare const PROVIDER_NAME = "Kimi Code";
|
|
23
24
|
/**
|
|
@@ -130,10 +131,46 @@ export declare const ANTHROPIC_MESSAGES_PATH = "/v1/messages?beta=true";
|
|
|
130
131
|
* spanning both tiers could not express "relax the text ceiling, leave the video
|
|
131
132
|
* one alone", and a value chosen for a 2 MB conversation would collapse the video
|
|
132
133
|
* tier with it. MiniMax's video budget is likewise a bare constant.
|
|
134
|
+
*
|
|
135
|
+
* The text/image tier is now graded by model: this constant is what the 256K
|
|
136
|
+
* models keep and what an unknown model falls back to, while the 1M models
|
|
137
|
+
* declare their own, larger ceiling in the registry. {@link maxRequestBodyBytesFor}
|
|
138
|
+
* is the resolver that applies that grade.
|
|
133
139
|
*/
|
|
134
140
|
export declare const DEFAULT_MAX_MESSAGE_BODY_BYTES = 2097152;
|
|
135
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Ceiling this process enforces when the caller has no model to key on.
|
|
143
|
+
*
|
|
144
|
+
* Kept alongside {@link maxRequestBodyBytesFor} rather than folded into it: this
|
|
145
|
+
* is the answer for "what does this deployment allow at all", which the video
|
|
146
|
+
* budget and the settings reporting paths need without naming a model. A request
|
|
147
|
+
* that DOES name one goes through the per-model resolver below, so a 1M-tier
|
|
148
|
+
* session gets its own tier instead of this floor.
|
|
149
|
+
*/
|
|
136
150
|
export declare function maxMessageBodyBytes(env?: NodeJS.ProcessEnv): number;
|
|
151
|
+
/**
|
|
152
|
+
* Request-body ceiling for one model, in precedence order.
|
|
153
|
+
*
|
|
154
|
+
* The middleware gateway that rejects a body is shared and the sessions are not:
|
|
155
|
+
* a 1M-tier session produces several megabytes of conversation the 256K tier
|
|
156
|
+
* cannot, so one number for both either starves the long tier or leaves the
|
|
157
|
+
* short one unguarded. Hence three sources, highest priority first:
|
|
158
|
+
*
|
|
159
|
+
* 1. DSH_KIMI_CODE_MAX_BODY_BYTES — a measured figure for THIS deployment, so it
|
|
160
|
+
* wins over every per-model default. It still has to be a positive integer:
|
|
161
|
+
* a typo falls through to the model's own default rather than switching the
|
|
162
|
+
* guard off, which is the one failure this variable must never cause;
|
|
163
|
+
* 2. the model's {@link KimiCodeCatalogModel.maxRequestBodyBytes};
|
|
164
|
+
* 3. {@link DEFAULT_MAX_MESSAGE_BODY_BYTES}, for a model the registry does not
|
|
165
|
+
* know — an unknown id keeps the most conservative ceiling rather than
|
|
166
|
+
* inheriting a long-context allowance nothing has vouched for.
|
|
167
|
+
*
|
|
168
|
+
* @param model the registry row for the model being called, or undefined when
|
|
169
|
+
* the id is not one this route ships.
|
|
170
|
+
* @param env environment the override is read from, injectable for tests.
|
|
171
|
+
*/
|
|
172
|
+
export declare function maxRequestBodyBytesFor(model: KimiCodeCatalogModel | undefined, env?: NodeJS.ProcessEnv): number;
|
|
173
|
+
export { LONG_CONTEXT_MESSAGE_BODY_BYTES };
|
|
137
174
|
/**
|
|
138
175
|
* Bytes one METERED token is assumed to occupy when a deployment asks this route
|
|
139
176
|
* to fold its published window against the byte ceiling.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACb,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3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