@acosmi/sdk-ts 2.0.1 → 2.2.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,40 @@ 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.2.0] - 2026-05-29 — 托管模型图片/视频生成
9
+
10
+ Additive minor。公开类型 / 方法签名零移除、零改名。图片/视频生成与文本模型同属托管模型网关(同 `Client`、同 `models:chat` 鉴权面),仅 `capabilities.supports_image_generation` / `supports_video_generation` 的模型可用。计费结算在营销系统,SDK / 网关只负责调用与用量上报。
11
+
12
+ ### Added
13
+
14
+ - **`Client.generateImage(modelID, req, signal?)`** — 同步图片生成,`POST /managed-models/:id/images/generations`,返回 `ImageGenerationResponse`(`url` / `b64_json` / `revised_prompt`)。内部超时与 chat 同级(11min)容纳上游耗时。
15
+ - **`Client.generateVideo(modelID, req, signal?)`** — 创建异步视频任务,`POST /managed-models/:id/videos/generations`,返回 `VideoTaskResponse`(含 `taskId`)。
16
+ - **`Client.pollVideoTask(modelID, taskID, durationSeconds?, signal?)`** — 轮询视频任务,`GET /managed-models/:id/videos/tasks/:taskId`;`durationSeconds` 透传给网关在 `completed` 时上报真物理量(视频秒数)。
17
+ - 新类型:`ImageGenerationRequest` / `ImageGenerationResponse` / `VideoGenerationRequest` / `VideoTaskResponse`。
18
+ - `ModelCapabilities` 新增可选 `supports_image_generation?` / `supports_video_generation?`(上游未声明时为 `undefined`,调用方不得用模型名 substring 推断)。
19
+ - `doJSONFullRaw(method, path, body, signal?, timeoutMs?)` 新增可选 `timeoutMs`(默认 30s,向后兼容),图片生成传 chat 同级超时。
20
+
21
+ ### 网关侧适配范围
22
+
23
+ - OpenAI 兼容图片端点 + 火山引擎(即梦/豆包)视频任务 + **DashScope 通义万相(wanx)原生异步任务 API(图片 + 视频)**。DashScope 万相图片在网关内部建任务并轮询到终态后同步返回 URL(对 SDK 仍是一次 `generateImage`),视频走 `generateVideo` + `pollVideoTask`。
24
+
25
+ ## [2.1.0] - 2026-05-28 — 远程控制 CrabCode 多接入面
26
+
27
+ Additive minor。公开类型 / 方法签名零移除、零改名。契约见 `docs/audit/sdk-remote-control-contract-2026-05-27.md`。
28
+
29
+ ### Added
30
+
31
+ - **Acosmi Gateway URL 公共契约**:`serverURL` / `baseURL` / `baseUrl` 三别名 + `normalizeGatewayBaseURL()`(仅接受 `http`/`https`,拒绝 `ws`/`wss` 及空 host,规整尾斜杠)。详见 README §"Acosmi Gateway URL 公共契约"。
32
+ - **远程控制(CrabCode remote-control)**,`agentRuns` 命名空间下、事件协议独立于旧 `stream`:
33
+ - `agentRuns.createRemoteRun(req, signal?)` — `req.runtime` 固定 `'crabcode_remote'`,`runner` + `adapter` 必填。
34
+ - `agentRuns.streamRemoteControl(runId, signal?)` — 无 options 参数;`error` 恒非终结、`done`/`settle` 终结、从不抛异常。
35
+ - 11 事件 `RemoteControlEvent` union + helper `parseRemoteControlEvent(raw)`(wire→强类型,未知 type 返回 `null`)/ `isTerminalRemoteEvent(ev)`。
36
+ - 枚举:`AdapterKind`(6)/ `RunnerKind`(3)/ `PermissionPolicy` / `WorkspacePolicy`。
37
+ - 专用 scope `remote_control`(+ 3 子 scope):`remoteControlScopes()` / `ScopeRemoteControl`,**不进 `allScopes()`**,绝不复用 `models:chat` / `ai`。
38
+ - wire 约定按平面分(契约 §12):远控平面 = snake_case + 时长整数毫秒(`approval_timeout_ms`);唯一序列化出口 `RemoteSessionEvent.ToWire()`,跨语言金标 fixtures 护栏(`test/remote-control-wire-golden.test.ts` ⇄ 后端 `wire_golden.json`)。
39
+ - **`chatbridge` 第三方聊天平台桥接类型骨架**(types-only,无 `client.chatBridge.*` 方法,Phase 7B 后端落地):导出类型 + 守卫 `isPlatform` / `isRegion` / `isIntegrationStatus` / `isChannelInboundEvent` / `asCredentialRef`。资源视图平面 = camelCase;secret 只入上游 vault,公共面仅见 `CredentialRef` + fingerprint + 脱敏 metadata(契约 §16)。
40
+ - `subscription.getPlanByCode(planCode, signal?)` — 按 `planCode` 精确取单个可售订阅计划(复用 `listPlans` 客户端过滤,未命中返回 `null`;deep-review §12.3)。
41
+
8
42
  ## [2.0.1] - 2026-05-25 — Packaging fix
9
43
 
10
44
  ### Fixed
package/README.md CHANGED
@@ -6,11 +6,34 @@
6
6
 
7
7
  ## 状态
8
8
 
