@vibedev-si/dsh-vibedev 0.3.8 → 0.3.10
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 +28 -5
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/client/client.js +123 -0
- package/lib/index.d.ts +10 -1
- package/lib/index.js +153 -14
- package/lib/llm/adapter.d.ts +10 -0
- package/lib/llm/cache-ttl.d.ts +10 -0
- package/lib/llm/index.d.ts +10 -3
- package/lib/llm/relay.d.ts +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
在 DeepSeek Harness 里登录 VibeDev 账号,和 DeepSeek 账号并存:
|
|
4
4
|
|
|
5
|
-
- **VibeDev 的模型**:登录后,模型选择器里会多出「VibeDev」一组(Claude、GPT
|
|
5
|
+
- **VibeDev 的模型**:登录后,模型选择器里会多出「VibeDev」一组(Claude、GPT 等普通网关模型),`relay-` 开头的聊天模型另列「中转」组,和 DeepSeek 的模型并列,选中就能用;
|
|
6
6
|
- **媒体生成**:Agent 可以生成图片、视频、音乐、播客和语音,并把语音转成文字,结果保存在工作区的 `media/` 目录下;
|
|
7
7
|
- **网页搜索**:提供走 VibeDev 网关的网页搜索,见下面的「网页搜索」。
|
|
8
8
|
|
|
@@ -74,12 +74,30 @@
|
|
|
74
74
|
媒体创建、完成、刷新请求走所选 API;上传和下载使用服务器返回的完整签名 URL,保留 host、path、query,不携带 VibeDev app token。返回签名链接时下载不再先探测旧 `/content` 接口;未返回链接的旧接口仍可直接返回文件。API 和下载请求拒绝重定向,不把失败或503当作跨区域重发理由。现有同站同键重试、SSE、心跳和取消语义保留。默认不读取开发密钥,旧 `VIBEDEV_GATEWAY_API_KEY` 变量不再使用;开发调试需显式指定本站专用环境变量。本地验证版不解除服务器503挡板,不发送真实模型或付费媒体测试。
|
|
75
75
|
|
|
76
76
|
- 模型列表来自 VibeDev 网关,按你的账号下发,所以**未登录时不显示**,登录后立即出现,不用重启。
|
|
77
|
-
-
|
|
77
|
+
- 普通模型在选择器里的「VibeDev」组;`relay-` 开头的聊天模型在「中转」组,两组共用同一个账号、余额和网关地址。没有中转模型时不显示空分组。
|
|
78
|
+
- 0.3.9 起,`relay-gpt-6.1-sol-x0.3` 显示为 `gpt-6.1-sol · 0.3倍率`;`relay-gpt-6.1-sol` 同样归入「中转」,但不显示倍率。网关给了可读的 `display_name` 时保留该名称。只把末尾 `-x数字` 当作倍率;其他文字后缀照常显示。
|
|
79
|
+
- 分组和倍率只影响显示:请求、历史记录和模型选择使用网关下发的完整模型 ID,不会去掉 `relay-` 或倍率后缀。不同倍率和无倍率的同名模型保持独立;价格和扣费仍以网关为准,插件不会按名称再乘一次倍率。中转模型保留目录声明的上下文、图片输入和推理档位,并按原模型族选择协议。原来已保存的普通路由与中转模型选择仍可解析。
|
|
78
80
|
- 没登录就用了 VibeDev 的模型,或登录已失效时,对话里会提示到侧边栏或设置里登录;余额不足时会提示并给出充值链接。这些提示和 DeepSeek 账号的登录、充值提示是分开的。
|
|
79
81
|
- 访问令牌过期时插件会自动续期并重发请求,不会重复输出。
|
|
80
82
|
- 网关到上游模型服务的连接中途断开(例如 `upstream_http2_stream_error`、上游响应流被中断)属于可恢复的传输故障,会和超时、5xx、限流一样按退避自动重试,不再直接判定成一次不可重试的失败;重试会重新发起该次请求,已经输出的内容不会续写。
|
|
81
83
|
- 0.3.7 起,网关新上架或下架的模型不用退出重新登录就能看到:指针停在侧边栏的 VibeDev 账号行上打开余额卡片、打开账号菜单(显示的余额超过 10 秒时),以及点「刷新」或打开「设置 → VibeDev 账号」时,插件在重新读取余额的同时也重新读取模型列表,最多每分钟一次;余额照常立刻显示,不等模型列表。模型有变化时,选择器里的「VibeDev」组和设置页的「N 个模型」随即更新。没人操作时,仍按原来的方式在启动、登录或切换账号时以及每 30 分钟(`catalogRefreshMinutes`)读取一次,不会定时轮询。
|
|
82
84
|
|
|
85
|
+
## Claude 提示词缓存(0.3.10)
|
|
86
|
+
|
|
87
|
+
在「插件 → VibeDev 账号与模型」设置页的「Claude 提示词缓存」一节选择保留时间,改完点「保存」:
|
|
88
|
+
|
|
89
|
+
| 选项 | 请求行为 |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| 默认 | 保持 0.3.9 的缓存行为:已有 `cache_control: {type: "ephemeral"}` 不显式指定 `ttl`。不是关闭缓存。 |
|
|
92
|
+
| 5分钟 | 给已有缓存标记显式指定 `ttl: "5m"`。 |
|
|
93
|
+
| 1小时 | 给已有缓存标记显式指定 `ttl: "1h"`。 |
|
|
94
|
+
|
|
95
|
+
该设置对应实时配置 `claudeCacheTtl: default | 5m | 1h`,只作用于 VibeDev 和「中转」组中使用 Anthropic Messages 协议的 Claude;GPT、DeepSeek、其他协议的缓存参数和所有模型 ID 保持不变。它只改写原有缓存断点,不增加断点,也不修改工具输入、JSON schema、历史消息或思考签名。设置保存后用于后续请求;已准备或开始的请求及其凭据续期重试沿用开始时的时长。离开设置页但未保存的修改会丢弃。
|
|
96
|
+
|
|
97
|
+
模型和网关必须支持标准 Anthropic `cache_control.ttl`,网关须正确转发并结算 5分钟和1小时缓存;不需要新增模型目录字段。选择时长只是请求保留时间,不保证命中缓存。1小时缓存写入可能费用更高,实际价格、用量和扣费以网关为准,插件不在本地修改价格。网关拒绝所选时长时会显示原请求错误,不自动缩短 TTL 或重发;可回到设置页改选默认或5分钟。
|
|
98
|
+
|
|
99
|
+
这是独立账号插件更新,无需重新打包桌面版。首次从桌面内置的账号插件升级时,需要完全退出并重新启动 VibeDev 一次(包括托盘);之后修改并保存该 TTL 设置即时用于后续请求,不需要再重启。
|
|
100
|
+
|
|
83
101
|
## 网页搜索
|
|
84
102
|
|
|
85
103
|
插件注册了一个网页搜索提供方 `vibedev-gateway`,用你的 VibeDev 登录调用网关的搜索。注册不等于启用:DeepSeek Harness 默认仍用自己的搜索;想改用 VibeDev 的,在配置文件里把 `web` 一行的 `searchProvider` 设为 `vibedev-gateway`(VibeDev 应用默认就是这样)。搜索本身不收费,但余额为零时网关会拒绝所有请求,包括搜索。
|
|
@@ -135,9 +153,10 @@
|
|
|
135
153
|
| --- | --- | --- |
|
|
136
154
|
| 每次付费生成前先询问 | 关 | 打开后,每次媒体生成前先确认费用。 |
|
|
137
155
|
| 保存目录 | `media` | 相对于工作区。 |
|
|
156
|
+
| Claude 提示词缓存保留时间 | 默认 | 可选默认、5分钟、1小时;保存后用于后续 Claude Messages 请求,默认不是关闭缓存。 |
|
|
138
157
|
| 默认生图 / 视频 / 音乐 / 播客 / 语音合成 / 转写模型 | 空 | 留空时由 Agent 按模型目录选择;可以填模型 id 或别名。 |
|
|
139
158
|
|
|
140
|
-
另有几项只能在配置文件(`cordis.patch.yml` 中 `dsh-vibedev` 一行)里改:`displayName
|
|
159
|
+
另有几项只能在配置文件(`cordis.patch.yml` 中 `dsh-vibedev` 一行)里改:`displayName`(普通模型分组名,默认 `VibeDev`)、`relayDisplayName`(中转模型分组名,默认「中转」)、`preferredModels`(排在最前的 VibeDev 模型)、`openBrowserOnSignIn`(登录时是否自动打开系统浏览器,默认开)、`catalogRefreshMinutes`(模型目录定时刷新间隔,默认 30 分钟;是没人打开余额卡片、账号菜单或设置时的兜底)、`client`(登录时报给网关的客户端名称,默认 `vibedev-plugin`)、`primary`(作为应用的主账号显示,默认关,VibeDev 应用里开)。
|
|
141
160
|
|
|
142
161
|
## 从 dsh-media 升级
|
|
143
162
|
|
|
@@ -177,7 +196,7 @@ npm run build
|
|
|
177
196
|
|
|
178
197
|
Sign in to VibeDev in DeepSeek Harness, next to the DeepSeek account:
|
|
179
198
|
|
|
180
|
-
- **VibeDev models**: once signed in, the model picker gains a "VibeDev" group
|
|
199
|
+
- **VibeDev models**: once signed in, the model picker gains a "VibeDev" group for ordinary gateway models and a separate 中转 (Relay) group for `relay-` chat models, next to DeepSeek's;
|
|
181
200
|
- **Media generation**: the agent generates images, videos, music, podcasts and speech, and transcribes speech; results are saved in the workspace under `media/`.
|
|
182
201
|
|
|
183
202
|
Everything is paid from your VibeDev balance; the DeepSeek account stays DeepSeek Harness's own, and the two do not affect each other. To create an account, register at [VibeDev](https://api.vibedev.studio). This plugin was renamed from `dsh-media`.
|
|
@@ -202,10 +221,14 @@ Everything is paid from your VibeDev balance; the DeepSeek account stays DeepSee
|
|
|
202
221
|
|
|
203
222
|
**Models**: the list comes from the VibeDev gateway for your account, so nothing is listed before you sign in; models appear right after, without a restart. Using a VibeDev model while signed out, or after the sign-in has ended, asks you to sign in; a used-up balance says so with the top-up link. These messages are separate from the DeepSeek account's. An expired access token is renewed and the request sent again, without repeating any output.
|
|
204
223
|
|
|
224
|
+
**Relay models (0.3.9)**: chat model IDs beginning with `relay-` appear in a separate 中转 (Relay) group, sharing the VibeDev account, gateway and balance. A terminal decimal `-x0.3` is displayed as `0.3倍率` next to the readable model name: `relay-gpt-6.1-sol-x0.3` becomes `gpt-6.1-sol · 0.3倍率`. `relay-gpt-6.1-sol` is in the same group without a multiplier. A gateway `display_name` is kept after removing these presentation markers. Other suffixes are retained as text. Requests, saved selections and history keep the complete exact model ID; rates and the suffix-free variant remain separate entries. Catalog prices are used unchanged, never multiplied by the suffix locally. Protocol-family detection handles the relay prefix while the catalog's endpoints, reasoning levels, image inputs and capacity remain authoritative. Old selections on the original route still resolve, both groups refresh together, and empty groups are hidden.
|
|
225
|
+
|
|
205
226
|
**New models without signing out (0.3.7)**: models the gateway publishes or withdraws now reach the picker on the next look at the account. Opening the balance card (resting the pointer on the sidebar's VibeDev row) or the account menu when the balance shown is more than 10 s old, Refresh on the card or in Settings → VibeDev Account, and opening that Settings page read the account with `?fresh=1`; the Host then reads the model catalog (`GET /v1/models`) again as well — at most once a minute and one read at a time, without making the balance wait. A list that changed republishes the picker's VibeDev group at once and reaches the "N models" line in Settings through the account route's long poll; a failed read keeps the list as it was. When nobody opens anything, the catalog is read as before: at start, on every sign-in, sign-out or account change, and every `catalogRefreshMinutes` (30 by default) — there is no other polling.
|
|
206
227
|
|
|
207
228
|
**Image sizes and ratios for the film workbench (0.3.8)**: an image model in the gateway catalog may declare its size tiers and aspect ratios (`capabilities.image_sizes`, such as `["1K", "1.5K", "2K", "4K"]`, and `capabilities.image_ratios`, such as `["1:1", "16:9", "9:16"]`); `vibedevMedia.models()` now hands them over on that model as `imageSizes` and `imageRatios`, for the image node's pickers. Each model keeps its own lists exactly as the gateway writes them, in its order — nothing is invented, converted or sorted (`1.5K` and `3K` stay as they are) — with entries that are not text, are blank or repeat an earlier one left out. A model that declares nothing, an empty list or a malformed one carries neither field, and nothing else in the catalog is affected. The lists follow the catalog through its cache and every refresh, so options the gateway drops disappear. They are capabilities, never request parameters: an image request still sends only `model`, `prompt`, `n`, `size` (pixels) and `quality`, and video models keep their own `ratios` and `resolutions`.
|
|
208
229
|
|
|
230
|
+
**Claude prompt cache lifetime (0.3.10)**: on Plugins → VibeDev Account & Models, the separate Claude prompt caching section offers Default, 5 minutes and 1 hour. Save stages this as the live `claudeCacheTtl` setting (`default`, `5m`, `1h`). Default preserves the 0.3.9 request: existing ephemeral markers omit `ttl`; it does not disable caching. Explicit choices add `ttl: "5m"` or `ttl: "1h"` only to existing Anthropic cache breakpoints for Claude over Messages, in both the VibeDev and Relay groups. No new breakpoint is created. Tool inputs, JSON schemas, historical messages, thinking signatures, exact model IDs and non-Anthropic caching are unchanged. Saved changes apply to future requests; a prepared or started request and its credential-renewal retry keep the captured choice. Unsaved changes are discarded when the page closes. Model and gateway support for standard Anthropic `cache_control.ttl` is required, including correct forwarding and billing; no new catalog field is needed. The lifetime requests retention rather than guaranteeing a hit. One-hour writes may cost more; usage and actual charges come from the gateway, with no local repricing. A rejected lifetime keeps the original request error, with no silent fallback or resubmission at a shorter TTL; select Default or 5 minutes in settings. This is a plugin-only update. Upgrading the application's built-in account plugin requires one complete app restart (including the tray); subsequent TTL saves do not require a restart.
|
|
231
|
+
|
|
209
232
|
**Web search**: the plugin registers the web search provider `vibedev-gateway`, signed in with your VibeDev account. Registering does not select it: DeepSeek Harness keeps its own search unless the profile sets `searchProvider: vibedev-gateway` on the `web` row (the VibeDev app does). Searching is free, but the gateway refuses every request, searches included, while the balance is zero.
|
|
210
233
|
|
|
211
234
|
**Media tools**: `image_generate`, `video_generate` (runs as a background job), `audio_generate` (music, a podcast or speech), `audio_transcribe` (a multipart file upload; languages and limits as each model declares), `media_models`, `media_tasks` and `media_account`. Reference images, videos and audio, and first and last frames, can each be a workspace path, an http(s) link, or `chat:1` for the most recent matching file you attached. A request the model cannot serve is refused before anything is uploaded or charged.
|
|
@@ -214,7 +237,7 @@ Everything is paid from your VibeDev balance; the DeepSeek account stays DeepSee
|
|
|
214
237
|
|
|
215
238
|
**Cost**: chat models are billed by usage at the gateway's prices; images per image, video per second (reference video length counts), music and podcasts per request, speech per second of original audio (the length the provider reports, which can differ from playback), transcription per minute. A model without a catalog price is shown as "not priced" (未定价), never as free. Video models priced per video Token (`video_pricing` in the catalog) have one Token price per resolution and presence of reference video, audio and images (first and last frames count as images); before a run the plugin estimates the matching rule's per-second price times the output length plus every reference video's length, and the final charge is the actual video Tokens. When that cannot be estimated (an unmeasured reference video, no per-second estimate, a pricing mode this version does not read) it says "estimate unavailable; billed by actual video Token usage" — never free, never "not priced". A finished video whose billing is still pending (`billing_status: pending`) is saved as usual and never generated again; only the charge is still to be confirmed. Failed and cancelled video and audio tasks are not charged, and a submitted video cannot be cancelled. One operation generates once: an unconfirmed submission is settled under the same key, a failed query or download only queries again or renews the link, and a result whose charge is still settling (`settlement_pending`) is kept, never generated again. "Ask before each paid generation" is off by default.
|
|
216
239
|
|
|
217
|
-
**Settings**: open "VibeDev Account & Models" on the Plugins page for the spending confirmation, the output folder and the default media models. `displayName`, `preferredModels`, `openBrowserOnSignIn`, `catalogRefreshMinutes`, `client` (the client name sent with the sign-in, default `vibedev-plugin`) and `primary` (show the account as the app's main account; off by default, on in the VibeDev app) are set in the profile's `cordis.patch.yml` row `dsh-vibedev`.
|
|
240
|
+
**Settings**: open "VibeDev Account & Models" on the Plugins page for the spending confirmation, the output folder and the default media models. `displayName`, `relayDisplayName` (the relay group label, default 中转), `preferredModels`, `openBrowserOnSignIn`, `catalogRefreshMinutes`, `client` (the client name sent with the sign-in, default `vibedev-plugin`) and `primary` (show the account as the app's main account; off by default, on in the VibeDev app) are set in the profile's `cordis.patch.yml` row `dsh-vibedev`.
|
|
218
241
|
|
|
219
242
|
**Upgrading from dsh-media**: the VibeDev Plugin Center (0.1.5 or later) switches it over for you, from its banner or when you install this plugin, the film workbench or the AI Creator Suite: the new package is installed disabled, `dsh-media` is disabled, the new one enabled, and `dsh-media` removed only after that worked. By hand, disable `dsh-media` first, install `@vibedev-si/dsh-vibedev`, uninstall `dsh-media` and restart the app fully. The two cannot both be enabled: they register the same tool names, and whichever loads second fails to start. The sign-in and running video and audio tasks carry over; the media settings go back to their defaults.
|
|
220
243
|
|
package/THIRD-PARTY-NOTICES.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
THIRD-PARTY NOTICES · @vibedev-si/dsh-vibedev 0.3.
|
|
1
|
+
THIRD-PARTY NOTICES · @vibedev-si/dsh-vibedev 0.3.10
|
|
2
2
|
|
|
3
3
|
This package bundles code from the projects below. Each is used under the licence that
|
|
4
4
|
follows its name; the licence texts are reproduced as the projects ship them.
|
package/client/client.js
CHANGED
|
@@ -739,6 +739,13 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
739
739
|
confirmSpending: "每次付费生成前先询问",
|
|
740
740
|
confirmSpendingHint: "开启后,生成图片、视频、音乐或播客之前会先请你确认,并显示模型和预估金额。默认关闭。",
|
|
741
741
|
output: "保存位置",
|
|
742
|
+
claudeCache: "Claude 提示词缓存",
|
|
743
|
+
claudeCacheTtl: "缓存保留时间",
|
|
744
|
+
claudeCacheDefault: "默认",
|
|
745
|
+
claudeCache5m: "5分钟",
|
|
746
|
+
claudeCache1h: "1小时",
|
|
747
|
+
claudeCacheHint: "默认保持现有请求行为;5分钟或1小时只指定已有缓存标记的保留时间。适用于 VibeDev 和中转分组中走 Messages 协议的 Claude,需要模型和网关支持。保存后用于后续请求,不保证命中缓存。",
|
|
748
|
+
claudeCacheCostHint: "1小时缓存写入可能费用更高,实际以网关为准。若网关拒绝该时长,请改选默认或5分钟;插件不会自动缩短时长重试。",
|
|
742
749
|
outputDir: "保存目录",
|
|
743
750
|
outputDirHint: "相对当前工作区。图片、视频、音频和转写稿分别放在其中的 images、videos、audio、transcripts 子目录。清空后恢复为 media。",
|
|
744
751
|
models: "默认媒体模型",
|
|
@@ -877,6 +884,13 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
877
884
|
confirmSpending: "Ask before each paid generation",
|
|
878
885
|
confirmSpendingHint: "When on, you are asked to confirm before an image, video, song or podcast is generated, with the model and the estimated price. Off by default.",
|
|
879
886
|
output: "Where results go",
|
|
887
|
+
claudeCache: "Claude prompt caching",
|
|
888
|
+
claudeCacheTtl: "Cache lifetime",
|
|
889
|
+
claudeCacheDefault: "Default",
|
|
890
|
+
claudeCache5m: "5 minutes",
|
|
891
|
+
claudeCache1h: "1 hour",
|
|
892
|
+
claudeCacheHint: "Default preserves existing requests; 5 minutes or 1 hour sets the lifetime on existing cache markers only. Applies to Claude over Messages in the VibeDev and Relay groups; model and gateway support are required. Saved changes apply to future requests. This does not guarantee a cache hit.",
|
|
893
|
+
claudeCacheCostHint: "1-hour cache writes may cost more; actual charges come from the gateway. If the gateway rejects the lifetime, select Default or 5 minutes. The plugin never silently retries with a shorter lifetime.",
|
|
880
894
|
outputDir: "Output folder",
|
|
881
895
|
outputDirHint: "Relative to the workspace. Images, videos, audio and transcripts go into its images, videos, audio and transcripts folders. Clear it to go back to media.",
|
|
882
896
|
models: "Default media models",
|
|
@@ -1286,6 +1300,14 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1286
1300
|
});
|
|
1287
1301
|
}
|
|
1288
1302
|
//#endregion
|
|
1303
|
+
//#region src/llm/cache-ttl.ts
|
|
1304
|
+
/** Anthropic cache retention changes only existing cache-control markers in serialized content. */
|
|
1305
|
+
const CLAUDE_CACHE_TTLS = [
|
|
1306
|
+
"default",
|
|
1307
|
+
"5m",
|
|
1308
|
+
"1h"
|
|
1309
|
+
];
|
|
1310
|
+
//#endregion
|
|
1289
1311
|
//#region src/client/fields.ts
|
|
1290
1312
|
/** The settings namespace: the plugin's profile entry id. */
|
|
1291
1313
|
const SETTINGS_NAMESPACE = "dsh-vibedev";
|
|
@@ -1302,6 +1324,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1302
1324
|
const FIELDS = [
|
|
1303
1325
|
"confirmSpending",
|
|
1304
1326
|
"outputDir",
|
|
1327
|
+
"claudeCacheTtl",
|
|
1305
1328
|
...MODEL_FIELDS
|
|
1306
1329
|
];
|
|
1307
1330
|
/**
|
|
@@ -1339,11 +1362,29 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1339
1362
|
}
|
|
1340
1363
|
};
|
|
1341
1364
|
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Stage the three supported Claude cache lifetimes without silently accepting arbitrary text.
|
|
1367
|
+
* @returns the TTL field's conversion spec.
|
|
1368
|
+
*/
|
|
1369
|
+
function claudeCacheTtlField() {
|
|
1370
|
+
return {
|
|
1371
|
+
field: "claudeCacheTtl",
|
|
1372
|
+
format: (value) => CLAUDE_CACHE_TTLS.find((choice) => choice === value) ?? "default",
|
|
1373
|
+
parse: (text) => {
|
|
1374
|
+
const choice = CLAUDE_CACHE_TTLS.find((choice) => choice === text.trim());
|
|
1375
|
+
return choice === void 0 ? void 0 : {
|
|
1376
|
+
kind: "set",
|
|
1377
|
+
value: choice
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1342
1382
|
/** The specs of every field the page edits. */
|
|
1343
1383
|
function fieldSpecs() {
|
|
1344
1384
|
return [
|
|
1345
1385
|
booleanField("confirmSpending"),
|
|
1346
1386
|
textField("outputDir"),
|
|
1387
|
+
claudeCacheTtlField(),
|
|
1347
1388
|
...MODEL_FIELDS.map(textField)
|
|
1348
1389
|
];
|
|
1349
1390
|
}
|
|
@@ -1386,6 +1427,13 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1386
1427
|
flex: 1,
|
|
1387
1428
|
minWidth: 0
|
|
1388
1429
|
},
|
|
1430
|
+
cacheRow: {
|
|
1431
|
+
display: "flex",
|
|
1432
|
+
alignItems: "center",
|
|
1433
|
+
flexWrap: "wrap",
|
|
1434
|
+
gap: 8,
|
|
1435
|
+
padding: "8px 0"
|
|
1436
|
+
},
|
|
1389
1437
|
label: {
|
|
1390
1438
|
fontSize: 13,
|
|
1391
1439
|
fontWeight: 500,
|
|
@@ -1436,6 +1484,21 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1436
1484
|
function MediaSettingsPage({ t, store, actions, account }) {
|
|
1437
1485
|
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot);
|
|
1438
1486
|
const site = (0, react.useSyncExternalStore)(account.subscribe, account.getSnapshot).view?.links.register;
|
|
1487
|
+
const [cacheOpen, setCacheOpen] = (0, react.useState)(false);
|
|
1488
|
+
const cacheOptions = [
|
|
1489
|
+
{
|
|
1490
|
+
id: "default",
|
|
1491
|
+
label: t("claudeCacheDefault")
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
id: "5m",
|
|
1495
|
+
label: t("claudeCache5m")
|
|
1496
|
+
},
|
|
1497
|
+
{
|
|
1498
|
+
id: "1h",
|
|
1499
|
+
label: t("claudeCache1h")
|
|
1500
|
+
}
|
|
1501
|
+
];
|
|
1439
1502
|
if (state.status === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1440
1503
|
style: styles$1.quiet,
|
|
1441
1504
|
role: "status",
|
|
@@ -1503,6 +1566,66 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1503
1566
|
...textField("outputDir")
|
|
1504
1567
|
})
|
|
1505
1568
|
}),
|
|
1569
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Section, {
|
|
1570
|
+
title: t("claudeCache"),
|
|
1571
|
+
hint: t("claudeCacheHint"),
|
|
1572
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1573
|
+
style: styles$1.cacheRow,
|
|
1574
|
+
children: [
|
|
1575
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1576
|
+
id: "dsh-vibedev-cache-ttl-label",
|
|
1577
|
+
style: styles$1.label,
|
|
1578
|
+
children: t("claudeCacheTtl")
|
|
1579
|
+
}),
|
|
1580
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
1581
|
+
open: cacheOpen && !disabled,
|
|
1582
|
+
selectedId: state.fields.claudeCacheTtl.text,
|
|
1583
|
+
items: cacheOptions,
|
|
1584
|
+
portal: true,
|
|
1585
|
+
autoFocus: true,
|
|
1586
|
+
anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1587
|
+
id: "dsh-vibedev-cache-ttl",
|
|
1588
|
+
type: "button",
|
|
1589
|
+
size: "sm",
|
|
1590
|
+
variant: "outline",
|
|
1591
|
+
disabled,
|
|
1592
|
+
"aria-labelledby": "dsh-vibedev-cache-ttl-label dsh-vibedev-cache-ttl-value",
|
|
1593
|
+
"aria-haspopup": "menu",
|
|
1594
|
+
"aria-expanded": cacheOpen && !disabled,
|
|
1595
|
+
onClick: () => {
|
|
1596
|
+
setCacheOpen((open) => !open);
|
|
1597
|
+
},
|
|
1598
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1599
|
+
id: "dsh-vibedev-cache-ttl-value",
|
|
1600
|
+
children: cacheOptions.find((choice) => choice.id === state.fields.claudeCacheTtl.text)?.label ?? t("claudeCacheDefault")
|
|
1601
|
+
})
|
|
1602
|
+
}),
|
|
1603
|
+
onClose: () => {
|
|
1604
|
+
setCacheOpen(false);
|
|
1605
|
+
},
|
|
1606
|
+
onSelect: (id) => {
|
|
1607
|
+
actions.edit("claudeCacheTtl", id);
|
|
1608
|
+
setCacheOpen(false);
|
|
1609
|
+
}
|
|
1610
|
+
}),
|
|
1611
|
+
state.fields.claudeCacheTtl.overridden && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1612
|
+
style: styles$1.quiet,
|
|
1613
|
+
children: t("overridden")
|
|
1614
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1615
|
+
type: "button",
|
|
1616
|
+
size: "sm",
|
|
1617
|
+
disabled,
|
|
1618
|
+
onClick: () => {
|
|
1619
|
+
actions.resetField("claudeCacheTtl");
|
|
1620
|
+
},
|
|
1621
|
+
children: t("reset")
|
|
1622
|
+
})] })
|
|
1623
|
+
]
|
|
1624
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1625
|
+
style: styles$1.hint,
|
|
1626
|
+
children: state.fields.claudeCacheTtl.invalid ? t("invalid") : t("claudeCacheCostHint")
|
|
1627
|
+
})]
|
|
1628
|
+
}),
|
|
1506
1629
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Section, {
|
|
1507
1630
|
title: t("models"),
|
|
1508
1631
|
hint: t("modelsHint"),
|
package/lib/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { Context, Volatile } from '@deepseek-ai/cordis';
|
|
24
24
|
import Schema from '@deepseek-ai/schemastery';
|
|
25
|
+
import { type ClaudeCacheTtl } from './llm/cache-ttl.js';
|
|
25
26
|
export { MediaError } from './gateway/errors.js';
|
|
26
27
|
export { MediaHostService } from './service.js';
|
|
27
28
|
export type { HostTarget, MediaOutputView, MediaTaskView } from './service.js';
|
|
@@ -37,7 +38,7 @@ export { LATENCY_ROUTE } from './account/latency.js';
|
|
|
37
38
|
export type { LatencyErrorKind, LatencyResult } from './account/latency.js';
|
|
38
39
|
export { FEEDBACK_ATTACHMENT_ROUTE, FEEDBACK_ROUTE } from './feedback/index.js';
|
|
39
40
|
export { GATEWAY_SEARCH_PROVIDER_ID as SEARCH_PROVIDER_ID } from './search/provider.js';
|
|
40
|
-
export { INSUFFICIENT_BALANCE_CODE, SIGN_IN_REQUIRED_CODE, VIBEDEV_ROUTE } from './llm/index.js';
|
|
41
|
+
export { INSUFFICIENT_BALANCE_CODE, SIGN_IN_REQUIRED_CODE, VIBEDEV_ROUTE, VIBEDEV_RELAY_ROUTE } from './llm/index.js';
|
|
41
42
|
/** The package version, sent in the `User-Agent` the gateway attributes plugin traffic by. */
|
|
42
43
|
export declare const version: string;
|
|
43
44
|
export declare const name = "dsh-vibedev";
|
|
@@ -45,6 +46,10 @@ export declare const inject: string[];
|
|
|
45
46
|
export interface Config {
|
|
46
47
|
/** Name the model pickers and the Models page show for the VibeDev models. */
|
|
47
48
|
displayName: string;
|
|
49
|
+
/** Name shown for relay chat models in model pickers. */
|
|
50
|
+
relayDisplayName: string;
|
|
51
|
+
/** Requested cache lifetime for subsequent Claude Messages calls. */
|
|
52
|
+
claudeCacheTtl: Volatile<ClaudeCacheTtl>;
|
|
48
53
|
/** VibeDev chat models listed first, in this order, when the catalog offers them. */
|
|
49
54
|
preferredModels: string[];
|
|
50
55
|
/** Open the system browser when a sign-in starts (off: the page opens the link itself). */
|
|
@@ -78,6 +83,8 @@ export interface Config {
|
|
|
78
83
|
}
|
|
79
84
|
export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
80
85
|
displayName: Schema<string, string, "defined">;
|
|
86
|
+
relayDisplayName: Schema<string, string, "defined">;
|
|
87
|
+
claudeCacheTtl: Schema<"default" | "5m" | "1h", "default" | "5m" | "1h", "volatile-defined">;
|
|
81
88
|
preferredModels: Schema<string[], string[], "defined">;
|
|
82
89
|
openBrowserOnSignIn: Schema<boolean, boolean, "defined">;
|
|
83
90
|
catalogRefreshMinutes: Schema<number, number, "defined">;
|
|
@@ -96,6 +103,8 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
96
103
|
stateDir: Schema<string, string, "defined">;
|
|
97
104
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
98
105
|
displayName: Schema<string, string, "defined">;
|
|
106
|
+
relayDisplayName: Schema<string, string, "defined">;
|
|
107
|
+
claudeCacheTtl: Schema<"default" | "5m" | "1h", "default" | "5m" | "1h", "volatile-defined">;
|
|
99
108
|
preferredModels: Schema<string[], string[], "defined">;
|
|
100
109
|
openBrowserOnSignIn: Schema<boolean, boolean, "defined">;
|
|
101
110
|
catalogRefreshMinutes: Schema<number, number, "defined">;
|
package/lib/index.js
CHANGED
|
@@ -3196,6 +3196,53 @@ const DEFAULT_REQUEST_IMAGE_PIXEL_BUDGET = 4194304;
|
|
|
3196
3196
|
/** Raw encoded-byte target before inline base64 expansion. */
|
|
3197
3197
|
const DEFAULT_REQUEST_IMAGE_MAX_BYTES = 1048576;
|
|
3198
3198
|
//#endregion
|
|
3199
|
+
//#region src/llm/relay.ts
|
|
3200
|
+
/** Naming metadata for relay chat models; the gateway id itself is never rewritten. */
|
|
3201
|
+
const RELAY_PREFIX = "relay-";
|
|
3202
|
+
const RATE_SUFFIX = /-x(\d+(?:\.\d+)?)$/;
|
|
3203
|
+
/**
|
|
3204
|
+
* Read relay markers without changing routing identity.
|
|
3205
|
+
* @param id - exact gateway model id.
|
|
3206
|
+
* @returns whether it is a relay model, its family id and any display multiplier.
|
|
3207
|
+
*/
|
|
3208
|
+
function relayIdentity(id) {
|
|
3209
|
+
if (!id.startsWith(RELAY_PREFIX)) return {
|
|
3210
|
+
relay: false,
|
|
3211
|
+
baseId: id
|
|
3212
|
+
};
|
|
3213
|
+
const base = id.slice(6);
|
|
3214
|
+
const rate = RATE_SUFFIX.exec(base);
|
|
3215
|
+
if (rate === null || rate.index === 0) return {
|
|
3216
|
+
relay: true,
|
|
3217
|
+
baseId: base || id
|
|
3218
|
+
};
|
|
3219
|
+
const [integer, fraction] = rate[1].split(".");
|
|
3220
|
+
const whole = integer.replace(/^0+(?=\d)/, "");
|
|
3221
|
+
const decimal = fraction?.replace(/0+$/, "");
|
|
3222
|
+
const multiplier = decimal ? `${whole}.${decimal}` : whole;
|
|
3223
|
+
return {
|
|
3224
|
+
relay: true,
|
|
3225
|
+
baseId: base.slice(0, rate.index),
|
|
3226
|
+
multiplier
|
|
3227
|
+
};
|
|
3228
|
+
}
|
|
3229
|
+
/**
|
|
3230
|
+
* Format a catalog label, keeping gateway-authored readable names.
|
|
3231
|
+
* @param id - exact gateway model id (the only source of the rate).
|
|
3232
|
+
* @param displayName - nonempty gateway display name, when supplied.
|
|
3233
|
+
* @returns the normal name, or a relay name with an optional multiplier.
|
|
3234
|
+
*/
|
|
3235
|
+
function modelDisplayName(id, displayName) {
|
|
3236
|
+
const identity = relayIdentity(id);
|
|
3237
|
+
if (!identity.relay) return displayName ?? id;
|
|
3238
|
+
const shown = displayName ?? id;
|
|
3239
|
+
const display = relayIdentity(shown);
|
|
3240
|
+
const matchingRate = display.relay && identity.multiplier !== void 0 && display.multiplier === identity.multiplier;
|
|
3241
|
+
const withoutPrefix = shown.startsWith(RELAY_PREFIX) ? shown.slice(6) : shown;
|
|
3242
|
+
const name = (matchingRate ? display.baseId : withoutPrefix) || identity.baseId;
|
|
3243
|
+
return identity.multiplier === void 0 ? name : `${name} · ${identity.multiplier}倍率`;
|
|
3244
|
+
}
|
|
3245
|
+
//#endregion
|
|
3199
3246
|
//#region src/llm/catalog.ts
|
|
3200
3247
|
/**
|
|
3201
3248
|
* The VibeDev gateway's model catalog (`GET /v1/models`), narrowed to the chat
|
|
@@ -3238,7 +3285,7 @@ const price$1 = (value) => typeof value === "number" && Number.isFinite(value) &
|
|
|
3238
3285
|
* @returns the preferred protocol.
|
|
3239
3286
|
*/
|
|
3240
3287
|
function preferredApi(id) {
|
|
3241
|
-
const family = id.toLowerCase();
|
|
3288
|
+
const family = relayIdentity(id).baseId.toLowerCase();
|
|
3242
3289
|
if (family.startsWith("claude")) return "anthropic-messages";
|
|
3243
3290
|
if (/^(?:gpt|o\d|codex|grok)/.test(family)) return "openai-responses";
|
|
3244
3291
|
return "openai-completions";
|
|
@@ -3304,7 +3351,7 @@ function parseCatalog(body) {
|
|
|
3304
3351
|
seen.add(id);
|
|
3305
3352
|
models.push({
|
|
3306
3353
|
id,
|
|
3307
|
-
name: typeof entry.display_name === "string" && entry.display_name.trim() !== "" ? entry.display_name.trim() :
|
|
3354
|
+
name: modelDisplayName(id, typeof entry.display_name === "string" && entry.display_name.trim() !== "" ? entry.display_name.trim() : void 0),
|
|
3308
3355
|
api,
|
|
3309
3356
|
contextWindow: positive$1(capabilities.context_window) ?? 2e5,
|
|
3310
3357
|
maxTokens: positive$1(capabilities.max_output_tokens) ?? 32768,
|
|
@@ -3990,7 +4037,7 @@ function compatOf(model) {
|
|
|
3990
4037
|
supportsStore: false,
|
|
3991
4038
|
maxTokensField: "max_tokens"
|
|
3992
4039
|
};
|
|
3993
|
-
if (model.id.toLowerCase().startsWith("deepseek")) return {
|
|
4040
|
+
if (relayIdentity(model.id).baseId.toLowerCase().startsWith("deepseek")) return {
|
|
3994
4041
|
...common,
|
|
3995
4042
|
thinkingFormat: "deepseek",
|
|
3996
4043
|
supportsReasoningEffort: true,
|
|
@@ -4350,6 +4397,54 @@ async function* toStreamChunks(events, contextWindow, callerSignal, requestedMod
|
|
|
4350
4397
|
throw new LlmError("pi-ai event stream ended without done/error", "STREAM_CLOSED");
|
|
4351
4398
|
}
|
|
4352
4399
|
//#endregion
|
|
4400
|
+
//#region src/llm/cache-ttl.ts
|
|
4401
|
+
/** Anthropic cache retention changes only existing cache-control markers in serialized content. */
|
|
4402
|
+
const CLAUDE_CACHE_TTLS = [
|
|
4403
|
+
"default",
|
|
4404
|
+
"5m",
|
|
4405
|
+
"1h"
|
|
4406
|
+
];
|
|
4407
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
4408
|
+
function cacheBlock(value, ttl, nested) {
|
|
4409
|
+
const block = object(value);
|
|
4410
|
+
if (block === void 0) return value;
|
|
4411
|
+
const marker = object(block.cache_control);
|
|
4412
|
+
const next = marker?.type === "ephemeral" ? {
|
|
4413
|
+
...block,
|
|
4414
|
+
cache_control: {
|
|
4415
|
+
...marker,
|
|
4416
|
+
ttl
|
|
4417
|
+
}
|
|
4418
|
+
} : { ...block };
|
|
4419
|
+
if (nested && Array.isArray(block.content)) next.content = block.content.map((child) => cacheBlock(child, ttl, true));
|
|
4420
|
+
const source = object(block.source);
|
|
4421
|
+
if (nested && block.type === "document" && source?.type === "content" && Array.isArray(source.content)) next.source = {
|
|
4422
|
+
...source,
|
|
4423
|
+
content: source.content.map((child) => cacheBlock(child, ttl, true))
|
|
4424
|
+
};
|
|
4425
|
+
return next;
|
|
4426
|
+
}
|
|
4427
|
+
/**
|
|
4428
|
+
* Set an explicit TTL on the Anthropic payload's existing ephemeral cache breakpoints.
|
|
4429
|
+
* @param payload - serialized Anthropic request; borrowed, never mutated.
|
|
4430
|
+
* @param ttl - user preference captured for this request; default preserves the original payload.
|
|
4431
|
+
* @returns the original payload for default, or a copy with known cache-control slots updated.
|
|
4432
|
+
*/
|
|
4433
|
+
function withClaudeCacheTtl(payload, ttl) {
|
|
4434
|
+
if (ttl === "default") return payload;
|
|
4435
|
+
const next = { ...payload };
|
|
4436
|
+
if (Array.isArray(payload.system)) next.system = payload.system.map((block) => cacheBlock(block, ttl, true));
|
|
4437
|
+
if (Array.isArray(payload.tools)) next.tools = payload.tools.map((tool) => cacheBlock(tool, ttl, false));
|
|
4438
|
+
if (Array.isArray(payload.messages)) next.messages = payload.messages.map((value) => {
|
|
4439
|
+
const message = object(value);
|
|
4440
|
+
return message !== void 0 && Array.isArray(message.content) ? {
|
|
4441
|
+
...message,
|
|
4442
|
+
content: message.content.map((block) => cacheBlock(block, ttl, true))
|
|
4443
|
+
} : value;
|
|
4444
|
+
});
|
|
4445
|
+
return next;
|
|
4446
|
+
}
|
|
4447
|
+
//#endregion
|
|
4353
4448
|
//#region \0@oxc-project+runtime@0.152.0/helpers/esm/usingCtx.js
|
|
4354
4449
|
function _usingCtx() {
|
|
4355
4450
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
@@ -4481,6 +4576,15 @@ var GatewayAdapter = class extends LlmAdapter {
|
|
|
4481
4576
|
name: this.config.displayName,
|
|
4482
4577
|
models: piModels
|
|
4483
4578
|
}));
|
|
4579
|
+
const relay = this.config.relayProvider;
|
|
4580
|
+
if (relay !== void 0) {
|
|
4581
|
+
const relayModels = catalog.filter((model) => relayIdentity(model.id).relay).map((model) => toPiModel(model, relay.id, origin));
|
|
4582
|
+
models.setProvider(gatewayProvider({
|
|
4583
|
+
id: relay.id,
|
|
4584
|
+
name: relay.displayName,
|
|
4585
|
+
models: relayModels
|
|
4586
|
+
}));
|
|
4587
|
+
}
|
|
4484
4588
|
this.snapshot = {
|
|
4485
4589
|
catalog,
|
|
4486
4590
|
origin,
|
|
@@ -4489,8 +4593,11 @@ var GatewayAdapter = class extends LlmAdapter {
|
|
|
4489
4593
|
};
|
|
4490
4594
|
return this.snapshot;
|
|
4491
4595
|
}
|
|
4596
|
+
owns(provider) {
|
|
4597
|
+
return provider === this.config.provider || provider === this.config.relayProvider?.id;
|
|
4598
|
+
}
|
|
4492
4599
|
assertOwned(provider) {
|
|
4493
|
-
if (
|
|
4600
|
+
if (!this.owns(provider)) throw new LlmError(`VibeDev gateway adapter does not own provider "${provider}"`, "NO_ADAPTER");
|
|
4494
4601
|
}
|
|
4495
4602
|
modelOf(snapshot, provider, id) {
|
|
4496
4603
|
this.assertOwned(provider);
|
|
@@ -4504,18 +4611,22 @@ var GatewayAdapter = class extends LlmAdapter {
|
|
|
4504
4611
|
};
|
|
4505
4612
|
}
|
|
4506
4613
|
providerInfo(provider) {
|
|
4614
|
+
this.assertOwned(provider);
|
|
4615
|
+
const relay = this.config.relayProvider;
|
|
4507
4616
|
return {
|
|
4508
4617
|
id: provider,
|
|
4509
|
-
name: this.config.displayName
|
|
4618
|
+
name: relay?.id === provider ? relay.displayName : this.config.displayName
|
|
4510
4619
|
};
|
|
4511
4620
|
}
|
|
4512
4621
|
providerRetryPolicy(provider) {
|
|
4513
|
-
return
|
|
4622
|
+
return this.owns(provider) ? this.config.retryPolicy?.() : void 0;
|
|
4514
4623
|
}
|
|
4515
4624
|
async listModels(provider) {
|
|
4516
4625
|
this.assertOwned(provider);
|
|
4517
4626
|
if (this.current().catalog.length === 0) await this.config.refreshCatalog?.();
|
|
4518
|
-
|
|
4627
|
+
const listed = this.current().models.getModels(provider);
|
|
4628
|
+
const hideRelay = provider === this.config.provider && this.config.relayProvider !== void 0;
|
|
4629
|
+
return listed.filter((model) => !hideRelay || !relayIdentity(model.id).relay).map((model) => ({
|
|
4519
4630
|
provider,
|
|
4520
4631
|
id: model.id,
|
|
4521
4632
|
name: model.name,
|
|
@@ -4538,19 +4649,24 @@ var GatewayAdapter = class extends LlmAdapter {
|
|
|
4538
4649
|
}
|
|
4539
4650
|
prepareCall(provider, model, _signal) {
|
|
4540
4651
|
const snapshot = this.current();
|
|
4652
|
+
const claudeCacheTtl = this.cacheTtlFor(this.modelOf(snapshot, provider, model).model);
|
|
4541
4653
|
return Promise.resolve({
|
|
4542
4654
|
model: this.modelInfo(snapshot, provider, model),
|
|
4543
|
-
stream: (options) => this.streamWithSnapshot(options, snapshot)
|
|
4655
|
+
stream: (options) => this.streamWithSnapshot(options, snapshot, claudeCacheTtl)
|
|
4544
4656
|
});
|
|
4545
4657
|
}
|
|
4546
4658
|
stream(options) {
|
|
4547
4659
|
return this.streamWithSnapshot(options, this.current());
|
|
4548
4660
|
}
|
|
4549
|
-
|
|
4661
|
+
cacheTtlFor(model) {
|
|
4662
|
+
return model.api === "anthropic-messages" && relayIdentity(model.id).baseId.toLowerCase().startsWith("claude") ? this.config.claudeCacheTtl?.() ?? "default" : "default";
|
|
4663
|
+
}
|
|
4664
|
+
async *streamWithSnapshot(options, snapshot, preparedTtl) {
|
|
4550
4665
|
try {
|
|
4551
4666
|
var _usingCtx$1 = _usingCtx();
|
|
4552
4667
|
if (options.stop !== void 0) throw new LlmError("the VibeDev gateway adapter does not support GenerateOptions.stop", "UNSUPPORTED_OPTION");
|
|
4553
4668
|
const { model, catalog } = this.modelOf(snapshot, options.provider, options.model);
|
|
4669
|
+
const claudeCacheTtl = preparedTtl ?? this.cacheTtlFor(model);
|
|
4554
4670
|
const starting = startingReasoning(catalog);
|
|
4555
4671
|
const reasoning = resolveReasoningLevel(model, options.reasoningEffort ?? (starting === void 0 ? void 0 : effortOf(starting)));
|
|
4556
4672
|
let credential = await this.config.resolveCredential();
|
|
@@ -4628,7 +4744,8 @@ var GatewayAdapter = class extends LlmAdapter {
|
|
|
4628
4744
|
onPayload: (payload) => this.shapePayload(payload, model, {
|
|
4629
4745
|
...sessionId === void 0 ? {} : { sessionId },
|
|
4630
4746
|
off: reasoning === "off" && offersNone,
|
|
4631
|
-
reasoning: enabledReasoning !== void 0
|
|
4747
|
+
reasoning: enabledReasoning !== void 0,
|
|
4748
|
+
claudeCacheTtl
|
|
4632
4749
|
}),
|
|
4633
4750
|
fetch: observingFetch,
|
|
4634
4751
|
onResponse: (received) => {
|
|
@@ -4706,7 +4823,7 @@ var GatewayAdapter = class extends LlmAdapter {
|
|
|
4706
4823
|
switch (model.api) {
|
|
4707
4824
|
case "openai-completions":
|
|
4708
4825
|
if (request.sessionId !== void 0 && shaped.prompt_cache_key === void 0) shaped.prompt_cache_key = request.sessionId;
|
|
4709
|
-
if (request.off && model.id.toLowerCase().startsWith("deepseek")) {
|
|
4826
|
+
if (request.off && relayIdentity(model.id).baseId.toLowerCase().startsWith("deepseek")) {
|
|
4710
4827
|
shaped.thinking = { type: "disabled" };
|
|
4711
4828
|
delete shaped.reasoning_effort;
|
|
4712
4829
|
} else if (request.off) shaped.reasoning_effort = "none";
|
|
@@ -4717,6 +4834,8 @@ var GatewayAdapter = class extends LlmAdapter {
|
|
|
4717
4834
|
effort: "none"
|
|
4718
4835
|
};
|
|
4719
4836
|
if (request.reasoning || request.off) delete shaped.temperature;
|
|
4837
|
+
break;
|
|
4838
|
+
case "anthropic-messages": return withClaudeCacheTtl(shaped, request.claudeCacheTtl);
|
|
4720
4839
|
}
|
|
4721
4840
|
return shaped;
|
|
4722
4841
|
}
|
|
@@ -4790,6 +4909,8 @@ function isUnauthorized(chunk, response) {
|
|
|
4790
4909
|
//#region src/llm/index.ts
|
|
4791
4910
|
/** The route the gateway's chat models are listed under. */
|
|
4792
4911
|
const VIBEDEV_ROUTE = "vibedev-gateway";
|
|
4912
|
+
/** The relay group shares the VibeDev account and keeps the gateway's complete model IDs. */
|
|
4913
|
+
const VIBEDEV_RELAY_ROUTE = "vibedev-relay";
|
|
4793
4914
|
/** Shortest gap between two catalog reads that an empty model list asks for. */
|
|
4794
4915
|
const ON_DEMAND_READ_GAP_MS = 15e3;
|
|
4795
4916
|
/**
|
|
@@ -4828,6 +4949,10 @@ function installGatewayModels(ctx, options) {
|
|
|
4828
4949
|
const adapter = new GatewayAdapter({
|
|
4829
4950
|
provider: VIBEDEV_ROUTE,
|
|
4830
4951
|
displayName: options.displayName,
|
|
4952
|
+
relayProvider: {
|
|
4953
|
+
id: VIBEDEV_RELAY_ROUTE,
|
|
4954
|
+
displayName: options.relayDisplayName ?? "中转"
|
|
4955
|
+
},
|
|
4831
4956
|
origin: () => origin,
|
|
4832
4957
|
catalog: () => catalog,
|
|
4833
4958
|
refreshCatalog: () => refreshIfEmpty(),
|
|
@@ -4835,6 +4960,7 @@ function installGatewayModels(ctx, options) {
|
|
|
4835
4960
|
rejectCredential: options.rejectCredential,
|
|
4836
4961
|
deviceId: options.deviceId,
|
|
4837
4962
|
cacheRetention: options.cacheRetention ?? "short",
|
|
4963
|
+
claudeCacheTtl: options.claudeCacheTtl,
|
|
4838
4964
|
resolveAttachments: () => ctx.get("attachments"),
|
|
4839
4965
|
resolveImageAccess: (attachments, ref) => resolveImageAttachmentAccess(attachments, (hostPath) => ctx.get("fs")?.processPathFromHostPath(hostPath), ref),
|
|
4840
4966
|
onReplayDegrade: ({ provider, model, reason }) => {
|
|
@@ -4842,7 +4968,7 @@ function installGatewayModels(ctx, options) {
|
|
|
4842
4968
|
},
|
|
4843
4969
|
...options.onRequestEnded === void 0 ? {} : { onRequestEnded: options.onRequestEnded }
|
|
4844
4970
|
});
|
|
4845
|
-
const registration = ctx.llm.registerAdapter([VIBEDEV_ROUTE], adapter);
|
|
4971
|
+
const registration = ctx.llm.registerAdapter([VIBEDEV_ROUTE, VIBEDEV_RELAY_ROUTE], adapter);
|
|
4846
4972
|
ctx.inject(["settings"], (child) => {
|
|
4847
4973
|
child.effect(() => child.settings.configure({ auto: false }, ctx.fiber));
|
|
4848
4974
|
});
|
|
@@ -4851,6 +4977,11 @@ function installGatewayModels(ctx, options) {
|
|
|
4851
4977
|
displayName: options.displayName,
|
|
4852
4978
|
settingsNs: entryId(ctx) ?? "dsh-vibedev",
|
|
4853
4979
|
settingsPath: []
|
|
4980
|
+
}, {
|
|
4981
|
+
provider: VIBEDEV_RELAY_ROUTE,
|
|
4982
|
+
displayName: options.relayDisplayName ?? "中转",
|
|
4983
|
+
settingsNs: entryId(ctx) ?? "dsh-vibedev",
|
|
4984
|
+
settingsPath: []
|
|
4854
4985
|
}]);
|
|
4855
4986
|
let reading;
|
|
4856
4987
|
let readRequests = 0;
|
|
@@ -4861,7 +4992,7 @@ function installGatewayModels(ctx, options) {
|
|
|
4861
4992
|
if (disposed || key === catalogKey) return;
|
|
4862
4993
|
catalog = next;
|
|
4863
4994
|
catalogKey = key;
|
|
4864
|
-
registration.replace([VIBEDEV_ROUTE]);
|
|
4995
|
+
registration.replace([VIBEDEV_ROUTE, VIBEDEV_RELAY_ROUTE]);
|
|
4865
4996
|
ctx.logger.info(`dsh-vibedev: the VibeDev route lists ${next.length} chat model(s)`);
|
|
4866
4997
|
};
|
|
4867
4998
|
const readOnce = async () => {
|
|
@@ -10879,6 +11010,8 @@ const name = "dsh-vibedev";
|
|
|
10879
11010
|
const inject = ["tools"];
|
|
10880
11011
|
const Config = Schema.object({
|
|
10881
11012
|
displayName: Schema.string().default("VibeDev"),
|
|
11013
|
+
relayDisplayName: Schema.string().default("中转"),
|
|
11014
|
+
claudeCacheTtl: Schema.union(CLAUDE_CACHE_TTLS.map((value) => Schema.const(value))).default("default").volatile(),
|
|
10882
11015
|
preferredModels: Schema.array(Schema.string()).default([]),
|
|
10883
11016
|
openBrowserOnSignIn: Schema.boolean().default(true),
|
|
10884
11017
|
catalogRefreshMinutes: Schema.number().min(1).max(1440).default(30),
|
|
@@ -10898,6 +11031,8 @@ const Config = Schema.object({
|
|
|
10898
11031
|
}).i18n({
|
|
10899
11032
|
"zh-CN": {
|
|
10900
11033
|
displayName: "模型选择器里显示的名称",
|
|
11034
|
+
relayDisplayName: "中转模型分组名称",
|
|
11035
|
+
claudeCacheTtl: "Claude 提示词缓存保留时间(默认 / 5分钟 / 1小时)",
|
|
10901
11036
|
preferredModels: "排在最前的 VibeDev 模型(按顺序,留空按网关顺序)",
|
|
10902
11037
|
openBrowserOnSignIn: "登录时自动打开系统浏览器",
|
|
10903
11038
|
catalogRefreshMinutes: "模型目录定时刷新间隔(分钟;没人打开余额卡片、账号菜单或设置时的兜底)",
|
|
@@ -10917,6 +11052,8 @@ const Config = Schema.object({
|
|
|
10917
11052
|
},
|
|
10918
11053
|
"en-US": {
|
|
10919
11054
|
displayName: "Name the model pickers show",
|
|
11055
|
+
relayDisplayName: "Relay model group name",
|
|
11056
|
+
claudeCacheTtl: "Claude prompt cache lifetime (default / 5 minutes / 1 hour)",
|
|
10920
11057
|
preferredModels: "VibeDev models listed first, in this order (empty: the gateway's order)",
|
|
10921
11058
|
openBrowserOnSignIn: "Open the system browser when signing in",
|
|
10922
11059
|
catalogRefreshMinutes: "Model catalog refresh interval in minutes (the fallback when nobody opens the balance card, the account menu or Settings)",
|
|
@@ -11034,6 +11171,8 @@ function apply(ctx, config) {
|
|
|
11034
11171
|
route = installGatewayModels(llmCtx, {
|
|
11035
11172
|
origin,
|
|
11036
11173
|
displayName: config.displayName,
|
|
11174
|
+
relayDisplayName: config.relayDisplayName,
|
|
11175
|
+
claudeCacheTtl: () => config.claudeCacheTtl.get(),
|
|
11037
11176
|
resolveCredential: () => chain.resolve(),
|
|
11038
11177
|
rejectCredential: (credential) => chain.reject(credential),
|
|
11039
11178
|
deviceId: () => storage.deviceId(),
|
|
@@ -11123,6 +11262,6 @@ function apply(ctx, config) {
|
|
|
11123
11262
|
});
|
|
11124
11263
|
}
|
|
11125
11264
|
//#endregion
|
|
11126
|
-
export { ACCOUNT_ROUTE_PREFIX, AccountService, Config, FEEDBACK_ATTACHMENT_ROUTE, FEEDBACK_ROUTE, INSUFFICIENT_BALANCE_CODE, LATENCY_ROUTE, MediaError, MediaHostService, GATEWAY_SEARCH_PROVIDER_ID as SEARCH_PROVIDER_ID, SIGN_IN_REQUIRED_CODE, VIBEDEV_ROUTE, apply, inject, name, parseMediaCatalog, version };
|
|
11265
|
+
export { ACCOUNT_ROUTE_PREFIX, AccountService, Config, FEEDBACK_ATTACHMENT_ROUTE, FEEDBACK_ROUTE, INSUFFICIENT_BALANCE_CODE, LATENCY_ROUTE, MediaError, MediaHostService, GATEWAY_SEARCH_PROVIDER_ID as SEARCH_PROVIDER_ID, SIGN_IN_REQUIRED_CODE, VIBEDEV_RELAY_ROUTE, VIBEDEV_ROUTE, apply, inject, name, parseMediaCatalog, version };
|
|
11127
11266
|
|
|
11128
11267
|
//# sourceMappingURL=index.js.map
|
package/lib/llm/adapter.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { LlmAdapter } from '@deepseek-ai/dsh-llm';
|
|
|
28
28
|
import type { GenerateOptions, ImageAttachmentAccess, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, PreparedAdapterCall, ResolvedRetryPolicy, StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
29
29
|
import type { AttachmentStore, ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
30
30
|
import type { GatewayModel } from './catalog.js';
|
|
31
|
+
import { type ClaudeCacheTtl } from './cache-ttl.js';
|
|
31
32
|
/** The credential for one request. */
|
|
32
33
|
export interface GatewayCredential {
|
|
33
34
|
readonly token: string;
|
|
@@ -62,6 +63,11 @@ export interface GatewayAdapterOptions {
|
|
|
62
63
|
readonly provider: string;
|
|
63
64
|
/** The name selectors show for the route. */
|
|
64
65
|
readonly displayName: string;
|
|
66
|
+
/** Optional picker group for relay models, served by the same account and gateway. */
|
|
67
|
+
readonly relayProvider?: {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly displayName: string;
|
|
70
|
+
};
|
|
65
71
|
/** The gateway origin, read per snapshot. */
|
|
66
72
|
readonly origin: () => string;
|
|
67
73
|
/** The current catalog; a new array identity means a new catalog. */
|
|
@@ -80,6 +86,8 @@ export interface GatewayAdapterOptions {
|
|
|
80
86
|
readonly retryPolicy?: () => ResolvedRetryPolicy | undefined;
|
|
81
87
|
readonly streamIdleTimeoutMs?: number;
|
|
82
88
|
readonly cacheRetention?: 'none' | 'short' | 'long';
|
|
89
|
+
/** Saved Claude Messages cache TTL, captured once before this request first awaits. */
|
|
90
|
+
readonly claudeCacheTtl?: () => ClaudeCacheTtl;
|
|
83
91
|
readonly resolveAttachments?: () => AttachmentStore | undefined;
|
|
84
92
|
readonly resolveImageAccess?: (attachments: AttachmentStore, ref: ImageAttachmentRef) => ImageAttachmentAccess | undefined;
|
|
85
93
|
readonly onReplayDegrade?: (detail: {
|
|
@@ -99,6 +107,7 @@ export declare class GatewayAdapter extends LlmAdapter {
|
|
|
99
107
|
private snapshot;
|
|
100
108
|
constructor(config: GatewayAdapterOptions);
|
|
101
109
|
private current;
|
|
110
|
+
private owns;
|
|
102
111
|
private assertOwned;
|
|
103
112
|
private modelOf;
|
|
104
113
|
providerInfo(provider: string): LlmProviderInfo;
|
|
@@ -108,6 +117,7 @@ export declare class GatewayAdapter extends LlmAdapter {
|
|
|
108
117
|
private modelInfo;
|
|
109
118
|
prepareCall(provider: string, model: string, _signal?: AbortSignal): Promise<PreparedAdapterCall>;
|
|
110
119
|
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
120
|
+
private cacheTtlFor;
|
|
111
121
|
private streamWithSnapshot;
|
|
112
122
|
/**
|
|
113
123
|
* Fit pi-ai's payload to the gateway: Chat Completions gets the session's cache key (pi-ai sends it
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Anthropic cache retention changes only existing cache-control markers in serialized content. */
|
|
2
|
+
export declare const CLAUDE_CACHE_TTLS: readonly ["default", "5m", "1h"];
|
|
3
|
+
export type ClaudeCacheTtl = typeof CLAUDE_CACHE_TTLS[number];
|
|
4
|
+
/**
|
|
5
|
+
* Set an explicit TTL on the Anthropic payload's existing ephemeral cache breakpoints.
|
|
6
|
+
* @param payload - serialized Anthropic request; borrowed, never mutated.
|
|
7
|
+
* @param ttl - user preference captured for this request; default preserves the original payload.
|
|
8
|
+
* @returns the original payload for default, or a copy with known cache-control slots updated.
|
|
9
|
+
*/
|
|
10
|
+
export declare function withClaudeCacheTtl(payload: Record<string, unknown>, ttl: ClaudeCacheTtl): Record<string, unknown>;
|
package/lib/llm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The VibeDev gateway's chat models on
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The VibeDev gateway's chat models on `vibedev-gateway` and `vibedev-relay`, so
|
|
3
|
+
* normal and relay models sit in separate picker groups next to the Harness's
|
|
4
|
+
* other providers, sharing the VibeDev account and balance.
|
|
5
5
|
*
|
|
6
6
|
* The catalog comes from the gateway (`GET /v1/models`) with the credential
|
|
7
7
|
* requests use, so nothing is listed before a sign-in: the catalog is per
|
|
@@ -22,18 +22,23 @@
|
|
|
22
22
|
import type { Context } from '@deepseek-ai/cordis';
|
|
23
23
|
import type { GatewayCredential } from './adapter.js';
|
|
24
24
|
import type { GatewayModel } from './catalog.js';
|
|
25
|
+
import type { ClaudeCacheTtl } from './cache-ttl.js';
|
|
25
26
|
export { GatewayAdapter, INSUFFICIENT_BALANCE_CODE, SIGN_IN_REQUIRED_CODE } from './adapter.js';
|
|
26
27
|
export type { GatewayAdapterOptions, GatewayCredential } from './adapter.js';
|
|
27
28
|
export { parseCatalog } from './catalog.js';
|
|
28
29
|
export type { GatewayModel } from './catalog.js';
|
|
29
30
|
/** The route the gateway's chat models are listed under. */
|
|
30
31
|
export declare const VIBEDEV_ROUTE = "vibedev-gateway";
|
|
32
|
+
/** The relay group shares the VibeDev account and keeps the gateway's complete model IDs. */
|
|
33
|
+
export declare const VIBEDEV_RELAY_ROUTE = "vibedev-relay";
|
|
31
34
|
/** What the route needs from the rest of the plugin. */
|
|
32
35
|
export interface GatewayModelsOptions {
|
|
33
36
|
/** Gateway origin, without a trailing slash. */
|
|
34
37
|
readonly origin: string;
|
|
35
38
|
/** The name pickers and the Models page show for the route. */
|
|
36
39
|
readonly displayName: string;
|
|
40
|
+
/** Relay provider group label, default 中转. */
|
|
41
|
+
readonly relayDisplayName?: string;
|
|
37
42
|
/** The credential for the next request, from the plugin's credential chain. */
|
|
38
43
|
readonly resolveCredential: () => Promise<GatewayCredential | undefined>;
|
|
39
44
|
/** Hand a credential the gateway refused back to its owner. */
|
|
@@ -47,6 +52,8 @@ export interface GatewayModelsOptions {
|
|
|
47
52
|
readonly catalogRefreshMinutes?: number;
|
|
48
53
|
readonly catalogTimeoutMs?: number;
|
|
49
54
|
readonly cacheRetention?: 'none' | 'short' | 'long';
|
|
55
|
+
/** Saved Claude Messages cache TTL; default leaves the SDK's markers unchanged. */
|
|
56
|
+
readonly claudeCacheTtl?: () => ClaudeCacheTtl;
|
|
50
57
|
/** A model request that may have been charged ended (the account reads the balance again). */
|
|
51
58
|
readonly onRequestEnded?: () => void;
|
|
52
59
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Naming metadata for relay chat models; the gateway id itself is never rewritten. */
|
|
2
|
+
/** Presentation and family identity parsed from one exact gateway model id. */
|
|
3
|
+
export interface RelayIdentity {
|
|
4
|
+
readonly relay: boolean;
|
|
5
|
+
readonly baseId: string;
|
|
6
|
+
/** Decimal text for display only; it is never applied to catalog prices. */
|
|
7
|
+
readonly multiplier?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Read relay markers without changing routing identity.
|
|
11
|
+
* @param id - exact gateway model id.
|
|
12
|
+
* @returns whether it is a relay model, its family id and any display multiplier.
|
|
13
|
+
*/
|
|
14
|
+
export declare function relayIdentity(id: string): RelayIdentity;
|
|
15
|
+
/**
|
|
16
|
+
* Format a catalog label, keeping gateway-authored readable names.
|
|
17
|
+
* @param id - exact gateway model id (the only source of the rate).
|
|
18
|
+
* @param displayName - nonempty gateway display name, when supplied.
|
|
19
|
+
* @returns the normal name, or a relay name with an optional multiplier.
|
|
20
|
+
*/
|
|
21
|
+
export declare function modelDisplayName(id: string, displayName?: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibedev-si/dsh-vibedev",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "VibeDev 账号与模型:在 DeepSeek Harness 里登录 VibeDev,与 DeepSeek 账号并存,使用 VibeDev 网关的模型(Claude、GPT 等),并生成图片、视频、音乐和播客 · VibeDev account and models for DeepSeek Harness: sign in to VibeDev next to the DeepSeek account and use the VibeDev gateway's models (Claude, GPT and more), plus image, video, music and podcast generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|