@vibedev-si/dsh-vibedev 0.11.6 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -3
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/client/client.account-center.js +6 -1
- package/client/client.js +101 -3
- package/lib/account/index.d.ts +2 -0
- package/lib/audio/request.d.ts +3 -2
- package/lib/auth/login.d.ts +58 -0
- package/lib/auth/remote-callback.d.ts +34 -0
- package/lib/auth/sign-in-state.d.ts +8 -2
- package/lib/gateway/catalog.d.ts +55 -3
- package/lib/gateway/paid-path.d.ts +1 -1
- package/lib/index.d.ts +9 -0
- package/lib/index.js +1174 -108
- package/lib/pricing.d.ts +48 -10
- package/lib/runtime.d.ts +14 -3
- package/lib/speech/availability.d.ts +39 -0
- package/lib/speech/gateway.d.ts +69 -0
- package/lib/speech/host.d.ts +131 -0
- package/lib/speech/index.d.ts +37 -0
- package/lib/speech/recognition.d.ts +40 -0
- package/lib/speech/sign-in.d.ts +34 -0
- package/lib/speech/synthesis.d.ts +38 -0
- package/lib/speech/wave.d.ts +33 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -10,6 +10,31 @@
|
|
|
10
10
|
|
|
11
11
|
本插件由 `dsh-media` 改名而来,见下面的「从 dsh-media 升级」。
|
|
12
12
|
|
|
13
|
+
## 0.12.0 用户可见更新
|
|
14
|
+
|
|
15
|
+
0.11.7 没有单独发布,它的远程登录也包含在 0.12.0 里(见本节最后一条)。
|
|
16
|
+
|
|
17
|
+
**语音输入和朗读可以走 VibeDev 了**:插件向 DSH 0.2.3-alpha.3 起的语音注册表注册两个云端提供方,都走 VibeDev 网关,费用从 VibeDev 余额扣:
|
|
18
|
+
|
|
19
|
+
- **`vibedev-asr`(语音识别)**:把录音发到网关识别,按音频秒数计费,不足 1 秒按 1 秒算。
|
|
20
|
+
- **`vibedev-tts`(朗读)**:边合成边播放,24 kHz 音频,音色 stella(默认)和 tide。按计费字符计费,一个汉字算 2 个。
|
|
21
|
+
- **没登录 VibeDev 时**:两个提供方都显示「需要登录 VibeDev」,登录后马上可用。
|
|
22
|
+
- **登录入口**:新增客户端服务 `vibedevSignIn`(`open()`),VibeDev 桌面的语音输入和朗读用它打开 VibeDev 登录。
|
|
23
|
+
- **旧版宿主不受影响**:在 DSH 0.2.3-alpha.2,或没有语音功能的宿主上,插件什么都不注册,也不报错,其余功能照常。
|
|
24
|
+
|
|
25
|
+
**Agent 的媒体工具不再列出实时语音模型**:网关目录里的 `vibedev-asr`、`vibedev-tts` 只给语音输入和朗读用。`media_models` 不再列出它们,`audio_generate`、`audio_transcribe` 也不会选用;按名字指定时,会提示它不是媒体模型。
|
|
26
|
+
|
|
27
|
+
**按字计费的语音模型会报价**:目录里声明 `billing_unit: "character"` 的语音模型,生成前会按实际发出的文本估价,例如「约 ¥0.0036(¥0.0003/计费字符,汉字按 2 个算,共 12 个计费字符),实际以网关结算为准」。
|
|
28
|
+
- 计数规则:汉字按目录里的 `han_character_weight` 计,默认 2;其余每个字符算 1,空格、标点和自动加的 `@AudioN` 标记都算。
|
|
29
|
+
- `media_models` 和账户中心的模型价格页也会显示这个单位。
|
|
30
|
+
|
|
31
|
+
**云环境和远程访问里也能「登录 VibeDev」**(原 0.11.7):以前登录只会回到本机 `http://127.0.0.1:<端口>`。在云主机上,浏览器在你自己的设备上,授权码送不回服务器,登录一直超时,界面显示「暂无可用模型」。
|
|
32
|
+
|
|
33
|
+
- **开启方式**:在主机的配置里设置 `remoteSignInBaseUrl: https://<主机ID>.h.vibedev.studio`(只填源,https,不带路径)。只有显式设置才启用,留空就是原来的本机登录;填了不合规则的值会在日志里说明并保持本机登录。
|
|
34
|
+
- **流程**:点「登录 VibeDev」后,链接在你**当前的浏览器**新标签页打开(服务器上不开系统浏览器),页面显示等待登录完成。同意后网关回到这台主机的 `/api/dsh-vibedev/sign-in/callback`(只有经远程入口登录的主人能访问),插件校验 state 和 code,把这次回调请求里远程入口附带的 `X-VibeDev-Edge-Assertion` 作为 `edge_assertion` 一起换取令牌。回调页提示「登录成功,可以关闭此页,回到 VibeDev 继续」。
|
|
35
|
+
- **出错时**:网关返回 403 `REMOTE_SIGN_IN_OWNER_MISMATCH` 时提示「这台主机不是由你当前登录的账号打开的」;回调缺少或重复了断言头,不请求网关,直接提示从远程入口重新打开主机。超时、state 不符等沿用原有提示。授权码、令牌和断言原文都不写日志。
|
|
36
|
+
- **不变**:桌面版的本机回调、令牌保存与刷新、`token_type: 'app'`、计费都不变;本机登录的换令牌请求不带 `edge_assertion`。
|
|
37
|
+
|
|
13
38
|
## 0.11.6 用户可见更新
|
|
14
39
|
|
|
15
40
|
**配音尽量一次生成**:实测同一模型读同一句话,两次生成的时长可以差 2 秒(3.3 秒对 5.3 秒),语速和停顿波动很大。用多次独立调用拼接长旁白时,即使音色一致,节奏也会一段一段不一样。`audio_generate` 的说明(英文,给模型看)现在提醒 Agent:
|
|
@@ -387,7 +412,7 @@ VibeDev 开着时发布的 `popup` 公告,现在会在下一次读取消息时
|
|
|
387
412
|
## 费用
|
|
388
413
|
|
|
389
414
|
- VibeDev 的聊天模型按用量计费,价格以 VibeDev 网关为准。
|
|
390
|
-
-
|
|
415
|
+
- 图片按张计费,视频按秒计费(参考视频的时长也计入),音乐和播客按次计费,语音按原始秒(按服务商返回的原始时长,可能和播放时长不同)或按计费字符计费(汉字按 2 个算),视模型而定,转写按分钟计费。`media_models` 会列出当前价格;目录没有给出价格的模型显示「未定价」,不代表免费。
|
|
391
416
|
- 按视频 Token 计价的模型(目录里的 `video_pricing`)按分辨率和有无参考视频、参考音频、参考图(含首尾帧)分档,例如「480p 无参考视频 ¥60.06/百万 Token(预计 ¥0.5819/秒)」。生成前的金额只是预估:每秒预估价 ×(输出时长 + 所有参考视频时长),最终按实际视频 Token 结算。参考视频时长未知、目录没有每秒预估价或计价方式当前版本不支持时,显示「无法预估;按实际视频 Token 用量结算」,不会当成免费或未定价。视频生成后费用仍在确认(`billing_status: pending`)时,视频照常保存,只是费用待确认,不会重新生成。
|
|
392
417
|
- 视频和音频的扣费、释放及未知状态只按网关明确的账务回执展示;失败或取消本身不能证明未扣费。视频提交后无法取消。
|
|
393
418
|
- 视频和音频提交结果待确认时,保留原操作编号与已落盘请求,只用原 Key 和原请求核对,不自动创建新编号。默认首轮总计最多 3 次尝试,之后最多 30 次后台核对,核对窗口从原任务创建起共 5 分钟;这些默认值沿用 0.3.11。次数、上限、截止时间和退避时间均落盘,刷新、同号调用或重启不会重置预算;429 本身不证明未提交,等待网关的 Retry-After 后才核对。网关明确永久歧义时停止同键核对并保留 unknown;没有任务 ID 的记录也受默认 3 小时最长跟踪时间约束,最终为 lost/unknown,不表示可以自动换新编号。已取得任务 ID 后只查询和下载原任务。结果已生成但费用仍在结算(`settlement_pending`)时照常保存,不会重新生成。
|
|
@@ -407,7 +432,7 @@ VibeDev 开着时发布的 `popup` 公告,现在会在下一次读取消息时
|
|
|
407
432
|
| Claude 提示词缓存保留时间 | 默认 | 可选默认、5分钟、1小时;保存后用于后续 Claude Messages 请求,默认不是关闭缓存。 |
|
|
408
433
|
| 默认生图 / 视频 / 音乐 / 播客 / 语音合成 / 转写模型 | 空 | 留空时由 Agent 按模型目录选择;可以填模型 id 或别名。 |
|
|
409
434
|
|
|
410
|
-
另有几项只能在配置文件(`cordis.patch.yml` 中 `dsh-vibedev` 一行)里改:`displayName`(普通模型分组名,默认 `VibeDev`)、`relayDisplayName`(中转模型分组名,默认「中转」)、`preferredModels`(排在最前的 VibeDev 模型)、`openBrowserOnSignIn`(登录时是否自动打开系统浏览器,默认开)、`catalogRefreshMinutes`(模型目录定时刷新间隔,默认 30 分钟;是没人打开余额卡片、账号菜单或设置时的兜底)、`client`(登录时报给网关的客户端名称,默认 `vibedev-plugin`)、`primary`(作为应用的主账号显示,默认关,VibeDev 应用里开)、`gatewayFetch`(注册网关抓取提供方 `vibedev-gateway`,默认关;仍由 `web` 行的 `fetchProvider` 决定是否选中)、`chatConsent.endpoint` 与 `chatConsent.callbackUrl`(VibeDev 桌面「消息」一次授权的授权接口和 Matrix 回调,见「聊天一次授权」)。
|
|
435
|
+
另有几项只能在配置文件(`cordis.patch.yml` 中 `dsh-vibedev` 一行)里改:`displayName`(普通模型分组名,默认 `VibeDev`)、`relayDisplayName`(中转模型分组名,默认「中转」)、`preferredModels`(排在最前的 VibeDev 模型)、`openBrowserOnSignIn`(登录时是否自动打开系统浏览器,默认开)、`remoteSignInBaseUrl`(云主机 / 远程访问的登录地址,如 `https://<主机ID>.h.vibedev.studio`,默认空即本机登录)、`catalogRefreshMinutes`(模型目录定时刷新间隔,默认 30 分钟;是没人打开余额卡片、账号菜单或设置时的兜底)、`client`(登录时报给网关的客户端名称,默认 `vibedev-plugin`)、`primary`(作为应用的主账号显示,默认关,VibeDev 应用里开)、`gatewayFetch`(注册网关抓取提供方 `vibedev-gateway`,默认关;仍由 `web` 行的 `fetchProvider` 决定是否选中)、`chatConsent.endpoint` 与 `chatConsent.callbackUrl`(VibeDev 桌面「消息」一次授权的授权接口和 Matrix 回调,见「聊天一次授权」)。
|
|
411
436
|
|
|
412
437
|
## 从 dsh-media 升级
|
|
413
438
|
|
|
@@ -512,6 +537,31 @@ npm run build
|
|
|
512
537
|
|
|
513
538
|
## English
|
|
514
539
|
|
|
540
|
+
### What changes in 0.12.0
|
|
541
|
+
|
|
542
|
+
0.11.7 was never published; its remote sign-in ships in 0.12.0 (the last item below).
|
|
543
|
+
|
|
544
|
+
**Voice input and read-aloud through VibeDev**: the plugin registers two cloud providers with the speech registries of DSH 0.2.3-alpha.3 and later, both through the VibeDev gateway and billed to the VibeDev balance:
|
|
545
|
+
|
|
546
|
+
- **`vibedev-asr` (speech recognition)**: sends the recording to the gateway; billed per second of audio, rounded up.
|
|
547
|
+
- **`vibedev-tts` (read-aloud)**: streams 24 kHz audio while it is synthesized, voices stella (default) and tide; billed per billable character, a Chinese character counting as two.
|
|
548
|
+
- **Signed out**: both providers say a VibeDev sign-in is needed and are ready right after signing in.
|
|
549
|
+
- **Sign-in entry**: the new client service `vibedevSignIn` (`open()`) opens the VibeDev sign-in for the VibeDev desktop's voice input and read-aloud.
|
|
550
|
+
- **Older hosts are unaffected**: on DSH 0.2.3-alpha.2, or a host without speech, the plugin registers nothing and reports nothing; everything else works as before.
|
|
551
|
+
|
|
552
|
+
**The agent's media tools no longer list realtime speech models**: `vibedev-asr` and `vibedev-tts` in the gateway catalog serve voice input and read-aloud only. `media_models` no longer lists them, `audio_generate` and `audio_transcribe` never choose them, and naming one says it is not a media model.
|
|
553
|
+
|
|
554
|
+
**Speech billed per character is quoted**: a speech model whose catalog declares `billing_unit: "character"` is quoted from the text actually sent before it runs, for example "about ¥0.0036 (¥0.0003 per billable character, Chinese characters count as 2, 12 billable characters); final billing follows the gateway receipt".
|
|
555
|
+
- Counting: a Chinese character counts as the catalog's `han_character_weight` (default 2), every other character as 1, spaces, punctuation and the automatic `@AudioN` markers included.
|
|
556
|
+
- `media_models` and the account center's model prices name the unit.
|
|
557
|
+
|
|
558
|
+
**"Sign in to VibeDev" works on cloud hosts and remote access** (formerly 0.11.7): sign-in used to return only to `http://127.0.0.1:<port>`. On a cloud host the browser runs on your own device, so the code never reached the server, sign-in always timed out and no models were listed.
|
|
559
|
+
|
|
560
|
+
- **Turning it on**: set `remoteSignInBaseUrl: https://<host id>.h.vibedev.studio` in the host's configuration (an https origin, no path). Only an explicit value turns it on; empty keeps the local sign-in, and a value that breaks the rule is logged and the local sign-in kept.
|
|
561
|
+
- **Flow**: "Sign in to VibeDev" opens the link in a new tab of **your current browser** (no system browser on the server) and the page shows it is waiting. After you agree, the gateway returns to this host's `/api/dsh-vibedev/sign-in/callback` (reachable only by the owner signed in through the remote entry); the plugin checks state and code and redeems the code with the remote entry's `X-VibeDev-Edge-Assertion` from that callback request as `edge_assertion`. The page then says you can close it and return to VibeDev.
|
|
562
|
+
- **Errors**: the gateway's 403 `REMOTE_SIGN_IN_OWNER_MISMATCH` reads "This host was not opened by the account you are signing in with"; a callback without exactly one assertion header is refused without asking the gateway. Timeouts and a wrong state keep their messages. Codes, tokens and assertions are never logged.
|
|
563
|
+
- **Unchanged**: the desktop's loopback callback, token storage and refresh, `token_type: 'app'` and billing; a local sign-in's redeem carries no `edge_assertion`.
|
|
564
|
+
|
|
515
565
|
### What changes in 0.11.6
|
|
516
566
|
|
|
517
567
|
**Generate a voice-over in one go**: the same model reading the same sentence twice came out 2 s apart (3.3 s against 5.3 s), so pace and pauses vary a lot from call to call, and a long narration stitched from separate calls changes rhythm part by part even when the voice stays the same. The `audio_generate` description now tells the agent to generate one batch of voice-over in one continuous call where it can, rather than many separate calls; when it must be split, to keep the same references, the same format and sample rate, and to submit the parts one after another in the same piece of work. The `@AudioN` markers of 0.11.5 were checked on the real gateway (no markers read aloud, nothing left out) and are unchanged.
|
|
@@ -776,7 +826,7 @@ For explicit joint acceptance, run node scripts/verify-fetch-joint.mjs with one
|
|
|
776
826
|
|
|
777
827
|
**Audio models**: whether an audio model makes music, a podcast, speech or a transcription comes from its catalog declaration (`audio.generation_kind`), never from its name; a model that declares no kind is listed but cannot generate. Each model is sent only the fields it declares in `request_fields`, with the text in its `prompt_field`: music takes `prompt`, `lyrics`, `genre`, `mood` and `gender`; a podcast `prompt` and `source_url`; speech what it declares (Seed: `text_prompt`, `references`, `audio_config`, `watermark`). Speech reference limits (count, size, length, exclusions) and the sample rates of each output format come from the gateway. Music and podcasts take no references, format, sample rate or duration.
|
|
778
828
|
|
|
779
|
-
**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. Charges, releases and unknown outcomes follow explicit gateway billing receipts; failure or cancellation alone does not prove no charge. A submitted video cannot be cancelled. One operation generates once: an unconfirmed submission keeps its original operation and unknown state without another automatic creation POST; only a declared read-only lookup capability can reconcile it, 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.
|
|
829
|
+
**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) or per billable character (a Chinese character counting as two), depending on the model, 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. Charges, releases and unknown outcomes follow explicit gateway billing receipts; failure or cancellation alone does not prove no charge. A submitted video cannot be cancelled. One operation generates once: an unconfirmed submission keeps its original operation and unknown state without another automatic creation POST; only a declared read-only lookup capability can reconcile it, 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.
|
|
780
830
|
|
|
781
831
|
**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`), `primary` (show the account as the app's main account; off by default, on in the VibeDev app), `gatewayFetch` (register the gateway fetch provider `vibedev-gateway`; off by default, and the `web` row's `fetchProvider` still selects it) and `chatConsent.endpoint` with `chatConsent.callbackUrl` (the consent endpoint and Matrix callback of the desktop Messages sign-in; see "One-step chat consent") are set in the profile's `cordis.patch.yml` row `dsh-vibedev`.
|
|
782
832
|
|
package/THIRD-PARTY-NOTICES.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
THIRD-PARTY NOTICES · @vibedev-si/dsh-vibedev 0.
|
|
1
|
+
THIRD-PARTY NOTICES · @vibedev-si/dsh-vibedev 0.12.0
|
|
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.
|
|
@@ -380,6 +380,7 @@ window.__ModuleLoader__.load({
|
|
|
380
380
|
priceUnitSecond: "CNY / 秒",
|
|
381
381
|
priceUnitOriginalSecond: "CNY / 原始秒",
|
|
382
382
|
priceUnitMinute: "CNY / 分钟",
|
|
383
|
+
priceUnitCharacter: "CNY / 计费字符(汉字按 2 个算)",
|
|
383
384
|
priceTiers: "上下文与媒体价格档位",
|
|
384
385
|
priceWholeRequest: "整单使用所在档位单价;区间为 (下界, 上界],第一档包括 0。",
|
|
385
386
|
priceMarginal: "仅超出阈值的部分使用对应档位单价。",
|
|
@@ -523,6 +524,7 @@ window.__ModuleLoader__.load({
|
|
|
523
524
|
priceUnitSecond: "CNY / second",
|
|
524
525
|
priceUnitOriginalSecond: "CNY / original second",
|
|
525
526
|
priceUnitMinute: "CNY / minute",
|
|
527
|
+
priceUnitCharacter: "CNY / billable character (Chinese characters count as 2)",
|
|
526
528
|
priceTiers: "Context and media price tiers",
|
|
527
529
|
priceWholeRequest: "The whole request uses its matching tier. Intervals are (lower, upper]; the first tier includes 0.",
|
|
528
530
|
priceMarginal: "Only usage above each threshold uses that tier price.",
|
|
@@ -2234,6 +2236,8 @@ window.__ModuleLoader__.load({
|
|
|
2234
2236
|
signInStorage: "无法在本机保存登录信息,请检查应用数据目录的访问权限。",
|
|
2235
2237
|
signInCallback: "无法启动本地登录回调,请检查安全软件后重试。",
|
|
2236
2238
|
signInUnknown: "登录未完成,请重新登录。",
|
|
2239
|
+
signInOwnerMismatch: "这台主机不是由你当前登录的账号打开的。请用打开这台主机的 VibeDev 账号登录。",
|
|
2240
|
+
signInEdgeAssertion: "登录回调没有经过 VibeDev 远程入口,请从远程入口打开这台主机后重新登录。",
|
|
2237
2241
|
signInDiagnostic: "登录诊断信息",
|
|
2238
2242
|
loadFailed: "读取 VibeDev 账号状态失败,请稍后再试。",
|
|
2239
2243
|
sidebarSignedIn: "VibeDev 已登录",
|
|
@@ -6388,7 +6392,8 @@ window.__ModuleLoader__.load({
|
|
|
6388
6392
|
generation: "priceUnitGeneration",
|
|
6389
6393
|
second: "priceUnitSecond",
|
|
6390
6394
|
original_second: "priceUnitOriginalSecond",
|
|
6391
|
-
minute: "priceUnitMinute"
|
|
6395
|
+
minute: "priceUnitMinute",
|
|
6396
|
+
character: "priceUnitCharacter"
|
|
6392
6397
|
};
|
|
6393
6398
|
const feeKeys = {
|
|
6394
6399
|
input: "priceInput",
|
package/client/client.js
CHANGED
|
@@ -662,6 +662,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
662
662
|
busy: "sign-in",
|
|
663
663
|
actionError: void 0
|
|
664
664
|
});
|
|
665
|
+
const tab = this.state.view?.signInMode === "remote" ? this.options.reserveWindow?.() : void 0;
|
|
665
666
|
try {
|
|
666
667
|
const response = await this.fetch(`${ACCOUNT_ROUTE}/sign-in`, {
|
|
667
668
|
method: "POST",
|
|
@@ -670,8 +671,10 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
670
671
|
});
|
|
671
672
|
const body = await response.json().catch(() => void 0);
|
|
672
673
|
if (!response.ok || typeof body?.url !== "string") throw new Error(typeof body?.error?.message === "string" ? body.error.message : `HTTP ${response.status}`);
|
|
673
|
-
if (
|
|
674
|
+
if (tab !== void 0) tab.navigate(body.url);
|
|
675
|
+
else if (body.opened !== true) this.options.openWindow?.(body.url);
|
|
674
676
|
} catch {
|
|
677
|
+
tab?.close();
|
|
675
678
|
this.set({ actionError: {
|
|
676
679
|
kind: "sign-in",
|
|
677
680
|
message: "Sign-in request failed."
|
|
@@ -858,7 +861,9 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
858
861
|
"gateway-unavailable": "signInUnavailable",
|
|
859
862
|
protocol: "signInProtocol",
|
|
860
863
|
storage: "signInStorage",
|
|
861
|
-
callback: "signInCallback"
|
|
864
|
+
callback: "signInCallback",
|
|
865
|
+
"edge-assertion": "signInEdgeAssertion",
|
|
866
|
+
"owner-mismatch": "signInOwnerMismatch"
|
|
862
867
|
};
|
|
863
868
|
return attempt.errorCode !== void 0 && Object.hasOwn(keys, attempt.errorCode) ? keys[attempt.errorCode] : "signInUnknown";
|
|
864
869
|
}
|
|
@@ -885,7 +890,9 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
885
890
|
"gateway-unavailable",
|
|
886
891
|
"protocol",
|
|
887
892
|
"storage",
|
|
888
|
-
"callback"
|
|
893
|
+
"callback",
|
|
894
|
+
"edge-assertion",
|
|
895
|
+
"owner-mismatch"
|
|
889
896
|
].includes(attempt.errorCode ?? "") ? attempt.errorCode : void 0,
|
|
890
897
|
stage,
|
|
891
898
|
Number.isInteger(attempt.httpStatus) && Number(attempt.httpStatus) >= 100 && Number(attempt.httpStatus) <= 599 ? `HTTP ${attempt.httpStatus}` : void 0,
|
|
@@ -1280,6 +1287,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1280
1287
|
priceUnitSecond: "CNY / 秒",
|
|
1281
1288
|
priceUnitOriginalSecond: "CNY / 原始秒",
|
|
1282
1289
|
priceUnitMinute: "CNY / 分钟",
|
|
1290
|
+
priceUnitCharacter: "CNY / 计费字符(汉字按 2 个算)",
|
|
1283
1291
|
priceTiers: "上下文与媒体价格档位",
|
|
1284
1292
|
priceWholeRequest: "整单使用所在档位单价;区间为 (下界, 上界],第一档包括 0。",
|
|
1285
1293
|
priceMarginal: "仅超出阈值的部分使用对应档位单价。",
|
|
@@ -1423,6 +1431,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1423
1431
|
priceUnitSecond: "CNY / second",
|
|
1424
1432
|
priceUnitOriginalSecond: "CNY / original second",
|
|
1425
1433
|
priceUnitMinute: "CNY / minute",
|
|
1434
|
+
priceUnitCharacter: "CNY / billable character (Chinese characters count as 2)",
|
|
1426
1435
|
priceTiers: "Context and media price tiers",
|
|
1427
1436
|
priceWholeRequest: "The whole request uses its matching tier. Intervals are (lower, upper]; the first tier includes 0.",
|
|
1428
1437
|
priceMarginal: "Only usage above each threshold uses that tier price.",
|
|
@@ -3120,6 +3129,8 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
3120
3129
|
signInStorage: "无法在本机保存登录信息,请检查应用数据目录的访问权限。",
|
|
3121
3130
|
signInCallback: "无法启动本地登录回调,请检查安全软件后重试。",
|
|
3122
3131
|
signInUnknown: "登录未完成,请重新登录。",
|
|
3132
|
+
signInOwnerMismatch: "这台主机不是由你当前登录的账号打开的。请用打开这台主机的 VibeDev 账号登录。",
|
|
3133
|
+
signInEdgeAssertion: "登录回调没有经过 VibeDev 远程入口,请从远程入口打开这台主机后重新登录。",
|
|
3123
3134
|
signInDiagnostic: "登录诊断信息",
|
|
3124
3135
|
loadFailed: "读取 VibeDev 账号状态失败,请稍后再试。",
|
|
3125
3136
|
sidebarSignedIn: "VibeDev 已登录",
|
|
@@ -3272,6 +3283,8 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
3272
3283
|
signInStorage: "Could not save the sign-in locally. Check access to the app data folder.",
|
|
3273
3284
|
signInCallback: "Could not start the local sign-in callback. Check local security software and try again.",
|
|
3274
3285
|
signInUnknown: "Could not complete sign-in. Please sign in again.",
|
|
3286
|
+
signInOwnerMismatch: "This host was not opened by the account you are signing in with. Sign in with the VibeDev account that opened this host.",
|
|
3287
|
+
signInEdgeAssertion: "The sign-in callback did not come through the VibeDev remote entry. Open this host through the remote entry and sign in again.",
|
|
3275
3288
|
signInDiagnostic: "Sign-in diagnostic details",
|
|
3276
3289
|
loadFailed: "The VibeDev account could not be read. Try again later.",
|
|
3277
3290
|
sidebarSignedIn: "VibeDev signed in",
|
|
@@ -5937,6 +5950,77 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
5937
5950
|
] });
|
|
5938
5951
|
}
|
|
5939
5952
|
//#endregion
|
|
5953
|
+
//#region src/speech/sign-in.ts
|
|
5954
|
+
/**
|
|
5955
|
+
* The client service that opens the VibeDev sign-in for another plugin: `vibedevSignIn`. Pure declarations only, so
|
|
5956
|
+
* the browser half bundles this module as it is and the Host half publishes the same contract in its types.
|
|
5957
|
+
*
|
|
5958
|
+
* Contract (dsh-vibedev 0.12.0). The VibeDev desktop's voice input and read-aloud offer "登录 VibeDev" while their
|
|
5959
|
+
* provider is a VibeDev one (`vibedev-asr`, `vibedev-tts`; any `vibedev-*` id) and it reports
|
|
5960
|
+
* `{ phase: 'unavailable', reason: 'sign-in-required' }` or fails with `sign-in-required`; that action calls
|
|
5961
|
+
* `open()`. The service is provided in a client's root scope while that client can read the VibeDev account (the
|
|
5962
|
+
* Host answered its account read, as it does for the owner's desktop window or web page; a peer the plugin's routes
|
|
5963
|
+
* refuse never gets it), and is withdrawn when the plugin's client unloads. Consumers follow it with
|
|
5964
|
+
* `ctx.inject(['vibedevSignIn'], …)` and offer the action only while it is present; they declare the context member
|
|
5965
|
+
* themselves, for example:
|
|
5966
|
+
*
|
|
5967
|
+
* ```ts
|
|
5968
|
+
* import type { VibeDevSignIn } from '@vibedev-si/dsh-vibedev'
|
|
5969
|
+
* declare module '@deepseek-ai/cordis' {
|
|
5970
|
+
* interface Context { vibedevSignIn: VibeDevSignIn }
|
|
5971
|
+
* }
|
|
5972
|
+
* ```
|
|
5973
|
+
* @module dsh-vibedev/speech/sign-in
|
|
5974
|
+
*/
|
|
5975
|
+
/** The service name: `ctx.get('vibedevSignIn')`. Kept as it is: the VibeDev desktop looks it up by this name. */
|
|
5976
|
+
const VIBEDEV_SIGN_IN_SERVICE = "vibedevSignIn";
|
|
5977
|
+
//#endregion
|
|
5978
|
+
//#region src/client/sign-in-service.ts
|
|
5979
|
+
/**
|
|
5980
|
+
* `vibedevSignIn` in the browser half: the VibeDev desktop's voice input and read-aloud open the VibeDev sign-in
|
|
5981
|
+
* through it while their provider is a VibeDev one (see `src/speech/sign-in.ts` for the contract).
|
|
5982
|
+
*
|
|
5983
|
+
* The service is there while this client can read the VibeDev account, as the DeepSeek account's `accountSignIn` is
|
|
5984
|
+
* there while the Peer may watch that account: from the account store's first answer on (the Host's account route
|
|
5985
|
+
* answers the owner's windows only, so a peer it refuses never gets the service) until the plugin's client unloads.
|
|
5986
|
+
* `open()` is the account section's 登录.
|
|
5987
|
+
*
|
|
5988
|
+
* Kept free of React and of the DOM, so it can be tested in node.
|
|
5989
|
+
*/
|
|
5990
|
+
/**
|
|
5991
|
+
* Provide `vibedevSignIn` while the account store has read the account.
|
|
5992
|
+
* @param ctx - the plugin's client context.
|
|
5993
|
+
* @param account - the account store the Settings section and the sidebar share.
|
|
5994
|
+
* @returns stop: withdraw the service and stop following the store.
|
|
5995
|
+
*/
|
|
5996
|
+
function provideSignIn(ctx, account) {
|
|
5997
|
+
if (typeof ctx.provide !== "function") return () => {};
|
|
5998
|
+
const host = ctx;
|
|
5999
|
+
const service = Object.freeze({ open: () => {
|
|
6000
|
+
account.signIn();
|
|
6001
|
+
} });
|
|
6002
|
+
let withdraw;
|
|
6003
|
+
const release = () => {
|
|
6004
|
+
const provided = withdraw;
|
|
6005
|
+
withdraw = void 0;
|
|
6006
|
+
if (provided === void 0) return;
|
|
6007
|
+
try {
|
|
6008
|
+
Promise.resolve(provided()).catch(() => void 0);
|
|
6009
|
+
} catch {}
|
|
6010
|
+
};
|
|
6011
|
+
const update = () => {
|
|
6012
|
+
const readable = account.getSnapshot().view !== void 0;
|
|
6013
|
+
if (readable && withdraw === void 0) withdraw = host.provide(VIBEDEV_SIGN_IN_SERVICE, service);
|
|
6014
|
+
else if (!readable) release();
|
|
6015
|
+
};
|
|
6016
|
+
const unsubscribe = account.subscribe(update);
|
|
6017
|
+
update();
|
|
6018
|
+
return () => {
|
|
6019
|
+
unsubscribe();
|
|
6020
|
+
release();
|
|
6021
|
+
};
|
|
6022
|
+
}
|
|
6023
|
+
//#endregion
|
|
5940
6024
|
//#region src/client/index.ts
|
|
5941
6025
|
/**
|
|
5942
6026
|
* dsh-vibedev browser half:
|
|
@@ -5987,6 +6071,19 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
5987
6071
|
openWindow: (url) => {
|
|
5988
6072
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
5989
6073
|
},
|
|
6074
|
+
reserveWindow: () => {
|
|
6075
|
+
const tab = window.open("", "_blank");
|
|
6076
|
+
if (tab === null) return void 0;
|
|
6077
|
+
tab.opener = null;
|
|
6078
|
+
return {
|
|
6079
|
+
navigate: (url) => {
|
|
6080
|
+
tab.location.href = url;
|
|
6081
|
+
},
|
|
6082
|
+
close: () => {
|
|
6083
|
+
tab.close();
|
|
6084
|
+
}
|
|
6085
|
+
};
|
|
6086
|
+
},
|
|
5990
6087
|
onFocus: (listener) => {
|
|
5991
6088
|
window.addEventListener("focus", listener);
|
|
5992
6089
|
return () => {
|
|
@@ -6007,6 +6104,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
6007
6104
|
const t = ctx.locale.bind(LOCALE_NAMESPACE);
|
|
6008
6105
|
const account = new AccountStore(windowOptions());
|
|
6009
6106
|
ctx.effect(() => account.start(), "dsh-vibedev: account reads");
|
|
6107
|
+
ctx.effect(() => provideSignIn(ctx, account), "dsh-vibedev: vibedevSignIn");
|
|
6010
6108
|
const announcements = new AnnouncementStore();
|
|
6011
6109
|
ctx.effect(() => {
|
|
6012
6110
|
announcements.start();
|
package/lib/account/index.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ export interface AccountView {
|
|
|
67
67
|
readonly url: string;
|
|
68
68
|
readonly expiresAt: number;
|
|
69
69
|
};
|
|
70
|
+
/** `remote`: this is a cloud host; the page opens the sign-in link in the user's browser (absent: the desktop flow). */
|
|
71
|
+
readonly signInMode?: 'remote';
|
|
70
72
|
/** Safe sign-in progress or the most recent terminal diagnostic. */
|
|
71
73
|
readonly attempt?: SignInAttempt;
|
|
72
74
|
/** VibeDev chat models the pickers list now, and why there are none. */
|
package/lib/audio/request.d.ts
CHANGED
|
@@ -169,8 +169,9 @@ export interface PreparedAudio {
|
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* Everything before an audio submission: choose the model, check every field
|
|
172
|
-
* against its declaration, upload and measure speech references, price it
|
|
173
|
-
*
|
|
172
|
+
* against its declaration, upload and measure speech references, price it
|
|
173
|
+
* (speech billed per character on the text as sent, `@AudioN` markers
|
|
174
|
+
* included), confirm the spending, and build the task under the operation's key.
|
|
174
175
|
* @param runtime - the media runtime.
|
|
175
176
|
* @param call - the tool call or host call.
|
|
176
177
|
* @param request - what to generate.
|
package/lib/auth/login.d.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* 127.0.0.1; the gateway issues a plugin session (`client=vibedev-plugin`)
|
|
6
6
|
* whose access token is refreshed with a rotating refresh token.
|
|
7
7
|
*
|
|
8
|
+
* Remote sign-in (0.11.7): a cloud host reached through the VibeDev remote entry sets `remoteBaseUrl`; the callback is
|
|
9
|
+
* then `https://<host id>.h.vibedev.studio/api/dsh-vibedev/sign-in/callback` on the host's own web server, and the
|
|
10
|
+
* redeem carries the remote entry's `X-VibeDev-Edge-Assertion` from that callback request as `edge_assertion`.
|
|
11
|
+
*
|
|
8
12
|
* Contract (gateway vibedev204):
|
|
9
13
|
* - browser: `{origin}/vibedev-link?callback=http://127.0.0.1:<port>/<path>&state&response_type=code&code_challenge&code_challenge_method=S256&client=vibedev-plugin`
|
|
10
14
|
* - `POST /api/v1/vibedev/link/redeem {code, code_verifier, token_type:'app', client, device_id, device_model, os_version}`
|
|
@@ -66,6 +70,47 @@ export interface PluginLoginOptions {
|
|
|
66
70
|
/** The client name the gateway records for the sign-in (it picks the key the usage is billed to). Defaults to `vibedev-plugin`. */
|
|
67
71
|
readonly client?: string;
|
|
68
72
|
readonly log?: (message: string) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Remote sign-in (a cloud host reached through the VibeDev remote entry): the host's public origin, such as
|
|
75
|
+
* `https://<host id>.h.vibedev.studio`. The gateway then returns to `${remoteBaseUrl}${REMOTE_CALLBACK_PATH}` on this
|
|
76
|
+
* host instead of a loopback port, no system browser is opened (the user's own browser opens the link), and the
|
|
77
|
+
* redeem carries the callback request's `X-VibeDev-Edge-Assertion` as `edge_assertion`. Absent: the desktop flow.
|
|
78
|
+
*/
|
|
79
|
+
readonly remoteBaseUrl?: string;
|
|
80
|
+
/** Whether the remote callback route is registered on the host's web server; a remote sign-in fails at once without it. */
|
|
81
|
+
readonly remoteCallbackReady?: () => boolean;
|
|
82
|
+
}
|
|
83
|
+
/** The host route the gateway returns a remote sign-in to (registered on the DSH web server). */
|
|
84
|
+
export declare const REMOTE_CALLBACK_PATH = "/api/dsh-vibedev/sign-in/callback";
|
|
85
|
+
/** The header the VibeDev remote entry adds to every request it forwards to a host. */
|
|
86
|
+
export declare const EDGE_ASSERTION_HEADER = "x-vibedev-edge-assertion";
|
|
87
|
+
/** The gateway's refusal of a remote sign-in by someone other than the host's owner. */
|
|
88
|
+
export declare const OWNER_MISMATCH_CODE = "REMOTE_SIGN_IN_OWNER_MISMATCH";
|
|
89
|
+
/** What the remote callback request carried in `X-VibeDev-Edge-Assertion`. */
|
|
90
|
+
export type EdgeAssertionRead = {
|
|
91
|
+
readonly kind: 'one';
|
|
92
|
+
readonly value: string;
|
|
93
|
+
} | {
|
|
94
|
+
readonly kind: 'missing' | 'multiple' | 'malformed';
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Read the remote entry's assertion from the raw header list: exactly one header, holding one compact JWS
|
|
98
|
+
* (three base64url parts). Its signature is checked by the gateway, never here; it is never logged.
|
|
99
|
+
* @param rawHeaders - Node's `rawHeaders` (name, value, name, value, …), where repeated headers stay apart.
|
|
100
|
+
* @returns the assertion, or why there is no usable one.
|
|
101
|
+
*/
|
|
102
|
+
export declare function readEdgeAssertion(rawHeaders: readonly string[]): EdgeAssertionRead;
|
|
103
|
+
/**
|
|
104
|
+
* Check a configured remote sign-in origin: https, an origin only (no path, query, credentials).
|
|
105
|
+
* @param value - the setting.
|
|
106
|
+
* @returns the origin without a trailing slash, or undefined when blank.
|
|
107
|
+
* @throws Error naming the rule it breaks.
|
|
108
|
+
*/
|
|
109
|
+
export declare function remoteSignInOrigin(value: string | undefined): string | undefined;
|
|
110
|
+
/** One remote callback's answer page. */
|
|
111
|
+
export interface CallbackPage {
|
|
112
|
+
readonly status: number;
|
|
113
|
+
readonly html: string;
|
|
69
114
|
}
|
|
70
115
|
/** A sign-in waiting for the browser. */
|
|
71
116
|
export interface PendingSignIn {
|
|
@@ -101,10 +146,14 @@ export declare class PluginLogin {
|
|
|
101
146
|
private readonly listeners;
|
|
102
147
|
private readonly now;
|
|
103
148
|
private readonly origin;
|
|
149
|
+
/** The host's public origin for a remote sign-in, else undefined (the desktop's loopback flow). */
|
|
150
|
+
private readonly remoteBase;
|
|
104
151
|
/**
|
|
105
152
|
* @param options - gateway origin, storage and test seams.
|
|
106
153
|
*/
|
|
107
154
|
constructor(options: PluginLoginOptions);
|
|
155
|
+
/** Whether sign-in returns to this host through the remote entry (a cloud host) rather than a loopback port. */
|
|
156
|
+
get remote(): boolean;
|
|
108
157
|
private readStored;
|
|
109
158
|
private load;
|
|
110
159
|
/** Re-read after the credential provider becomes ready or its record changes, without starting a browser sign-in. */
|
|
@@ -162,6 +211,15 @@ export declare class PluginLogin {
|
|
|
162
211
|
opened: boolean;
|
|
163
212
|
}>;
|
|
164
213
|
private beginSignIn;
|
|
214
|
+
/**
|
|
215
|
+
* The remote callback route's request (`GET /api/dsh-vibedev/sign-in/callback` on the host's web server): finish the
|
|
216
|
+
* waiting remote sign-in, or answer why it cannot be finished. Always answers.
|
|
217
|
+
* @param url - the request URL (only its query is read).
|
|
218
|
+
* @param method - the request method.
|
|
219
|
+
* @param edge - what the request carried in `X-VibeDev-Edge-Assertion` (see {@link readEdgeAssertion}).
|
|
220
|
+
* @returns the page to answer with.
|
|
221
|
+
*/
|
|
222
|
+
receiveRemoteCallback(url: URL, method: string | undefined, edge: EdgeAssertionRead): Promise<CallbackPage>;
|
|
165
223
|
/** Sign out: revoke the session at the gateway (best effort) and forget it. */
|
|
166
224
|
signOut(): Promise<void>;
|
|
167
225
|
/** Stop a waiting sign-in. */
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The remote sign-in's return route on the host's own web server:
|
|
3
|
+
* `GET /api/dsh-vibedev/sign-in/callback?code&state`, registered with `auth: 'required'`, so only the host's owner
|
|
4
|
+
* (signed in through the VibeDev remote entry) reaches it. An exact route outranks the `/api` prefix the client
|
|
5
|
+
* connection owns.
|
|
6
|
+
*
|
|
7
|
+
* The request's `X-VibeDev-Edge-Assertion` (one header, read from the raw header list so a repeated header is seen)
|
|
8
|
+
* goes to the gateway as `edge_assertion`; it, the code and the tokens are never logged.
|
|
9
|
+
* @module dsh-vibedev/auth/remote-callback
|
|
10
|
+
*/
|
|
11
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
12
|
+
import type { PluginLogin } from './login.js';
|
|
13
|
+
/** The part of the DSH web server this route uses (`webServer.register`). */
|
|
14
|
+
export interface RemoteCallbackServer {
|
|
15
|
+
register(route: {
|
|
16
|
+
kind: 'exact';
|
|
17
|
+
path: string;
|
|
18
|
+
auth?: 'required';
|
|
19
|
+
handler: (req: IncomingMessage, res: ServerResponse, peer?: unknown) => void | Promise<void>;
|
|
20
|
+
}): () => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The route's handler.
|
|
24
|
+
* @param login - the plugin's sign-in.
|
|
25
|
+
* @returns a web-server handler.
|
|
26
|
+
*/
|
|
27
|
+
export declare function remoteCallbackHandler(login: Pick<PluginLogin, 'receiveRemoteCallback'>): (req: IncomingMessage, res: ServerResponse, peer?: unknown) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Register the route.
|
|
30
|
+
* @param server - the DSH web server.
|
|
31
|
+
* @param login - the plugin's sign-in.
|
|
32
|
+
* @returns the disposer.
|
|
33
|
+
*/
|
|
34
|
+
export declare function registerRemoteCallback(server: RemoteCallbackServer, login: Pick<PluginLogin, 'receiveRemoteCallback'>): () => void;
|
|
@@ -5,7 +5,11 @@ export interface SignInAttempt {
|
|
|
5
5
|
readonly expiresAt: number;
|
|
6
6
|
readonly gatewayOrigin: string;
|
|
7
7
|
readonly stage?: 'listen' | 'device' | 'redeem' | 'persist';
|
|
8
|
-
readonly errorCode?: 'network' | 'timeout' | 'gateway-refused' | 'gateway-unavailable' | 'protocol' | 'storage' | 'callback'
|
|
8
|
+
readonly errorCode?: 'network' | 'timeout' | 'gateway-refused' | 'gateway-unavailable' | 'protocol' | 'storage' | 'callback'
|
|
9
|
+
/** Remote sign-in: the callback carried no single remote-entry assertion (X-VibeDev-Edge-Assertion). */
|
|
10
|
+
| 'edge-assertion'
|
|
11
|
+
/** Remote sign-in: the gateway's 403 REMOTE_SIGN_IN_OWNER_MISMATCH (the host is not the signing-in account's). */
|
|
12
|
+
| 'owner-mismatch';
|
|
9
13
|
readonly httpStatus?: number;
|
|
10
14
|
readonly networkCode?: string;
|
|
11
15
|
}
|
|
@@ -16,6 +20,8 @@ export declare function transportFailure(error: unknown): SignInFailure;
|
|
|
16
20
|
/** A fixed bilingual explanation suitable for exposed rejection messages. */
|
|
17
21
|
export declare function failureMessage(attempt: Pick<SignInAttempt, 'errorCode' | 'stage' | 'httpStatus'>): string;
|
|
18
22
|
/** Only our fixed explanation and escaped safe enum/status fields reach the browser. */
|
|
19
|
-
export declare function failurePage(attempt: SignInAttempt): string;
|
|
23
|
+
export declare function failurePage(attempt: SignInAttempt, returnTo?: string): string;
|
|
24
|
+
/** A link back to the VibeDev page this remote sign-in started from. */
|
|
25
|
+
export declare function returnLink(url: string, chinese: string, english: string): string;
|
|
20
26
|
/** Explicit log allowlist; adding fields to the public attempt never expands log output. */
|
|
21
27
|
export declare function attemptLog(event: 'request' | 'phase' | 'response' | 'terminal', attempt: SignInAttempt): string;
|
package/lib/gateway/catalog.d.ts
CHANGED
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
* `billing_unit` and the declared limits (references, output formats and their
|
|
15
15
|
* sample rates). An audio model that declares no kind is listed but cannot be
|
|
16
16
|
* chosen for generation: neither its name nor its id decides what it makes.
|
|
17
|
+
* Speech billed per character (`billing_unit: "character"`) states what one
|
|
18
|
+
* Chinese character counts as (`han_character_weight`, 2 when undeclared).
|
|
19
|
+
*
|
|
20
|
+
* Realtime speech models (`media_type: "speech"`, or a `speech` block, such as
|
|
21
|
+
* `vibedev-asr` and `vibedev-tts`) serve the desktop's voice input and
|
|
22
|
+
* read-aloud, not the media tools: they are kept apart from the media models
|
|
23
|
+
* ({@link parseCatalog}), whatever their modalities say, so a name that refers
|
|
24
|
+
* to one can be answered with what it is.
|
|
17
25
|
*
|
|
18
26
|
* Image models may declare their size tiers and aspect ratios
|
|
19
27
|
* (`capabilities.image_sizes`, `capabilities.image_ratios`); they are read as
|
|
@@ -95,9 +103,11 @@ export interface VideoCapabilities {
|
|
|
95
103
|
/**
|
|
96
104
|
* What a price is charged per: one generation, one second of output, one
|
|
97
105
|
* second of ORIGINAL audio (speech is billed on the provider's original length,
|
|
98
|
-
* not on what plays back after processing),
|
|
106
|
+
* not on what plays back after processing), one minute of input audio, or one
|
|
107
|
+
* billable character of the text read aloud (a Chinese character counts as the
|
|
108
|
+
* model's `han_character_weight`, every other character as 1).
|
|
99
109
|
*/
|
|
100
|
-
export type PriceUnit = 'generation' | 'second' | 'original_second' | 'minute';
|
|
110
|
+
export type PriceUnit = 'generation' | 'second' | 'original_second' | 'minute' | 'character';
|
|
101
111
|
/** One price tier: video tiers are resolutions (`720p`), image tiers size buckets (`1K`). */
|
|
102
112
|
export interface MediaPriceTier {
|
|
103
113
|
readonly tier: string;
|
|
@@ -148,7 +158,10 @@ export type VideoPricingIssue = 'unknown-schema' | 'invalid';
|
|
|
148
158
|
export declare const AUDIO_GENERATION_KINDS: readonly ["music", "podcast", "speech", "transcription"];
|
|
149
159
|
export type AudioGenerationKind = typeof AUDIO_GENERATION_KINDS[number];
|
|
150
160
|
/** How an audio model is billed (`audio.billing_unit`). */
|
|
151
|
-
export
|
|
161
|
+
export declare const AUDIO_BILLING_UNITS: readonly ["generation", "original_second", "minute", "character"];
|
|
162
|
+
export type AudioBillingUnit = typeof AUDIO_BILLING_UNITS[number];
|
|
163
|
+
/** What one Chinese character counts as under per-character billing when the model does not say (`han_character_weight`). */
|
|
164
|
+
export declare const DEFAULT_HAN_CHARACTER_WEIGHT = 2;
|
|
152
165
|
/** The reference audio a speech model takes (a voice to imitate), as the catalog declares it. */
|
|
153
166
|
export interface AudioReferenceLimits {
|
|
154
167
|
readonly min: number;
|
|
@@ -188,6 +201,12 @@ export interface AudioCapabilities {
|
|
|
188
201
|
/** The request fields the model accepts, under their wire names. */
|
|
189
202
|
readonly requestFields: readonly string[];
|
|
190
203
|
readonly billingUnit?: AudioBillingUnit;
|
|
204
|
+
/**
|
|
205
|
+
* Per-character billing: what one Chinese character (a CJK unified ideograph) counts as, every other character
|
|
206
|
+
* counting 1 (`audio.han_character_weight`, a positive number). Set to {@link DEFAULT_HAN_CHARACTER_WEIGHT} for a
|
|
207
|
+
* model billed per character that declares none; absent otherwise.
|
|
208
|
+
*/
|
|
209
|
+
readonly hanCharacterWeight?: number;
|
|
191
210
|
readonly references?: AudioReferenceLimits;
|
|
192
211
|
readonly outputFormats?: readonly AudioOutputFormat[];
|
|
193
212
|
readonly defaultFormat?: string;
|
|
@@ -242,6 +261,24 @@ export interface MediaModel {
|
|
|
242
261
|
readonly video?: VideoCapabilities;
|
|
243
262
|
readonly audio?: AudioCapabilities;
|
|
244
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* A realtime speech model of the catalog: speech recognition for voice input (`speech.lane: "asr"`) or synthesis for
|
|
266
|
+
* read-aloud (`"tts"`), on its own endpoints, for the desktop rather than the agent. It is not a media model: the media
|
|
267
|
+
* tools never list, choose or price it; it is kept only so a name that refers to one can be told what it is.
|
|
268
|
+
*/
|
|
269
|
+
export interface RealtimeSpeechModel {
|
|
270
|
+
readonly id: string;
|
|
271
|
+
readonly aliases?: readonly string[];
|
|
272
|
+
/** The lane its `speech` block names (`asr`, `tts`), in lower case; absent when it names none. */
|
|
273
|
+
readonly lane?: string;
|
|
274
|
+
}
|
|
275
|
+
/** A `/v1/models` body as the media tools read it. */
|
|
276
|
+
export interface ParsedCatalog {
|
|
277
|
+
/** The media models, in catalog order. */
|
|
278
|
+
readonly models: MediaModel[];
|
|
279
|
+
/** The realtime speech models, kept apart from the media models, in catalog order. */
|
|
280
|
+
readonly realtimeSpeech: RealtimeSpeechModel[];
|
|
281
|
+
}
|
|
245
282
|
type Json = Record<string, unknown>;
|
|
246
283
|
/**
|
|
247
284
|
* Parse a `video` capability block (or the legacy video fields inside `capabilities`).
|
|
@@ -272,10 +309,25 @@ export declare function parseVideoPricing(value: unknown): {
|
|
|
272
309
|
videoPricing?: VideoTokenPricing;
|
|
273
310
|
videoPricingIssue?: VideoPricingIssue;
|
|
274
311
|
};
|
|
312
|
+
/**
|
|
313
|
+
* Whether a catalog entry is a realtime speech model: `media_type: "speech"`, or a `speech` block (`vibedev-asr`,
|
|
314
|
+
* `vibedev-tts`). Such a model serves the desktop's voice input and read-aloud, never the media tools — whatever its
|
|
315
|
+
* modalities say: a read-aloud lane outputs audio, and would otherwise look like an audio generator.
|
|
316
|
+
* @param entry - one entry of `/v1/models`.
|
|
317
|
+
* @returns whether it is one.
|
|
318
|
+
*/
|
|
319
|
+
export declare function isRealtimeSpeechEntry(entry: unknown): boolean;
|
|
275
320
|
/**
|
|
276
321
|
* Parse a `/v1/models` body into its media models.
|
|
277
322
|
* @param body - `{data:[...]}` or a bare array.
|
|
278
323
|
* @returns the media models, in catalog order.
|
|
279
324
|
*/
|
|
280
325
|
export declare function parseMediaCatalog(body: unknown): MediaModel[];
|
|
326
|
+
/**
|
|
327
|
+
* Parse a `/v1/models` body into its media models, with the realtime speech models kept apart: they are never media
|
|
328
|
+
* models (see {@link isRealtimeSpeechEntry}), and are listed only so a name that refers to one can be told what it is.
|
|
329
|
+
* @param body - `{data:[...]}` or a bare array.
|
|
330
|
+
* @returns the media models and the realtime speech models, each in catalog order.
|
|
331
|
+
*/
|
|
332
|
+
export declare function parseCatalog(body: unknown): ParsedCatalog;
|
|
281
333
|
export {};
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* Whether an accepted request may have been charged.
|
|
7
7
|
* @param method - the HTTP method.
|
|
8
8
|
* @param path - the request path, without the query.
|
|
9
|
-
* @returns true for a POST to a generation or
|
|
9
|
+
* @returns true for a POST to a generation, transcription or speech endpoint.
|
|
10
10
|
*/
|
|
11
11
|
export declare function isPaidRequest(method: string, path: string): boolean;
|