9
- - 主实现 / 事实标准:本 TS SDK 现为 Acosmi SDK 的主力实现。Go SDK [acosmi-sdk-go](https://github.com/acosmi/acosmi-sdk-go) 已暂停维护,待 TS 稳定后再从 TS 反向翻译补齐
10
- - 当前版本:**2.0.0**(Phase 3 复核 + 全量根治 BREAKING 升级,2026-05-25)。**Phase 3 复核**: 主仓 9 commit 闭环 20 P0 (RBAC 表达式统一 / PII 真落盘加密链 / K7 视频 webhook 幂等 / K8 OCR SSRF / K9 KYC main flow / admin 写端点错误码契约). **SDK 同步**: 新增 `casehall.getMyLawyerCredentialStatus()` + `enterprise.getMyEnterpriseKycStatus()` 律师/企业 OWNER 自查端点; `finance/types.ts` P2-016 PII 注释升级 (含 keyVersion v1/v2 payload 协议); 新建 `docs/pii-role-matrix.md` (4 角色 × 3 PII 级矩阵); admin 写端点错误码改 HTTP 状态码语义 (`200+{ok:false}` → `403/404/501`). **v1.x 历史**: 1.9.0 finance / 1.8.1 enterprise / 1.8.0 casehall / 1.7.0 csign+pricing / 1.6.0 endUserId+11min 保活. 详见 [CHANGELOG](./CHANGELOG.md).
11
- - 测试:发布前需通过 typecheck/lint/vitest/build/packed-tarball smoke (`npm run test:pack`)
12
- - API 参考文档:`npm run docs` TypeDoc 生成到 `docs/api/`
13
- - 包链接:[npm](https://www.npmjs.com/package/@acosmi/sdk-ts) · [GitHub Releases](https://github.com/acosmi/sdk-ts/releases)
9
+ - **主实现 / 事实标准**:本 TS SDK 现为 Acosmi SDK 的主力实现。Go SDK [acosmi-sdk-go](https://github.com/acosmi/acosmi-sdk-go) 已暂停维护,待 TS 稳定后再从 TS 反向翻译补齐。
10
+ - **当前 npm 版本:`2.1.0`**(远程控制 CrabCode 多接入面,2026-05-28)。
11
+ - **`v2.1.0`(已发布)**:远程控制 CrabCode 多接入面 —— `serverURL`/`baseURL` Gateway URL 公共契约(见下方小节)、`agentRuns.createRemoteRun` / `agentRuns.streamRemoteControl` + 11 事件 union(见 §Agent Runs → 远程控制)、`chatbridge` 第三方聊天平台桥接类型(types-only 骨架,见 §Chat Bridge)、专用 `remote_control` scope(不进 `allScopes()`)。契约见 `docs/audit/sdk-remote-control-contract-2026-05-27.md`。
12
+ - **v2.0.0 BREAKING(Phase 3 复核 + 全量根治,2026-05-25)摘要**:
13
+ - SDK 同步主仓 9 commit 闭环 20 P0(RBAC 表达式统一 / PII 真落盘加密链 / K7 视频 webhook 幂等 / K8 OCR SSRF / K9 KYC main flow / admin 写端点错误码契约)。
14
+ - 新增 `casehall.getMyLawyerCredentialStatus()` + `enterprise.getMyEnterpriseKycStatus()` 律师 / 企业 OWNER 自查端点(纯增量)。
15
+ - `finance/types.ts` P2-016 PII Javadoc 升级(含 `keyVersion` v1/v2 payload 协议 + 4 角色 × 3 PII 级矩阵)。
16
+ - 新建 `docs/pii-role-matrix.md`(4 角色:`platform_admin` / `s2s` / `lawyer` / `consumer`)。
17
+ - admin 写端点错误码改 HTTP 状态码语义(`200+{ok:false}` → `403/404/501`),上游契约整流。
18
+ - **升级路径详见下方 "v2.0.0 升级指引"**。
19
+ - **v1.x 历史链**:1.9.0 finance / 1.8.1 enterprise / 1.8.0 casehall / 1.7.0 csign+pricing+products+subscription / 1.6.0 endUserId+11min 保活 / 1.5.x 跨域共享 DTO + Compliance S1-S6 rollup / 1.4.x 浏览器 Web OAuth / 1.3.x compliance SDK / 1.2.x InputModality / 1.1.x agentRuns / 1.0.x 包发布修复。详见 [CHANGELOG](./CHANGELOG.md)。
20
+ - **测试**:发布前需通过 `typecheck` / `lint` / `vitest` / `build` / `test:pack`(packed-tarball consumer smoke)。
21
+ - **API 参考文档**:`npm run docs`(TypeDoc)生成到 `docs/api/`。
22
+ - **包链接**:[npm](https://www.npmjs.com/package/@acosmi/sdk-ts) · [GitHub Releases](https://github.com/acosmi/sdk-ts/releases)。
23
+
24
+ ### v2.0.0 升级指引
25
+
26
+ v2.0.0 标 BREAKING,但 **TS SDK 公开类型与方法签名零移除、零改名**;BREAKING 范围在网关后端,集成方按以下清单核对:
27
+
28
+ | 受影响场景 | 集成方动作 | 关联 |
29
+ |------------|----------|------|
30
+ | 持有 `ROLE_ADMIN` 角色(不是 `platform_admin`)想读 PII L3 字段(如发票税号、律师执照号) | **必须 review** — 网关 `SensitiveSerializer` 不再把 `ROLE_ADMIN` 当 `platform_admin` 别名 fail-OPEN,统一收敛为 4 角色严格白名单。仍需 PII L3 read 的角色须重新申请 `platform_admin` | `docs/pii-role-matrix.md` |
31
+ | 持有 admin 写端点 (`/admin/**/...`) 旧契约 — 期望 `200+{ok:false,code:xxx}` 业务错误码 | **必须改** — 改读 HTTP 状态码:`403` 鉴权不足 / `404` 资源不存在 / `501` `NOT_CONFIGURED_CODE` 网关未配置 provider;body 不再保证带业务码 | 主仓 `K10AdminController` |
32
+ | 用 `client.casehall.*` / `client.enterprise.*` 调律师 / 企业 OWNER 资质相关接口 | **零改动** — 新增 `getMyLawyerCredentialStatus()` / `getMyEnterpriseKycStatus()` 是纯增量,不影响既有方法 | `src/casehall/client.ts`、`src/enterprise/client.ts` |
33
+ | 读 `Invoice.taxNumber` / `Invoice.bankAccount` 等 PII 字段 | **零代码改动** — 字段名 / wire-format 不变,仅 Javadoc 标注从"脱敏"升级为"keyVersion v1/v2 真加密 + AAD field binding",运行时 transparent | `src/finance/types.ts` |
34
+ | 集成 v1.x 时按"`ROLE_ADMIN` 自动当 `platform_admin`"测试用例 | **必须改** — 删掉别名假设;测试角色显式写 `platform_admin` / `s2s` / `lawyer` / `consumer` 之一 | `docs/pii-role-matrix.md` §角色映射表 |
35
+
36
+ > v2.0.0 → v2.0.1 是纯 packaging fix(`package.json.files` 数组补 2 个 docs),无源码改动;从 v2.0.0 升 v2.0.1 不需要任何 review。
14
37
 
15
38
  ## 安装
16
39
 
@@ -23,7 +46,7 @@ npm install @acosmi/sdk-ts
23
46
  ```ts
24
47
  import { Client, allScopes } from '@acosmi/sdk-ts';
25
48
 
26
- const client = new Client({ serverURL: process.env.ACOSMI_SERVER_URL! });
49
+ const client = new Client({ baseURL: process.env.ACOSMI_BASE_URL! });
27
50
  await client.login('My App', allScopes());
28
51
 
29
52
  const resp = await client.chat('claude-opus-4-7', {
@@ -34,6 +57,45 @@ const resp = await client.chat('claude-opus-4-7', {
34
57
  console.log(resp.content);
35
58
  ```
36
59
 
60
+ ### Acosmi Gateway URL — `serverURL` / `baseURL` 公共契约 (v2.1+)
61
+
62
+ `Client` 配置中 `serverURL` / `baseURL` / `baseUrl` 三字段同语义、互为 alias,归一化后必须相等;任传其一即可,多写时 normalize 后冲突会立刻抛错。
63
+
64
+ ```ts
65
+ // 推荐拼写
66
+ const client = new Client({ baseURL: 'https://acosmi.com' });
67
+
68
+ // 与历史 serverURL 完全等价
69
+ const same = new Client({ serverURL: 'https://acosmi.com' });
70
+
71
+ // 多写一致 OK; 不一致抛错
72
+ new Client({ serverURL: 'https://a.example', baseURL: 'https://b.example' });
73
+ // → Error: Acosmi Gateway URL conflict: …
74
+ ```
75
+
76
+ **红线 (Phase 0 契约 §1-§2)** — Acosmi Gateway URL 是 `@acosmi/sdk-ts` 调 Acosmi nexus-v4 API 的根:
77
+
78
+ - 只接受 `http:` / `https:`;`ws:` / `wss:` 是 CrabCode `--sdk-url` RemoteIO 会话通道,**不是** SDK gateway URL,传入立刻抛错。
79
+ - agent-runs / managed-models / notifications WS / compliance 都从同一个 normalized base 派生;SDK 内部 `apiURL()` 自动追加 `/api/v4`,不会重复拼。
80
+ - 不推荐 runtime mutate `client.serverURL`;多 base 用 per-instance Client cache(例如 `Map<normalizedGatewayURL, Promise<Client>>`)。
81
+ - `complianceBaseURL` 是独立第二根地址,不被 `baseURL` alias 覆盖。
82
+
83
+ 公共 helper:
84
+
85
+ ```ts
86
+ import { Client, normalizeGatewayBaseURL, DEFAULT_GATEWAY_BASE_URL } from '@acosmi/sdk-ts';
87
+
88
+ normalizeGatewayBaseURL('https://gw.example/api/v4/'); // → 'https://gw.example/api/v4'
89
+ normalizeGatewayBaseURL('wss://session.example'); // → throw: only allows http/https
90
+ DEFAULT_GATEWAY_BASE_URL; // → 'https://acosmi.com'
91
+
92
+ const c = new Client({ baseURL: 'https://gw.example' });
93
+ c.getBaseURL(); // → 'https://gw.example' (= c.getServerURL())
94
+ c.apiURL('/agent-runs'); // → 'https://gw.example/api/v4/agent-runs'
95
+ ```
96
+
97
+ 详见 `docs/audit/sdk-remote-control-contract-2026-05-27.md`。
98
+
37
99
  ### 用户隔离 (v1.6.0+)
38
100
 
39
101
  `ChatRequest.endUserId` — 业务侧终端用户的稳定标识, **跨 provider 通用语义**, 不绑死 DeepSeek。SDK 自动按 wire-format 注入: OpenAI 顶层 `user_id` / Anthropic `metadata.user_id`; 网关侧校验并派生后送达上游, 命中三项隔离能力 (内容安全 / KV-cache / 调度)。
@@ -52,6 +114,62 @@ if (err) {
52
114
 
53
115
  不传 `endUserId` 时网关从认证身份 HMAC-SHA256 自动派生 32 字符稳定 id, 业务无感知。流式 + 同步 + Anthropic + OpenAI 四条路径均支持。
54
116
 
117
+ ## 图片 / 视频生成(托管模型网关,v2.2+)
118
+
119
+ 图片生成、视频生成与文本对话**同属托管模型网关**(同一个 `Client`、同一套 `models:chat` 鉴权面),**不是工作流**。只有 `capabilities.supports_image_generation` / `supports_video_generation` 为真的模型可调;计费结算在营销系统,SDK / 网关只做调用与用量上报。
120
+
121
+ **先按 capability 筛模型**:
122
+
123
+ ```ts
124
+ const models = await client.listModels();
125
+ const imageModel = models.find((m) => m.capabilities?.supportsImageGeneration);
126
+ const videoModel = models.find((m) => m.capabilities?.supportsVideoGeneration);
127
+ ```
128
+
129
+ ### 图片生成(同步)
130
+
131
+ `generateImage` 一次调用直接拿图(内部超时与 chat 同级 11min,容纳上游耗时;DashScope 万相图片在网关内部建任务并轮询到终态后同步返回,对 SDK 仍是一次调用)。
132
+
133
+ ```ts
134
+ const img = await client.generateImage(imageModel!.id, {
135
+ prompt: '一只在雪地里奔跑的柴犬,电影感光影',
136
+ width: 1024, // 缺省 1024
137
+ height: 1024, // 缺省 1024
138
+ style: 'cinematic', // 可选
139
+ });
140
+ console.log(img.url ?? img.b64_json); // ImageGenerationResponse: url / b64_json / revised_prompt / requestId
141
+ ```
142
+
143
+ ### 视频生成(异步:建任务 → 轮询)
144
+
145
+ `generateVideo` 返回 `taskId`,再用 `pollVideoTask` 轮询到 `completed`。`durationSeconds` 务必回传创建时的秒数——网关在 `completed` 时据此上报真实视频时长用量。
146
+
147
+ ```ts
148
+ const task = await client.generateVideo(videoModel!.id, {
149
+ prompt: '海浪拍打礁石的慢镜头',
150
+ resolution: '1280x720', // 可选
151
+ duration: 5, // 秒
152
+ });
153
+
154
+ let res = task;
155
+ while (res.status !== 'completed' && res.status !== 'failed') {
156
+ await new Promise((r) => setTimeout(r, 3000));
157
+ res = await client.pollVideoTask(videoModel!.id, task.taskId, 5); // 回传 duration=5
158
+ }
159
+ if (res.status === 'failed') throw new Error(res.error);
160
+ console.log(res.videoUrl); // VideoTaskResponse: taskId / status / videoUrl / error / requestId
161
+ ```
162
+
163
+ **请求字段速查**
164
+
165
+ | | 图片 `ImageGenerationRequest` | 视频 `VideoGenerationRequest` |
166
+ | --- | --- | --- |
167
+ | 必填 | `prompt` | `prompt` |
168
+ | 尺寸 | `width` / `height`(缺省 1024) | `resolution`(如 `"1280x720"`) |
169
+ | 其他 | `style` | `duration`(秒) |
170
+
171
+ > 字段是网关**通用契约**;某厂商支持哪些取值由上游模型决定(如万相尺寸 `宽*高` 星号格式由网关代转)。网关适配范围:OpenAI 兼容图片 + 火山引擎(即梦/豆包)视频 + DashScope 通义万相(wanx)原生异步任务(图片+视频)。
172
+
55
173
  ## 双格式红线(设计核心)
56
174
 
57
175
  SDK 同时提供 **Anthropic + OpenAI 两条 endpoint**,**等地位**,对应两个不同下游产品。
@@ -179,6 +297,75 @@ await client.agentRuns.cancel(run.runId); // safe to call from UI cancel buttons
179
297
  | `error` | 失败事件(`throwOnError:true` 默认会转 `AgentRunStreamError` 抛出) | `error.code`、`error.message`、`error.stage`、`error.retryable` |
180
298
  | `done` | 流终止 | `runId`、`status` |
181
299
 
300
+ ### 远程控制 — CrabCode remote-control(v2.1.0)
301
+
302
+ 远程控制是 Agent Run 的一个独立 runtime(`runtime: 'crabcode_remote'`),用于把 CrabCode 子进程的会话/工具/权限循环经服务端适配成 C 端可消费的事件流。它**不复用** `agentRuns.stream` 的旧事件 union,事件协议另成一套(契约 §4 的 11 事件)。
303
+
304
+ ```ts
305
+ import { Client, remoteControlScopes } from '@acosmi/sdk-ts';
306
+
307
+ const client = new Client({ baseURL: process.env.ACOSMI_BASE_URL! });
308
+ // 远控是高风险 scope,不在 allScopes() 内,必须显式申请
309
+ await client.login('CrabCode Remote', remoteControlScopes());
310
+
311
+ const run = await client.agentRuns.createRemoteRun({
312
+ appId: 'crabcode',
313
+ input: '重构这个函数并跑测试',
314
+ runtime: 'crabcode_remote', // 固定值
315
+ runner: 'cloud', // 'cloud' | 'desktop' | 'local_embedded'
316
+ adapter: 'remote_io', // 6 选 1,见下表
317
+ permissionPolicy: { shellAllowed: true, shellDenyList: ['rm', 'shutdown'], approvalTimeoutMs: 30_000 },
318
+ workspacePolicy: { readOnly: false, deniedPaths: ['/etc', '/root'] },
319
+ });
320
+
321
+ for await (const ev of client.agentRuns.streamRemoteControl(run.runId)) {
322
+ switch (ev.type) {
323
+ case 'text_delta': process.stdout.write(ev.text); break;
324
+ case 'permission_request': /* 渲染审批卡片,回写 permission_result */ break;
325
+ case 'settle': console.log('billed', ev.billed); break;
326
+ }
327
+ }
328
+
329
+ await client.agentRuns.cancel(run.runId); // UI 中止走服务端 cancel control frame,不是 fetch abort
330
+ ```
331
+
332
+ 要点:
333
+
334
+ - **scope 隔离**:远控用专用 `remote_control` scope(服务端展开为 `remote_control:{agent-run,session-control,permission-response}` 三子项);**绝不复用** `models:chat`/`ai`,且 `allScopes()` 不含它——桌面登录不会自动获得远控权限。用 `remoteControlScopes()` 或显式 `[...allScopes(), ScopeRemoteControl]`。
335
+ - **adapter / runner**(`AdapterKind` / `RunnerKind`,契约 §3 placement 矩阵):
336
+
337
+ | adapter | 适用 |
338
+ | --- | --- |
339
+ | `remote_io` | 单次纯会话流(CrabCode `--sdk-url` ws/wss) |
340
+ | `app_server_tcp_ws` | Desktop 已登录、本机 AppServer loopback RPC |
341
+ | `bridge_ccr` | 云端/托管 runner,session pool + heartbeat |
342
+ | `app_server_uds` / `stdio_stream_json` | 同机父子进程内嵌 |
343
+ | `tauri_managed_app_server` | Tauri native 托管 lifecycle |
344
+
345
+ - **wire 约定(契约 §12-§14,按平面分)**:远控属 **snake_case 平面**——`permissionPolicy`/`workspacePolicy` 等 SDK camelCase 入参由 SDK 翻译为 snake_case wire(`shell_allowed`/`approval_timeout_ms`/`denied_paths`…);时长一律**整数毫秒**(`approvalTimeoutMs`,禁 `time.Duration` 上 wire)。事件帧为**扁平信封**(`type`+`seq`+字段同级,snake_case),SDK 用 `parseRemoteControlEvent(raw)` 翻译为强类型 `RemoteControlEvent`。
346
+ - **11 事件 union**(`RemoteControlEvent`,契约 §4):`text_delta` / `reasoning_delta` / `tool_call` / `tool_result` / `permission_request` / `permission_result` / `usage` / `settle` / `status` / `error` / `done`。`error` **恒为非终结**(终结性错误由 `done.reason`/`done.finalStatus` 承载),`done` / `settle` 才终结流——故 `streamRemoteControl` 不接受 options、从不抛异常;用 `isTerminalRemoteEvent(ev)` 判终结。
347
+ - **辅助导出**:`parseRemoteControlEvent` / `isTerminalRemoteEvent` / `AdapterKind` / `RunnerKind` / `RemoteControlEvent` / `RemoteSessionPlacement` / `PermissionPolicy` / `WorkspacePolicy`(`src/agent-runs/remote-control.ts`)。
348
+
349
+ ## Chat Bridge(第三方聊天平台桥接,v2.1.0 · types-only 骨架,无 client 方法,Phase 7B 后端落地)
350
+
351
+ `chatbridge` 从根入口导出第三方聊天平台(飞书/企微/钉钉/Slack/Teams/Telegram/WhatsApp)接入 Acosmi 远控的**稳定类型契约**。Phase 7 仅交付类型骨架:**SDK 暂无 `client.chatBridge.*` 方法**,平台 webhook/凭证/桥接 handler 是 Phase 7B 后端工作;平台 SDK 依赖留在独立 adapter 包,不进主包。
352
+
353
+ ```ts
354
+ import {
355
+ isPlatform, isRegion, isChannelInboundEvent, asCredentialRef,
356
+ type Platform, type ChatCredentialPublic, type ChannelInboundEvent,
357
+ } from '@acosmi/sdk-ts';
358
+
359
+ isPlatform('feishu'); // → true(7 平台枚举运行时守卫)
360
+ asCredentialRef('cred_abc...'); // → branded CredentialRef(防 plaintext 误传)
361
+ ```
362
+
363
+ 边界(契约 §6 + §16):
364
+
365
+ - 平台 secret(bot token / signing key / AES key)**只入上游 credential vault**;SDK 公共面只见 `CredentialRef`(`cred_<base32>`)+ `fingerprint` + 脱敏 metadata,**永不**出现 ciphertext / plaintext(`ChatCredentialPublic` 编译期即无密文字段)。
366
+ - **wire 平面**:chatbridge 资源视图走 nexus-v4 model-direct 序列化,字段为 **camelCase**(与 remote-control 的 snake_case 平面不同,详见契约 §12)。
367
+ - 平台原始 thread / sender / workspace ID 一律 SHA256 hash 后入库(`threadHash`/`senderHash`)。
368
+
182
369
  ## 认证
183
370
 
184
371
  ### 浏览器内 / 自动 OAuth(推荐)
@@ -246,7 +433,10 @@ const client = new Client({ serverURL: process.env.ACOSMI_SERVER_URL!, store: ne
246
433
  | ------------ | ------------------------------------------------------------------------------------ |
247
434
  | **Client 构造** | `new Client(cfg)`(同步),`Client.create(cfg)`(async;预加载已有 TokenStore) |
248
435
  | **Chat** | `chat`, `chatStream`, `chatStreamWithUsage`, `chatMessages`, `chatMessagesStream`, `buildChatRequest` |
436
+ | **图片 / 视频生成**(v2.2.0+) | `generateImage`(同步), `generateVideo`(建异步任务), `pollVideoTask`(轮询);仅 `capabilities.supportsImageGeneration` / `supportsVideoGeneration` 模型可用 |
249
437
  | **Agent Runs** | `agentRuns.create`, `agentRuns.stream`, `agentRuns.run`, `agentRuns.cancel`, `agentRuns.get`, `agentRuns.listArtifacts`, `agentRuns.downloadArtifact`, `agentRuns.submitLocalToolResult`, `agentRuns.runWithLocalTools` |
438
+ | **Agent Runs — 远程控制**(v2.1) | `agentRuns.createRemoteRun`, `agentRuns.streamRemoteControl`;helper:`parseRemoteControlEvent`, `isTerminalRemoteEvent`;scope:`remoteControlScopes()` / `ScopeRemoteControl`(不进 `allScopes()`) |
439
+ | **Chat Bridge**(v2.1 · types-only) | 无 client 方法(Phase 7B 后端落地);导出类型守卫 `isPlatform`, `isRegion`, `isIntegrationStatus`, `isChannelInboundEvent`, `asCredentialRef` |
250
440
  | **Auth — 内置 Loopback OAuth** | `login`, `loginWithHandler`, `logout`, `ensureToken`, `forceRefresh`, `isAuthorized`, `getTokenSet` |
251
441
  | **Auth — 手动 OAuth 原语** | `discover`, `discoverWithProfile`, `register`, `authorize`, `exchangeCode`, `refreshToken`, `revokeToken`, `generateState` |
252
442
  | **Auth — 浏览器 Web OAuth (v1.4.0+)** | `discoverWebOAuthMetadata`, `registerWebOAuthClient`, `createWebAuthorizationRequest`, `completeWebAuthorizationRequest` |
@@ -260,7 +450,17 @@ const client = new Client({ serverURL: process.env.ACOSMI_SERVER_URL!, store: ne
260
450
  | **Notifications — WebSocket** | `connect`, `disconnect`, `isConnected` (实时推送订阅;浏览器走原生 WebSocket,Node 18-21 需自装 `ws`,Node 22+ 用原生) |
261
451
  | **Bug Report** | `submitBugReport`, `getBugReport` |
262
452
  | **Web Search** | `newWebSearchTool` (factory) |
263
- | **Compliance** | `compliance.createEvidenceAsset`, `compliance.issueTimestamp`, `compliance.waitForTimestampVerified`, `compliance.buildEvidencePackage`, `compliance.createReport`, `compliance.downloadReport`, `compliance.createSigningEnvelope`, `compliance.signEnvelope`, `compliance.getProviderRequest`, `compliance.waitForProviderRequestTerminal` |
453
+ | **Subscription**(v1.7.0+) | `listPlans`, `listUserSubscriptions` |
454
+ | **Pricing**(v1.7.0+) | `getPricingConfig`, `quoteCompliance` |
455
+ | **Products**(v1.7.0+) | `getProductBySlug`, `listProductsByFamily`, `listComplianceSkus`, `listPublicModels` |
456
+ | **Casehall — 法律案件**(v1.8.0+) | `listLawyers`, `getLawyer`, `submitCaseLead`, `listMyCaseLeads`, `getMyCases`, `bookConsultation`, `listMyConsultations`, `listMyLegalOrders`, `listLegalSKUs`, `getMyLawyerCredentialStatus`(v2.0.0+) |
457
+ | **Enterprise — 企业席位**(v1.8.1+) | `listMyEnterprises`, `getEnterprise`, `inviteMember`, `listEnterpriseMembers`, `listOrgSubscriptions`, `listSeats`, `assignSeat`, `revokeSeat`, `getOrgConsumeReport`, `getMyEnterpriseKycStatus`(v2.0.0+) |
458
+ | **Finance — 财务**(v1.9.0+) | `listMyInvoices`, `requestInvoice`, `listMyRefunds`, `requestRefund`, `listMyCorporateTransfers`, `initiateCorporateTransfer`, `uploadCorporateTransferProof` |
459
+ | **Compliance — 证据 / 章戳 / 公开验真** | `compliance.createEvidenceAsset`, `compliance.getEvidenceAsset`, `compliance.verifyEvidencePublic`(匿名公开验真,v1.3.2+), `compliance.issueTimestamp`, `compliance.issueTimestampForAsset`, `compliance.getTimestamp`, `compliance.verifyTimestamp`, `compliance.waitForTimestampVerified`, `compliance.buildEvidencePackage` |
460
+ | **Compliance — 报告** | `compliance.createReport`(写,带 `Idempotency-Key`), `compliance.getReport`, `compliance.publishReport`(step-up + 写), `compliance.downloadReport` |
461
+ | **Compliance — 签署 envelope** | `compliance.createSigningEnvelope`(写), `compliance.getSigningEnvelope`, `compliance.signEnvelope`(step-up + gate + 写), `compliance.createH5SigningUrl`(step-up + gate + 写), `compliance.syncSigningEnvelopeStatus`(写) |
462
+ | **Compliance — 用印审批** | `compliance.submitSealApproval`(写), `compliance.approveSealApproval`(step-up + 写), `compliance.rejectSealApproval`(写), `compliance.cancelSealApproval`(写), `compliance.listPendingSealApprovals`, `compliance.getSealApproval` |
463
+ | **Compliance — Provider Request** | `compliance.getProviderRequest`, `compliance.waitForProviderRequestTerminal`, `compliance.classifyError` |
264
464
  | **Compliance — 分页列表** | `compliance.listEvidenceAssets`, `compliance.listTimestamps`, `compliance.listEvidencePackages`, `compliance.listReports`, `compliance.listSigningEnvelopes`, `compliance.listSealApprovals`, `compliance.listSealUses`(均返回 `PageResult<T>`) |
265
465
  | **Compliance — 能力与操作投影** | `compliance.getCapabilities`, `compliance.getFeatureGate`, `compliance.listOperations`, `compliance.getOperation` |
266
466
  | **Compliance — TSA 只读视图** | `compliance.listTsaProviders`, `compliance.getTsaStats` |
@@ -537,68 +737,103 @@ PII / 合同原文 / storage bucket+key / subject snapshot / provider raw / TSA
537
737
 
538
738
  ### 完整 API 列表
539
739
 
740
+ 标注约定:
741
+ - `// 写` — POST / PUT / DELETE 写操作,**必传 `Idempotency-Key`**(即第二参数 `options?: ComplianceWriteOptions` 的 `idempotencyKey` 字段);写操作不自动 retry,401 不 refresh + replay
742
+ - `// step-up` — 需 OAuth token 升级等级;失败抛 `BusinessError` 含 code `1031000013`,调用方按 `classifyComplianceError` 分支引导用户重新 introspection
743
+ - `// gate` — 受 capability gate 控制,未闭合时 fail-closed;先用 `getCapabilities` / `getFeatureGate` 探测
744
+ - `// 分页` — 走 `GET .../page` 返回 `PageResult<T>`(`{ total, list }`)
745
+ - 无标注 — GET 读路径,单次 401 refresh 重试
746
+
747
+ #### 证据资产(evidence)
748
+
540
749
  ```ts
541
- client.compliance.createEvidenceAsset(req, options?)
750
+ client.compliance.createEvidenceAsset(req, options?) // 写
542
751
  client.compliance.getEvidenceAsset(id, signal?)
543
- client.compliance.verifyEvidencePublic(req, signal?)
544
- client.compliance.listEvidenceAssets(req?, signal?) // 分页 → PageResult
545
- client.compliance.listEvidencePackages(req?, signal?) // 分页 → PageResult
752
+ client.compliance.verifyEvidencePublic(req, signal?) // 匿名公开验真(未 login 不抛 not-authorized)
753
+ client.compliance.listEvidenceAssets(req?, signal?) // 分页
754
+ client.compliance.listEvidencePackages(req?, signal?) // 分页
755
+ client.compliance.buildEvidencePackage(assetId, timestampTokenId?, options?) // 写
756
+ ```
546
757
 
547
- client.compliance.issueTimestamp(req, options?)
548
- client.compliance.issueTimestampForAsset(assetId, options?)
758
+ #### 时间章(timestamp)
759
+
760
+ ```ts
761
+ client.compliance.issueTimestamp(req, options?) // 写
762
+ client.compliance.issueTimestampForAsset(assetId, options?) // 写
549
763
  client.compliance.getTimestamp(id, signal?)
550
- client.compliance.verifyTimestamp(req, options?)
764
+ client.compliance.verifyTimestamp(req, options?) // 写(远端 verify 落审计)
551
765
  client.compliance.waitForTimestampVerified(id, opts?)
552
- client.compliance.listTimestamps(req?, signal?) // 分页 → PageResult
766
+ client.compliance.listTimestamps(req?, signal?) // 分页
767
+ client.compliance.listTsaProviders(signal?) // TSA provider 只读列表
768
+ client.compliance.getTsaStats(signal?) // 时间章统计只读视图
769
+ ```
553
770
 
554
- client.compliance.buildEvidencePackage(assetId, timestampTokenId?, options?)
771
+ #### 出证报告(report)
555
772
 
556
- client.compliance.createReport(req, options?) // 需 compliance:reports:write
773
+ ```ts
774
+ client.compliance.createReport(req, options?) // 写,需 compliance:reports:write
557
775
  client.compliance.getReport(id, signal?)
558
- client.compliance.publishReport(id, options?) // step-up
559
- client.compliance.downloadReport(id, signal?) // 离线复核 hash 视图
560
- client.compliance.listReports(req?, signal?) // 分页 → PageResult
776
+ client.compliance.publishReport(id, options?) // 写 + step-up
777
+ client.compliance.downloadReport(id, signal?) // 离线复核 hash 视图
778
+ client.compliance.listReports(req?, signal?) // 分页
779
+ ```
780
+
781
+ #### 签署 envelope
561
782
 
562
- client.compliance.createSigningEnvelope(req, options?)
783
+ ```ts
784
+ client.compliance.createSigningEnvelope(req, options?) // 写
563
785
  client.compliance.getSigningEnvelope(envelopeId, signal?)
564
- client.compliance.signEnvelope(envelopeId, req, options?) // step-up + gate
565
- client.compliance.createH5SigningUrl(envelopeId, req, options?) // step-up + gate
566
- client.compliance.syncSigningEnvelopeStatus(envelopeId, options?)
567
- client.compliance.listSigningEnvelopes(req?, signal?) // 分页 → PageResult
568
- client.compliance.listEnvelopeContracts(envelopeId, signal?) // 合同列表(数组)
569
- client.compliance.listEnvelopeProviderRequests(envelopeId, signal?) // provider 请求列表(数组)
570
- client.compliance.voidEnvelope(envelopeId, req, options?) // 作废 envelope(写)
571
-
572
- client.compliance.submitSealApproval(req, options?)
573
- client.compliance.approveSealApproval(id, query, options?) // step-up
574
- client.compliance.rejectSealApproval(id, query, options?)
575
- client.compliance.cancelSealApproval(id, query, options?)
786
+ client.compliance.signEnvelope(envelopeId, req, options?) // 写 + step-up + gate
787
+ client.compliance.createH5SigningUrl(envelopeId, req, options?) // 写 + step-up + gate
788
+ client.compliance.syncSigningEnvelopeStatus(envelopeId, options?) // 写
789
+ client.compliance.listSigningEnvelopes(req?, signal?) // 分页
790
+ client.compliance.listEnvelopeContracts(envelopeId, signal?) // 合同列表(数组,非 PageResult)
791
+ client.compliance.listEnvelopeProviderRequests(envelopeId, signal?) // provider 请求列表(数组,非 PageResult)
792
+ client.compliance.voidEnvelope(envelopeId, req, options?) //
793
+ ```
794
+
795
+ #### 用印审批(seal approval / seal use)
796
+
797
+ ```ts
798
+ client.compliance.submitSealApproval(req, options?) // 写
799
+ client.compliance.approveSealApproval(id, query, options?) // 写 + step-up
800
+ client.compliance.rejectSealApproval(id, query, options?) // 写
801
+ client.compliance.cancelSealApproval(id, query, options?) // 写
576
802
  client.compliance.listPendingSealApprovals(signal?)
577
803
  client.compliance.getSealApproval(id, signal?)
578
- client.compliance.listSealApprovals(req?, signal?) // 分页 → PageResult
579
- client.compliance.listSealUses(req?, signal?) // 用印执行分页 → PageResult
804
+ client.compliance.listSealApprovals(req?, signal?) // 分页
805
+ client.compliance.listSealUses(req?, signal?) // 分页(用印执行)
806
+ ```
807
+
808
+ #### Provider request 状态轮询
580
809
 
810
+ ```ts
581
811
  client.compliance.getProviderRequest(id, signal?)
582
812
  client.compliance.waitForProviderRequestTerminal(id, opts?)
813
+ ```
583
814
 
584
- client.compliance.getCapabilities(signal?) // 能力闸门列表
585
- client.compliance.getFeatureGate(action, signal?) // 单动作能力(便捷,一次网络请求)
586
- client.compliance.listOperations(req?, signal?) // 操作投影分页 → PageResult
587
- client.compliance.getOperation(id, signal?) // 操作投影详情
588
- client.compliance.classifyError(err) // BusinessError → ComplianceErrorInfo | null(同顶层 classifyComplianceError,便于在 catch 块上链式调用)
815
+ #### 能力闸门 / 操作投影
589
816
 
590
- client.compliance.listTsaProviders(signal?) // TSA provider 只读列表
591
- client.compliance.getTsaStats(signal?) // 时间章统计只读视图
817
+ ```ts
818
+ client.compliance.getCapabilities(signal?) // 能力闸门列表(拿不到必须 fail-closed)
819
+ client.compliance.getFeatureGate(action, signal?) // 单动作能力(便捷,一次网络请求)
820
+ client.compliance.listOperations(req?, signal?) // 分页(操作投影)
821
+ client.compliance.getOperation(id, signal?)
822
+ client.compliance.classifyError(err) // BusinessError → ComplianceErrorInfo | null(同顶层 classifyComplianceError,便于 catch 块链式调用)
823
+ ```
592
824
 
593
- client.compliance.createContractTemplate(req, options?) // 创建合同模板(DRAFT
594
- client.compliance.updateContractTemplate(id, req, options?) // 更新模板(仅 DRAFT)
595
- client.compliance.deleteContractTemplate(id, options?) // 删除模板(仅 DRAFT)
596
- client.compliance.getContractTemplate(id, signal?) // 模板详情
597
- client.compliance.listContractTemplates(req?, signal?) // 模板分页 → PageResult
598
- client.compliance.uploadContractTemplatePdf(id, req, options?) // 上传 PDF(base64
599
- client.compliance.publishContractTemplate(id, options?) // DRAFT → PUBLISHED
600
- client.compliance.archiveContractTemplate(id, options?) // PUBLISHED → ARCHIVED
601
- client.compliance.listContractTemplateVersions(id, signal?) // 版本快照列表(数组)
825
+ #### 合同模板(contract template,v1.5.0 S5
826
+
827
+ ```ts
828
+ client.compliance.createContractTemplate(req, options?) // 写,DRAFT
829
+ client.compliance.updateContractTemplate(id, req, options?) // 写(仅 DRAFT)
830
+ client.compliance.deleteContractTemplate(id, options?) // 写(仅 DRAFT
831
+ client.compliance.getContractTemplate(id, signal?) // 模板详情
832
+ client.compliance.listContractTemplates(req?, signal?) // 分页
833
+ client.compliance.uploadContractTemplatePdf(id, req, options?) // 写(上传 PDF base64)
834
+ client.compliance.publishContractTemplate(id, options?) // 写,DRAFT → PUBLISHED
835
+ client.compliance.archiveContractTemplate(id, options?) // 写,PUBLISHED → ARCHIVED
836
+ client.compliance.listContractTemplateVersions(id, signal?) // 版本快照列表(数组)
602
837
  ```
603
838
 
604
839
  > 6 个 `list*` 分页方法(compliance gateway S1)均走 `GET .../page`,返回
@@ -683,7 +918,16 @@ npm run docs # 经 TypeDoc 生成 API 参考到 docs/api/
683
918
 
684
919
  | 版本 | 状态 | 概要 |
685
920
  | --- | --- | --- |
686
- | 1.5.1 | 当前稳定版 | **Docs / examples / 源码注释全量复核与修订 — 无 API 变化**。修补 8 项漂移与遗漏:README API 总览补 25+ 漏列方法(Chat 内部方法、Auth 浏览器 Web OAuth 4 原语、Skills/Notifications/Entitlements/Packages 全量、WS `connect/disconnect/isConnected`);重写 §"手动 OAuth" 段对齐 `auth.ts` 真实签名;§"双格式红线" + 三个 chat 示例 `maxTokens` snake_case `max_tokens`;错误表补 `ModelNotFoundError`;§Agent Runs 13 类 stream event 完整表;新增 §`sanitize` 命名空间小节;`docs/compliance.md` 6 `Since v1.6/.../1.10` 统一为 `v1.5.0 (originally planned as ...)`;手册 §7 scope 数 12 → 15 + 新增 S1-S6 rollup 段;`examples/compliance-evidence-timestamp.ts` `ScopeComplianceReportsWrite`(v1.3.2 漂移生产 401 隐患);`examples/auth-oauth-flow.ts` + `examples/core-chat.ts` 注释对齐当前契约;`src/index.ts` + `src/browser.ts` + `src/auth/auth.ts` 注释从 Go-port 语义改为"TS 主实现 + Web OAuth 替代品"。`typecheck` / `lint` / `vitest`(214) / `build` / `test:pack` 全绿。 |
921
+ | 2.2.0 | **当前稳定版(npm latest)** | **托管模型图片/视频生成(2026-05-29)**。图片/视频生成与文本模型同属托管模型网关(同 `Client`、同 `models:chat` 鉴权面),仅 `capabilities.supports_image_generation` / `supports_video_generation` 的模型可用;计费结算在营销系统,SDK / 网关只负责调用与用量上报。新增 `client.generateImage(modelID, req, signal?)`(同步,`POST /managed-models/:id/images/generations`)/ `client.generateVideo(modelID, req, signal?)`(建异步任务,返回 `taskId`)/ `client.pollVideoTask(modelID, taskID, durationSeconds?, signal?)`(轮询,`durationSeconds` 透传给网关在 `completed` 时上报视频秒数);新增 `ImageGenerationRequest`/`ImageGenerationResponse`/`VideoGenerationRequest`/`VideoTaskResponse` 类型 + `ModelCapabilities.supportsImageGeneration`/`supportsVideoGeneration` 标志。网关适配 OpenAI 兼容图片 + 火山引擎(即梦/豆包)视频 + DashScope 通义万相(wanx)原生异步任务(图片+视频)。公开类型 / 方法签名零移除、零改名(additive minor)。 |
922
+ | 2.1.0 | 稳定版 | **远程控制 CrabCode 多接入面(2026-05-28)**。`serverURL`/`baseURL`/`baseUrl` Gateway URL 公共契约 + `normalizeGatewayBaseURL`(仅 http/https,拒 ws/wss);`agentRuns.createRemoteRun` / `streamRemoteControl` + 11 事件 `RemoteControlEvent` union + `parseRemoteControlEvent` / `isTerminalRemoteEvent`;`AdapterKind`(6) / `RunnerKind`(3) / `PermissionPolicy` / `WorkspacePolicy`;专用 `remote_control` scope(不进 `allScopes()`,`remoteControlScopes()`);`chatbridge` 第三方聊天平台类型骨架(types-only,无 client 方法,Phase 7B 后端落地);`subscription.getPlanByCode`。wire 约定按平面分(远控 snake_case + 毫秒整数 / chatbridge camelCase,契约 §12-§14)。公开类型 / 方法签名零移除、零改名(additive minor)。 |
923
+ | 2.0.1 | 稳定版 | **Packaging fix — 纯发布元数据,无源码改动**。`package.json.files` 数组补 `docs/pii-role-matrix.md` + `docs/开发与发布手册.md` 两项,让 v2.0.0 引入的 PII 角色矩阵与开发手册随 npm tarball 一并下发。从 v2.0.0 升级到 v2.0.1 无需任何 review。 |
924
+ | 2.0.0 | **BREAKING** | **Phase 3 复核 + 全量根治(2026-05-25)**。主仓 9 commit 闭环 20 P0(RBAC 表达式统一 / PII 真落盘加密链 / K7 视频 webhook 幂等 / K8 OCR SSRF / K9 KYC main flow / admin 写端点错误码契约)。**SDK 同步**:新增 `casehall.getMyLawyerCredentialStatus()` + `enterprise.getMyEnterpriseKycStatus()` 律师/企业 OWNER 自查端点;`finance/types.ts` P2-016 PII Javadoc 升级(含 `keyVersion` v1/v2 payload 协议);新建 `docs/pii-role-matrix.md`(4 角色 × 3 PII 级矩阵);admin 写端点错误码改 HTTP 状态码语义(`200+{ok:false}` → `403/404/501`)。**升级指引详见 §"v2.0.0 升级指引"**。SDK 公开类型 / 方法签名零移除、零改名;BREAKING 范围在网关后端契约。 |
925
+ | 1.9.0 | 稳定版 | **finance 域落地(商品化总规划 P7)**。新增 `client.finance.*`:`listMyInvoices` / `requestInvoice` / `listMyRefunds` / `requestRefund` / `listMyCorporateTransfers` / `initiateCorporateTransfer` / `uploadCorporateTransferProof`(决策 14/15 + R12)。发票 / 退款 / 对公转账三条业务线全量接入;金额一律用 string(json.Number 端口,避免 JS 浮点损失)。 |
926
+ | 1.8.1 | 稳定版 | **enterprise 企业席位域落地(商品化总规划 P6a)**。新增 `client.enterprise.*`:`listMyEnterprises` / `getEnterprise` / `inviteMember` / `listEnterpriseMembers` / `listOrgSubscriptions` / `listSeats` / `assignSeat` / `revokeSeat` / `getOrgConsumeReport`。OWNER/ADMIN 权限下席位月度变更 ≤ 3 次(超出返 41xxx 业务码);订阅 + 席位 + 用量报表三视图齐备。 |
927
+ | 1.8.0 | 稳定版 | **casehall 法律案件咨询域落地(商品化总规划 P5 方案 B)**。新增 `client.casehall.*`:`listLawyers` / `getLawyer` / `submitCaseLead` / `listMyCaseLeads` / `getMyCases` / `bookConsultation` / `listMyConsultations` / `listMyLegalOrders` / `listLegalSKUs`。律师库公开端点(VERIFIED + ACTIVE,PII L3 已脱敏)+ 案件线索 + 咨询 + 5 LEGAL_SERVICE SKU;admin 板块 9 模块不在 SDK 边界。 |
928
+ | 1.7.0 | 稳定版 | **subscription + pricing + products 三域落地(商品化总规划 P1-P4)**。`subscription`:`listPlans` / `listUserSubscriptions`(订阅档位 + 用户订阅)。`pricing`:`getPricingConfig` / `quoteCompliance`(公开业务参数 + csign 合规 SKU 报价)。`products`:`getProductBySlug` / `listProductsByFamily` / `listComplianceSkus` / `listPublicModels`(商品中心 productFamily / audience / billingMode 索引)。 |
929
+ | 1.6.0 | 稳定版 | `ChatRequest.endUserId` 业务侧终端用户稳定标识,跨 provider 通用语义;SDK 自动按 wire-format 注入(OpenAI 顶层 `user_id` / Anthropic `metadata.user_id`);不传时网关从认证身份 HMAC-SHA256 自动派生 32 字符 id。`validateEndUserId(s)` helper 校验 PII / 长度 / 字符集。SSE keep-alive + 11 分钟超时调优;网关侧命中三项隔离能力(内容安全 / KV-cache / 调度)。 |
930
+ | 1.5.1 | 历史稳定版 | **Docs / examples / 源码注释全量复核与修订 — 无 API 变化**。修补 8 项漂移与遗漏:README API 总览补 25+ 漏列方法(Chat 内部方法、Auth 浏览器 Web OAuth 4 原语、Skills/Notifications/Entitlements/Packages 全量、WS `connect/disconnect/isConnected`);重写 §"手动 OAuth" 段对齐 `auth.ts` 真实签名;§"双格式红线" + 三个 chat 示例 `maxTokens` → snake_case `max_tokens`;错误表补 `ModelNotFoundError`;§Agent Runs 补 13 类 stream event 完整表;新增 §`sanitize` 命名空间小节;`docs/compliance.md` 6 处 `Since v1.6/.../1.10` 统一为 `v1.5.0 (originally planned as ...)`;手册 §7 scope 数 12 → 15 + 新增 S1-S6 rollup 段;`examples/compliance-evidence-timestamp.ts` 补 `ScopeComplianceReportsWrite`(v1.3.2 漂移生产 401 隐患);`examples/auth-oauth-flow.ts` + `examples/core-chat.ts` 注释对齐当前契约;`src/index.ts` + `src/browser.ts` + `src/auth/auth.ts` 注释从 Go-port 语义改为"TS 主实现 + Web OAuth 替代品"。`typecheck` / `lint` / `vitest`(214) / `build` / `test:pack` 全绿。 |
687
931
  | 1.5.0 | 稳定版 | 沉淀 `src/shared/` 跨域共享 DTO(`PageRequest`/`PageResult` 别名、`OperationId`/`OperationStatus`/`IdempotencyKeyHeader`、`RetryAdvice` 叠加层、`PrincipalRef`/`TenantRef`、`FeatureGateStatus`/`StepUpStatus`/`BillingPreflightResult`)。**同时全量 rollup compliance gateway S1-S6** 能力(原 1.6.0-1.11.0 roadmap,见 [CHANGELOG.md](./CHANGELOG.md)):S1 6 个分页列表、S2 capabilities + operations 投影、S3 TSA 只读视图、S4 envelope 收尾 + void、S5 合同模板全生命周期 + 2 新 scope(`compliance:contract_template:{read,write}`)、S6 用印执行分页(`listSealUses`)。当前 compliance scope 总数 **15** 个(`complianceScopes()` 返回)。纯增量;8 个平台控制面占位命名空间仍待后端契约就绪后落地。 |
688
932
  | 1.4.2 | 稳定版 | `src/` 从扁平 36 文件按业务域重组为 per-domain 目录;公共导出符号集合、`exports`、`dist/` 路径一字未变(纯内部重组)。新增 TypeDoc API 文档。 |
689
933
  | 1.4.1 | 稳定版 | 新增 `Config.browserRefreshMode` / `refreshProxyURL`——浏览器 Web OAuth token 刷新策略(规避 issuer CORS 403)。 |