@acosmi/sdk-ts 2.12.0 → 2.14.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/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ All notable changes to `@acosmi/sdk-ts` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.14.0] - 2026-08-02 — inputModalities 开放值域归一 (open modality domain)
9
+
10
+ 模态标签的值域由**网关托管模型目录**持有,靠运营动作扩张(`video` 自 2026-06-20 起已是合法值),不靠发 SDK 新版。此前 SDK 在两处把它当成封闭集处理:`InputModality` 类型只列 `text|image`,且 `input_modalities`(snake_case)归一化分支按这份硬编码集裁剪数组——而 camelCase 分支从不裁剪。线上 wire 恒为 camelCase,所以那个过滤器从未真正执行过(死代码),但它把错误语义写进了契约。本版收敛为对称透传,并把数据字段的类型开放。
11
+
12
+ 同一形态的封闭枚举在 CrabCode 客户端(Rust 侧)造成过真实事故:一行目录数据声明 `video`,整个网关模型列表在所有客户端上打空数周。**扩模态的次序是硬的:先客户端、再 SDK、最后网关白名单**。
13
+
14
+ ### Changed
15
+
16
+ - **`normalizeInputModalities` 两分支对称** — snake_case 分支不再按 `{text, image}` 白名单裁剪,只做键名归一 + 剔除非字符串元素(畸形值)。camelCase 分支行为不变(本就原样透传)。**行为影响仅限**上游改发 snake_case 的假设场景;现网 camelCase 路径逐字节不变。
17
+ - **`InputModality` 加 `'video'`** — 该联合体现在的定位是「**查询用**的已知标签集」(`modelSupportsInputModality` / `findFirstModelByInputModality` 的 `modality` 参数),保留自动补全。
18
+ - **`ManagedModel.inputModalities` 类型放开为 `InputModalityTag[]`** — 数据字段照收目录里的任何标签,未知模态不再被类型谎报成不可能出现。既有消费方(`includes('image')` 族判定)零改动。
19
+
20
+ ### Added
21
+
22
+ - **`InputModalityTag`(类型)** — 模态标签的**开放**值域(即 `string`;已知取值见 `InputModality`)。规则是「查询用 `InputModality`(有补全),数据用 `InputModalityTag`(照收未知标签)」。
23
+
24
+ ## [2.13.0] - 2026-08-01 — 邀请奖励窗口重置券 (window-reset credits)
25
+
26
+ 邀请奖励从"送 token"改为**送窗口重置次数**:被邀请人激活并达到用量门槛后给邀请人发一张重置券,每张可清空一次滚动窗口已用量(只动窗口用量原语,**月度额度池零触碰**)。SDK 加性新增总览查询与核销两个客户端方法,核销支持 `clientRequestId` 幂等键。全部加性,既有调用零改动。
27
+
28
+ ### Added
29
+
30
+ - **`Client.getWindowResetSummary(signal?)`** — 查询当前用户窗口重置券总览(`GET /entitlements/window-reset/summary`);返回 `WindowResetSummary`。`userId` 由网关从鉴权态解析,客户端永不传。用于个人中心邀请栏与 429 窗口限额弹窗展示「还剩几张券 + 最近到期时间 + 邀请进度」。
31
+ - **`Client.redeemWindowReset({ clientRequestId?, signal? })`** — 消费一张重置券清空当前滚动窗口已用量(`POST /entitlements/window-reset/redeem`),返回 `{ remaining }`(扣减后剩余张数)。**幂等键语义**:同一 `clientRequestId` 重放不二次扣券(网关按该键返回首次结果),网络重试 / 用户连点必须复用同一 ID,换 ID = 换一次真实扣券;不传则不幂等。业务错按 SDK 惯例抛 `BusinessError`(message 含机器码):`NO_AVAILABLE_CREDIT`(无可用券)/ `NO_WINDOW_USAGE`(当前窗口无已用量,不扣券)。
32
+ - **`WindowResetSummary`(类型)** — `{ availableCount, nextExpireAt: string | null, totalGranted, totalUsed, qualifiedInvites, pendingInvites }`:可用券张数、可用券中最早到期时间(无券为 `null`)、累计发放 / 已用张数,以及邀请已达标 / 待达标数。
33
+
8
34
  ## [2.12.0] - 2026-07-11 — 5 小时窗口软限额 (windowOverridable + 继续开关)
9
35
 
10
36
  后端把 5 小时窗口改为**软限额**:默认开启(到达 5h 仅提醒、自动继续消耗周配额),用户可关成严格模式(到达即等待恢复);周窗维持硬限。429 响应体加性新增 `windowOverridable`(5h 严格模式=true,可续跑;周窗/显式禁止/灰度关=false,硬等待),额度总览加 `windowFiveHourContinueEnabled` 与 `WindowLimitStatus.overridable`,并新增设置「继续」开关的客户端方法。全部加性,向后兼容——旧字段/旧调用零改动,老网关不返回新字段时按硬等待处理。
@@ -59,6 +85,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
59
85
  - **类型** — `EmbeddingRequest`/`EmbeddingData`/`EmbeddingResponse`/`RerankRequest`/`RerankResult`/`RerankResponse`。
60
86
  - **`listModels` / `listModelsWithStatus` 新增 `opts.includeLocked`** — `true` 时请求 `/managed-models?picker=1` 全集模式:网关把越档模型作为 `Locked=true` 补回返全集,供 C 端选择器展示「付费订阅区」+ 置灰升级引导。缺省行为不变(只返有桶模型,向后兼容)。全集模式不写 `modelCache`,避免 locked 模型混入可用模型集。
61
87
 
88
+ ## [2.8.0] - 2026-06-16 — 登录 302 重定向承接(successRedirectURL)
89
+
90
+ > 本条目为 2026-08-02 补记(发版时 CHANGELOG 漏记;事实源 = 独立仓 v2.8.0 tag / npm 2.8.0 / 父仓同步 commit `1f91c394`)。
91
+
92
+ ### Added
93
+
94
+ - **`LoginOptions.successRedirectURL`(可选)** — 登录成功后的 302 重定向目标(issue C「302 重定向发版」承接);不传时行为与 2.7.0 完全一致。additive minor,既有调用零改动。
95
+
62
96
  ## [2.7.0] - 2026-06-11 — 远控管理面补齐 + BYOK 密钥客户端 + Chat Bridge CRUD(Phase 7B)
63
97
 
64
98
  补齐远控核心交互之外的全部管理面(此前下游 CrabCode 只能裸 fetch),新增 BYO 模型密钥客户端,落地 chat-bridge integration/credential 管理面 CRUD——云端控制台与下游调用的是同一组端点同一份租户隔离数据,天然互通。全部方法逐字段对齐 nexus-v4 handler 真实 wire 形状(契约 §12/§14/§18 附录 A)。
@@ -941,6 +975,31 @@ Additive minor。公开类型 / 方法签名零移除、零改名。契约见 `d
941
975
  - 36/36 vitest 全绿,源码 typecheck/lint/build 0 错误
942
976
  - 翻车机制:`prepublishOnly` 仅跑源码 typecheck/vitest/build,不验证 packed product 在 consumer 视角能否解析
943
977
 
978
+ [2.14.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.14.0
979
+ [2.13.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.13.0
980
+ [2.12.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.12.0
981
+ [2.11.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.11.0
982
+ [2.10.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.10.0
983
+ [2.9.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.9.0
984
+ [2.8.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.8.0
985
+ [2.7.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.7.0
986
+ [2.6.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.6.0
987
+ [2.5.1]: https://github.com/acosmi/sdk-ts/releases/tag/v2.5.1
988
+ [2.4.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.4.0
989
+ [2.3.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.3.0
990
+ [2.2.1]: https://github.com/acosmi/sdk-ts/releases/tag/v2.2.1
991
+ [2.2.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.2.0
992
+ [2.1.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.1.0
993
+ [2.0.1]: https://github.com/acosmi/sdk-ts/releases/tag/v2.0.1
994
+ [2.0.0]: https://github.com/acosmi/sdk-ts/releases/tag/v2.0.0
995
+ [1.9.0]: https://github.com/acosmi/sdk-ts/releases/tag/v1.9.0
996
+ [1.6.0]: https://github.com/acosmi/sdk-ts/releases/tag/v1.6.0
997
+ [1.5.1]: https://github.com/acosmi/sdk-ts/releases/tag/v1.5.1
998
+ [1.5.0]: https://github.com/acosmi/sdk-ts/releases/tag/v1.5.0
999
+ [1.4.2]: https://github.com/acosmi/sdk-ts/releases/tag/v1.4.2
1000
+ [1.4.1]: https://github.com/acosmi/sdk-ts/releases/tag/v1.4.1
1001
+ [1.4.0]: https://github.com/acosmi/sdk-ts/releases/tag/v1.4.0
1002
+ [1.3.2]: https://github.com/acosmi/sdk-ts/releases/tag/v1.3.2
944
1003
  [1.3.1]: https://github.com/acosmi/sdk-ts/releases/tag/v1.3.1
945
1004
  [1.3.0]: https://github.com/acosmi/sdk-ts/releases/tag/v1.3.0
946
1005
  [1.2.0]: https://github.com/acosmi/sdk-ts/releases/tag/v1.2.0
@@ -948,3 +1007,6 @@ Additive minor。公开类型 / 方法签名零移除、零改名。契约见 `d
948
1007
  [1.0.2]: https://github.com/acosmi/sdk-ts/releases/tag/v1.0.2
949
1008
  [1.0.1]: https://github.com/acosmi/sdk-ts/releases/tag/v1.0.1
950
1009
  [1.0.0]: https://www.npmjs.com/package/@acosmi/sdk-ts/v/1.0.0
1010
+
1011
+ <!-- 1.7.0 / 1.8.0 / 1.8.1 / 2.5.0 为未单独发版的内部迭代(无 git tag、无 npm 版本,内容并入下一个发布),故无链接定义。
1012
+ 2026-08-02 实证:git ls-remote --tags(v1.6.0 直跳 v1.9.0、v2.4.0 直跳 v2.5.1)+ npm view @acosmi/sdk-ts versions 同形。 -->
package/README.md CHANGED
@@ -582,6 +582,7 @@ const client = new Client({ serverURL: process.env.ACOSMI_SERVER_URL!, store: ne
582
582
  | **Tools** | `listTools`, `getTool` |
583
583
  | **Wallet** | `getWalletStats`, `getWalletTransactions` |
584
584
  | **Entitlements** | `getBalance`, `getBalanceDetail`, `listEntitlements`, `listConsumeRecords`, `claimMonthlyFree`, `getByModel`, `listBuckets`, `listCoefficients`, `invalidateCoefficientCache` |
585
+ | **Entitlements — 窗口重置券**(v2.13.0+) | `getWindowResetSummary`(邀请奖励券总览), `redeemWindowReset`(核销一张券清空当前窗口已用量;`clientRequestId` 为幂等键) |
585
586
  | **Packages** | `listTokenPackages`, `getTokenPackageDetail`, `buyTokenPackage`, `getOrderStatus`, `listMyOrders`, `waitForPayment` |
586
587
  | **Notifications** | `listNotifications`, `getUnreadCount`, `markNotificationRead`, `markAllNotificationsRead`, `deleteNotification`, `registerDevice`, `unregisterDevice`, `listNotificationPreferences`, `updateNotificationPreference` |
587
588
  | **Notifications — WebSocket** | `connect`, `disconnect`, `isConnected` (实时推送订阅;浏览器走原生 WebSocket,Node 18-21 需自装 `ws`,Node 22+ 用原生) |
@@ -2814,6 +2814,46 @@ var Client = class _Client {
2814
2814
  );
2815
2815
  return { enabled: resp.data.enabled };
2816
2816
  }
2817
+ /**
2818
+ * [W-MEMBERSHIP 2026-08-01 邀请奖励] 查询当前用户窗口重置券总览 (v2.13+)。
2819
+ *
2820
+ * 重置券由邀请奖励发放 (被邀请人激活并达到用量门槛后计一次), 每张可清空一次滚动窗口已用量
2821
+ * (见 redeemWindowReset)。userId 由网关从鉴权态解析, 客户端永不传。
2822
+ * 用于个人中心邀请栏与 429 窗口限额弹窗展示"还剩几张券 + 最近到期时间 + 邀请进度"。
2823
+ *
2824
+ * @returns 券余量 / 最近到期 / 累计发放与使用 / 邀请已达标与待达标数。
2825
+ */
2826
+ async getWindowResetSummary(signal) {
2827
+ const resp = await this.doJSON(
2828
+ "GET",
2829
+ "/entitlements/window-reset/summary",
2830
+ null,
2831
+ signal
2832
+ );
2833
+ return resp.data;
2834
+ }
2835
+ /**
2836
+ * [W-MEMBERSHIP 2026-08-01 邀请奖励] 消费一张窗口重置券, 清空当前滚动窗口已用量 (v2.13+)。
2837
+ *
2838
+ * **幂等键语义**: 传 `clientRequestId` 时同一 ID 重放**不会二次扣券** — 网关按该键返回首次
2839
+ * 结果 (`remaining` 与首次一致)。网络重试 / 用户连点必须**复用同一 ID**; 换 ID = 换一次真实
2840
+ * 扣券。不传则不幂等, 每次调用都是一次真实扣券。
2841
+ *
2842
+ * 业务错 (信封 `code != 0`) 按 SDK 惯例抛 `BusinessError` (message 含机器码), 常见两种:
2843
+ * - `NO_AVAILABLE_CREDIT` — 无可用券 (未发放 / 已用尽 / 已过期)
2844
+ * - `NO_WINDOW_USAGE` — 当前窗口无已用量, 无可重置 (不扣券)
2845
+ *
2846
+ * @returns 扣减后剩余可用券张数 { remaining }。
2847
+ */
2848
+ async redeemWindowReset(opts) {
2849
+ const resp = await this.doJSON(
2850
+ "POST",
2851
+ "/entitlements/window-reset/redeem",
2852
+ { clientRequestId: opts?.clientRequestId },
2853
+ opts?.signal
2854
+ );
2855
+ return { remaining: resp.data.remaining };
2856
+ }
2817
2857
  /**
2818
2858
  * 查询单个模型的能力矩阵
2819
2859
  * 优先从 listModels 缓存读取, miss 时调用 listModels 刷新
@@ -3568,9 +3608,7 @@ function normalizeInputModalities(models) {
3568
3608
  if (Array.isArray(m.inputModalities)) continue;
3569
3609
  const snake = m.input_modalities;
3570
3610
  if (Array.isArray(snake)) {
3571
- m.inputModalities = snake.filter(
3572
- (v) => v === "text" || v === "image"
3573
- );
3611
+ m.inputModalities = snake.filter((v) => typeof v === "string");
3574
3612
  }
3575
3613
  }
3576
3614
  return models;