@acosmi/sdk-ts 1.5.0 → 1.6.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 +73 -1
- package/README.md +130 -25
- package/dist/browser/index.mjs +46 -6
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +46 -6
- package/dist/index.mjs.map +1 -1
- package/dist/node/adapters/anthropic.cjs +11 -2
- package/dist/node/adapters/anthropic.cjs.map +1 -1
- package/dist/node/adapters/anthropic.d.cts +1 -1
- package/dist/node/adapters/anthropic.d.ts +1 -1
- package/dist/node/adapters/anthropic.mjs +11 -2
- package/dist/node/adapters/anthropic.mjs.map +1 -1
- package/dist/node/adapters/openai.cjs +3 -0
- package/dist/node/adapters/openai.cjs.map +1 -1
- package/dist/node/adapters/openai.d.cts +2 -2
- package/dist/node/adapters/openai.d.ts +2 -2
- package/dist/node/adapters/openai.mjs +3 -0
- package/dist/node/adapters/openai.mjs.map +1 -1
- package/dist/node/{index-nvLKgCm9.d.cts → index-Bah9A83R.d.cts} +1 -1
- package/dist/node/{index-nvLKgCm9.d.ts → index-Bah9A83R.d.ts} +1 -1
- package/dist/node/{index-DEA6LXw6.d.cts → index-C9X5Yuyk.d.cts} +10 -1
- package/dist/node/{index-DEA6LXw6.d.ts → index-C9X5Yuyk.d.ts} +10 -1
- package/dist/node/index.cjs +48 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +34 -8
- package/dist/node/index.d.ts +34 -8
- package/dist/node/index.mjs +46 -6
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{openai-vfUUgdvL.d.ts → openai-BqKAhbSc.d.ts} +2 -2
- package/dist/node/{openai-BDodfhsG.d.cts → openai-C_UKadSX.d.cts} +2 -2
- package/dist/node/sanitize/index.d.cts +1 -1
- package/dist/node/sanitize/index.d.ts +1 -1
- package/docs/compliance.md +13 -8
- package/examples/auth-oauth-flow.ts +6 -2
- package/examples/compliance-evidence-timestamp.ts +3 -1
- package/examples/core-chat.ts +5 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,79 @@ 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
|
-
## [
|
|
8
|
+
## [1.6.0] - 2026-05-24
|
|
9
|
+
|
|
10
|
+
### Added — 业务侧终端用户 id (endUserId) + 请求保活
|
|
11
|
+
|
|
12
|
+
- `ChatRequest.endUserId?: string` — 业务侧终端用户 id, 跨 provider 通用语义。
|
|
13
|
+
序列化规则:
|
|
14
|
+
- OpenAI wire: 顶层 `body["user_id"]`
|
|
15
|
+
- Anthropic wire: 合并到 `body["metadata"]["user_id"]`; caller `metadata` 显式键优先
|
|
16
|
+
- 约束: 长度 ≤ 512, 字符集 `[a-zA-Z0-9_-]+`, **禁止包含用户隐私信息** (邮箱/手机/真名等).
|
|
17
|
+
- 公开 helper `validateEndUserId(s)`, `isSSECommentLine(line)`, 常量 `maxEndUserIdLength`.
|
|
18
|
+
- Chat / ChatMessages / ChatStream / ChatMessagesStream 的 per-request timeout 5min → **11min**,
|
|
19
|
+
覆盖 DeepSeek 上游 "开始推理前最大 10min 保活" 窗口。
|
|
20
|
+
- SSE 外层循环显式跳过 `: comment` 注释行 (": keep-alive"), 防止未来添加 else-branch 误抛 JSON parse error。
|
|
21
|
+
- 网关 sanitizer step 4.4 做最终校验 + 派生 + 注入; caller 显式覆盖需 `scope=endusr.set`,
|
|
22
|
+
无授权时 endUserId 被丢弃, 上游收到的是网关 HMAC 派生值 (32 字符稳定 id)。
|
|
23
|
+
|
|
24
|
+
### Security — devDep upgrade(消除 4 项 moderate Dependabot alerts)
|
|
25
|
+
|
|
26
|
+
- `vitest` `^1.0.0` → `^4.1.7`(跨 3 major),传递性把 `vite` `5.4.21` → `8.0.14`
|
|
27
|
+
/ `esbuild` 路径升到 fixed 区间,消除:
|
|
28
|
+
- **GHSA-67mh-4wv8-2f99** — esbuild dev server CORS bypass(fix: 0.25.0)
|
|
29
|
+
- **GHSA-4w7w-66w2-5vf9** — vite path traversal in optimized deps `.map` handling(fix: 6.4.2)
|
|
30
|
+
- **Consumer 零影响**:vitest/vite/esbuild 全在 devDependencies,dist tarball 与
|
|
31
|
+
package.json `engines.node >=18` 不变;不需要打 tag / 发新版。
|
|
32
|
+
- 验证:`npm audit` 0 vulnerabilities / `vitest 4.1.7` 17 文件 214 case
|
|
33
|
+
全绿 / typecheck / lint / build / test:pack consumer 视角 PASS / docs 重生
|
|
34
|
+
无新增 errors。
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## [1.5.1] — 2026-05-23
|
|
39
|
+
|
|
40
|
+
> **Docs / examples patch — 无 API 变化**。对 README、`docs/compliance.md`、`docs/开发与发布手册.md`、`examples/`、源码注释做全量复核与修订,消除发现的 8 项漂移与遗漏。无 runtime 行为变更、无新增/移除导出符号、无 wire-format 变化;`typecheck` / `lint` / `vitest`(214) / `build` / `test:pack` 全绿。
|
|
41
|
+
|
|
42
|
+
### Changed — README.md
|
|
43
|
+
|
|
44
|
+
- 补全 API 总览表 25+ 漏列方法:`chatMessages` / `chatMessagesStream` / `buildChatRequest` / `loginWithHandler` / `isAuthorized` / `getTokenSet` / 浏览器 Web OAuth 4 原语 / `discoverWithProfile` / `register` / `revokeToken` / `generateState` / `ensureModelCached` / `browseSkillStore` / `getSkillSummary` / `certifySkill` / `getCertificationStatus` / `markAllNotificationsRead` / `deleteNotification` / `unregisterDevice` / `updateNotificationPreference` / WS `connect`/`disconnect`/`isConnected` / `listConsumeRecords` / `invalidateCoefficientCache` / `getTokenPackageDetail` / `listMyOrders` / `Client.create`。
|
|
45
|
+
- 修复 §"双格式红线" 把 `preferredFormat` / `supportedFormats` 错写为 camelCase 的描述——`ManagedModel` 上这两个字段是 snake_case wire 字段;同步说明 `modelId` / `isEnabled` / `inputModalities` 等顶层走 camelCase。
|
|
46
|
+
- 修复 Quick Start / 流式 / Web Search 三个示例的 `ChatRequest` 字段:`maxTokens` → `max_tokens`(与 `src/models/types.ts:ChatRequest.max_tokens` 对齐)。
|
|
47
|
+
- 重写 §"手动 OAuth" 段:`register/authorize/exchangeCode` 全部按 `src/auth/auth.ts` 真实签名重写——`register` 不接 scopes / `authorize` 需 `reg.client_id`+`handler:` 而非 `onEvent:`、返回 `{ result, verifier }` / `exchangeCode` 需 5 个位置参数含 `result.redirectURI` + `verifier`;指向 `examples/auth-oauth-flow.ts` 完整示例;加浏览器 Web OAuth 替代品指引。
|
|
48
|
+
- §错误处理表补 `ModelNotFoundError`(`chat` / `ensureModelCached` listModels 自动刷新后仍未命中);为既有 `NetworkError` / `StreamError` / `CompliancePollError` 补字段细节。
|
|
49
|
+
- §Agent Runs 段补 `AgentRunStreamEvent` 完整 13 类事件表(`run_started` / `status` / `text_delta` / `reasoning_delta` / `tool_call` / `tool_result` / `local_tool_request` / `artifact` / `sources` / `usage` / `settle` / `error` / `done`)。
|
|
50
|
+
- 新增 §`sanitize` 命名空间小节:列 `client.setDefensiveSanitize` / `setAutoStripEphemeralHistory` / `applyRequestSanitizers` 三个 mixin 方法 + `sanitize.sanitize` / `dropBlocks` / `stripEphemeral` + 17 个 `Block*` 常量 + `MinimalSanitizeConfig` 字段(`maxMessagesTurns` / `permanentDenyBlocks` / `maxImageBytes` / `maxVideoBytes` / `maxPDFBytes`)+ thinking 块硬豁免红线。
|
|
51
|
+
- §历史表 1.5.0 行补"compliance gateway S1-S6 全量 rollup + scope 总数 15"说明。
|
|
52
|
+
|
|
53
|
+
### Changed — docs/compliance.md
|
|
54
|
+
|
|
55
|
+
- 6 处版本号漂移修订:`Since v1.6.0 / 1.7.0 / 1.8.0 / 1.9.0 / 1.10.0` + `Contract-template scopes (added in v1.10.0)` → 统一为 `v1.5.0 (originally planned as v1.X.0 — see CHANGELOG §"SN:..."`,避免消费者误以为这些方法在未来版本才有。
|
|
56
|
+
|
|
57
|
+
### Changed — docs/开发与发布手册.md
|
|
58
|
+
|
|
59
|
+
- §7 必测清单:`test/compliance-scopes.test.ts — 12 个` → `15 个`,附 12 → 13(v1.3.2)→ 15(v1.5.0 S5)演进注解。
|
|
60
|
+
- §7 新增"Compliance gateway S1-S6 rollup(v1.5.0)"小节,逐 S 列出新增 25+ SDK 方法、对应后端 G1-G6、新增 scope 与 fail-closed 红线。
|
|
61
|
+
|
|
62
|
+
### Changed — examples/
|
|
63
|
+
|
|
64
|
+
- `examples/compliance-evidence-timestamp.ts` 补 `ScopeComplianceReportsWrite`(`createReport` 自 v1.3.2 起改用独立 write scope;过去用 `ScopeComplianceReportsRead` 在生产会 401)。
|
|
65
|
+
- `examples/auth-oauth-flow.ts` 顶部注释指向 v1.4.0+ Web OAuth 原语(`discoverWebOAuthMetadata` / `registerWebOAuthClient` / `createWebAuthorizationRequest` / `completeWebAuthorizationRequest`)+ `Config.browserRefreshMode` / `refreshProxyURL` (v1.4.1+) CORS 规避方案。
|
|
66
|
+
- `examples/core-chat.ts` 顶部注释把 `preferredFormat` / `supportedFormats` 改回 snake_case;补 `ChatRequest` snake_case wire / `ManagedModel` 顶层 camelCase 字段命名说明。
|
|
67
|
+
|
|
68
|
+
### Changed — 源码注释(无 runtime 影响)
|
|
69
|
+
|
|
70
|
+
- `src/index.ts` 顶部注释从"端口源 acosmi-sdk-go v0.19.0 (一字不差对齐)"改为"自 2026-05-22 起 TS 是主实现 / 事实标准",与 README §状态 + 手册 §1 / §10 一致。
|
|
71
|
+
- `src/browser.ts` 顶部注释加 v1.4.0+ Web OAuth 替代品 + v1.4.1+ `browserRefreshMode` 指引。
|
|
72
|
+
- `src/auth/auth.ts` 顶部 + `authorize()` doc:从"浏览器侧应自行实现 popup window"改为指向同文件内 Web OAuth 原语。
|
|
73
|
+
- `docs/api/`(TypeDoc 生成)已同步重生成。
|
|
74
|
+
|
|
75
|
+
### Verified
|
|
76
|
+
|
|
77
|
+
- `typecheck`:0 errors
|
|
78
|
+
- `vitest`:17 files / **214 tests passed**
|
|
79
|
+
- `npm pack --dry-run`:tarball 内容无变化
|
|
80
|
+
- 跨语言契约印记(snake_case wire / 双 adapter 等地位 / bug-for-bug 行为)零回归
|
|
9
81
|
|
|
10
82
|
---
|
|
11
83
|
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
## 状态
|
|
8
8
|
|
|
9
9
|
- 主实现 / 事实标准:本 TS SDK 现为 Acosmi SDK 的主力实现。Go SDK [acosmi-sdk-go](https://github.com/acosmi/acosmi-sdk-go) 已暂停维护,待 TS 稳定后再从 TS 反向翻译补齐
|
|
10
|
-
- 当前版本:**1.
|
|
10
|
+
- 当前版本:**1.6.0**(v1.6.0 新增 `ChatRequest.endUserId` 业务侧终端用户 id + SSE keep-alive 注释行自动跳过 + per-request 超时 5min→11min 覆盖上游"开始推理前最长 10min 保活"窗口;详见下方"用户隔离 (v1.6.0+)"+ [CHANGELOG](./CHANGELOG.md))。`1.5.x` 文档复核 + `src/shared/` 跨域 DTO + compliance gateway S1-S6 rollup;`1.4.x` `src/` 按业务域重组 + 浏览器 Web OAuth;`1.3.x` `client.compliance` 合规域客户端
|
|
11
11
|
- 测试:发布前需通过 typecheck/lint/vitest/build/packed-tarball smoke (`npm run test:pack`)
|
|
12
12
|
- API 参考文档:`npm run docs` 经 TypeDoc 生成到 `docs/api/`
|
|
13
13
|
- 包链接:[npm](https://www.npmjs.com/package/@acosmi/sdk-ts) · [GitHub Releases](https://github.com/acosmi/sdk-ts/releases)
|
|
@@ -28,11 +28,30 @@ await client.login('My App', allScopes());
|
|
|
28
28
|
|
|
29
29
|
const resp = await client.chat('claude-opus-4-7', {
|
|
30
30
|
messages: [{ role: 'user', content: 'Hello' }],
|
|
31
|
-
|
|
31
|
+
max_tokens: 1024, // ChatRequest 走 snake_case wire 字段(与上游 Go json tag 对齐)
|
|
32
|
+
endUserId: 'user-abc-123', // v1.6.0+ 业务侧稳定 id, 启用上游隔离 / KV-cache / 调度策略
|
|
32
33
|
});
|
|
33
34
|
console.log(resp.content);
|
|
34
35
|
```
|
|
35
36
|
|
|
37
|
+
### 用户隔离 (v1.6.0+)
|
|
38
|
+
|
|
39
|
+
`ChatRequest.endUserId` — 业务侧终端用户的稳定标识, **跨 provider 通用语义**, 不绑死 DeepSeek。SDK 自动按 wire-format 注入: OpenAI 顶层 `user_id` / Anthropic `metadata.user_id`; 网关侧校验并派生后送达上游, 命中三项隔离能力 (内容安全 / KV-cache / 调度)。
|
|
40
|
+
|
|
41
|
+
**约束**: 字符集 `[a-zA-Z0-9_-]+`, 长度 ≤ 512, **禁止包含 PII** (邮箱 / 手机 / 真名等)。可用 `validateEndUserId(s)` helper 自校验。
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { validateEndUserId } from '@acosmi/sdk-ts';
|
|
45
|
+
|
|
46
|
+
const err = validateEndUserId(uid);
|
|
47
|
+
if (err) {
|
|
48
|
+
// 处理: PII / 长度 / 字符集不合规
|
|
49
|
+
throw new Error(err);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
不传 `endUserId` 时网关从认证身份 HMAC-SHA256 自动派生 32 字符稳定 id, 业务无感知。流式 + 同步 + Anthropic + OpenAI 四条路径均支持。
|
|
54
|
+
|
|
36
55
|
## 双格式红线(设计核心)
|
|
37
56
|
|
|
38
57
|
SDK 同时提供 **Anthropic + OpenAI 两条 endpoint**,**等地位**,对应两个不同下游产品。
|
|
@@ -42,12 +61,12 @@ SDK 同时提供 **Anthropic + OpenAI 两条 endpoint**,**等地位**,对应
|
|
|
42
61
|
| `AnthropicAdapter` | `POST /managed-models/:id/anthropic` | Anthropic 原生格式(含 thinking 等)|
|
|
43
62
|
| `OpenAIAdapter` | `POST /managed-models/:id/chat` | OpenAI 兼容格式(DeepSeek/GLM 等) |
|
|
44
63
|
|
|
45
|
-
路由由 `getAdapterForModel(model)` 按 ManagedModel 的 `
|
|
64
|
+
路由由 `getAdapterForModel(model)` 按 ManagedModel 的 `preferred_format` / `supported_formats` 决策(wire-format 字段,snake_case 与上游 Go json tag 严格对齐;ManagedModel 上其余顶层字段如 `modelId` / `isEnabled` / `inputModalities` 走 camelCase,详见 `src/models/types.ts`):
|
|
46
65
|
|
|
47
|
-
1. `
|
|
48
|
-
2. `
|
|
49
|
-
3. `
|
|
50
|
-
4. 两字段均空(旧上游)→ 按 provider 名回落
|
|
66
|
+
1. `preferred_format` 非空 → 按值(`anthropic` | `openai`)
|
|
67
|
+
2. `supported_formats` 含 `anthropic` → AnthropicAdapter
|
|
68
|
+
3. `supported_formats` 含 `openai` → OpenAIAdapter
|
|
69
|
+
4. 两字段均空(旧上游)→ 按 `provider` 名回落
|
|
51
70
|
|
|
52
71
|
`client.chat()` / `client.chatStream()` 内部自动调 `getAdapterForModel`,使用方无需关心。
|
|
53
72
|
|
|
@@ -66,7 +85,7 @@ SDK 同时提供 **Anthropic + OpenAI 两条 endpoint**,**等地位**,对应
|
|
|
66
85
|
```ts
|
|
67
86
|
const stream = client.chatStream('claude-opus-4-7', {
|
|
68
87
|
messages: [{ role: 'user', content: '写一首诗' }],
|
|
69
|
-
|
|
88
|
+
max_tokens: 1024,
|
|
70
89
|
});
|
|
71
90
|
|
|
72
91
|
for await (const ev of stream) {
|
|
@@ -142,6 +161,24 @@ await client.agentRuns.cancel(run.runId); // safe to call from UI cancel buttons
|
|
|
142
161
|
|
|
143
162
|
`stream(runId)` 支持 durable replay:断线后重新连接同一个 run,会先回放已持久化的 Agent Run SSE 事件,再继续消费运行中的事件。`usage` / `settle` 事件会暴露 `exact`、`cacheReadTokens`、`cacheCreateTokens` 等字段,便于下游展示真实结算状态。
|
|
144
163
|
|
|
164
|
+
**`AgentRunStreamEvent` 完整事件类型**(union,详见 `src/agent-runs/types.ts`;上面示例只演示了 4 种常见分支):
|
|
165
|
+
|
|
166
|
+
| `type` | 触发 / 含义 | 关键字段 |
|
|
167
|
+
| --- | --- | --- |
|
|
168
|
+
| `run_started` | 流首事件,确认服务端已开始执行 | `runId`、`sessionId` |
|
|
169
|
+
| `status` | 任务粗粒度状态变化 | `status` (`queued`/`running`/`completed`/`failed`/`cancelled`)、`message?` |
|
|
170
|
+
| `text_delta` | 主要文本输出增量 | `text` |
|
|
171
|
+
| `reasoning_delta` | 推理 / 思考过程增量(debug 用,不一定向终端用户展示) | `text` |
|
|
172
|
+
| `tool_call` | Agent 发起内置 / 网关工具调用 | `id`、`name`、`input?` |
|
|
173
|
+
| `tool_result` | 内置 / 网关工具调用结果 | `id`、`name?`、`result?`、`error?` |
|
|
174
|
+
| `local_tool_request` | Agent 请求宿主提供本地只读工具结果,宿主须用 `submitLocalToolResult` 回填 | `requestId`、`name`、`input` |
|
|
175
|
+
| `artifact` | 产出文件(图片 / 代码 / 文档等);用 `downloadArtifact(runId, artifact.id)` 下载 | `artifact: AgentRunArtifact` |
|
|
176
|
+
| `sources` | 网络检索 / RAG 来源信息 | `sources` |
|
|
177
|
+
| `usage` | provider/ADK 透传的 token usage | `usage.exact`、`inputTokens`、`outputTokens`、`totalTokens`、`cacheReadTokens`、`cacheCreateTokens` |
|
|
178
|
+
| `settle` | 服务端结算事件 | `settlement.status`、`tokenRemaining`、`callRemaining`、`exact`、`retryQueued` |
|
|
179
|
+
| `error` | 失败事件(`throwOnError:true` 默认会转 `AgentRunStreamError` 抛出) | `error.code`、`error.message`、`error.stage`、`error.retryable` |
|
|
180
|
+
| `done` | 流终止 | `runId`、`status` |
|
|
181
|
+
|
|
145
182
|
## 认证
|
|
146
183
|
|
|
147
184
|
### 浏览器内 / 自动 OAuth(推荐)
|
|
@@ -153,17 +190,45 @@ const token = await client.ensureToken(); // 拿到当前有效 access toke
|
|
|
153
190
|
|
|
154
191
|
### 手动 OAuth(CLI / 自定义流程)
|
|
155
192
|
|
|
193
|
+
底层 helper 适用于自管 token 的 CLI / 自定义授权 UI。**大多数场景直接用 `client.login(appName, scopes)` 即可**——它内部封装了下面全部步骤。完整可运行示例见 [`examples/auth-oauth-flow.ts`](./examples/auth-oauth-flow.ts)。
|
|
194
|
+
|
|
156
195
|
```ts
|
|
157
|
-
import {
|
|
196
|
+
import {
|
|
197
|
+
discover, // RFC 8414 元数据发现
|
|
198
|
+
register, // RFC 7591 动态客户端注册
|
|
199
|
+
authorize, // 本地 loopback PKCE(仅 Node)
|
|
200
|
+
exchangeCode, // code + verifier → token
|
|
201
|
+
refreshToken, // 续期
|
|
202
|
+
newTokenSet, // 把 TokenResponse 包成可持久化 TokenSet
|
|
203
|
+
FileTokenStore,
|
|
204
|
+
allScopes,
|
|
205
|
+
} from '@acosmi/sdk-ts';
|
|
158
206
|
|
|
159
207
|
const meta = await discover(process.env.ACOSMI_SERVER_URL!);
|
|
160
|
-
const reg = await register(meta, 'My CLI'
|
|
161
|
-
const
|
|
162
|
-
|
|
208
|
+
const reg = await register(meta, 'My CLI'); // 不接 scopes 参数
|
|
209
|
+
const scopes = allScopes();
|
|
210
|
+
|
|
211
|
+
// authorize 返回 { result, verifier },result.code + result.redirectURI 给 exchangeCode
|
|
212
|
+
const { result, verifier } = await authorize(meta, reg.client_id, scopes, {
|
|
213
|
+
handler: (ev) => {
|
|
214
|
+
if (ev.type === 'auth_url') console.log('open in browser:', ev.url);
|
|
215
|
+
},
|
|
163
216
|
});
|
|
164
|
-
|
|
217
|
+
|
|
218
|
+
const tokenResp = await exchangeCode(
|
|
219
|
+
meta,
|
|
220
|
+
reg.client_id,
|
|
221
|
+
result.code,
|
|
222
|
+
result.redirectURI, // 来自 authorize 返回;不是手动构造的 redirect_uri
|
|
223
|
+
verifier, // 来自 authorize 返回;不是 result.* 上的字段
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const tokens = newTokenSet(tokenResp, reg.client_id, process.env.ACOSMI_SERVER_URL!);
|
|
227
|
+
await new FileTokenStore('./tokens.json').save(tokens);
|
|
165
228
|
```
|
|
166
229
|
|
|
230
|
+
> 浏览器侧(无法启 loopback HTTP server)请改用 v1.4.0+ Web OAuth 原语 `discoverWebOAuthMetadata` + `registerWebOAuthClient` + `createWebAuthorizationRequest` + `completeWebAuthorizationRequest`,由调用方实现 popup / 同窗口 redirect handler,SDK 负责 PKCE / state 校验 / token 兑换。
|
|
231
|
+
|
|
167
232
|
### Token 持久化
|
|
168
233
|
|
|
169
234
|
```ts
|
|
@@ -179,16 +244,20 @@ const client = new Client({ serverURL: process.env.ACOSMI_SERVER_URL!, store: ne
|
|
|
179
244
|
|
|
180
245
|
| 模块 | 主要方法 |
|
|
181
246
|
| ------------ | ------------------------------------------------------------------------------------ |
|
|
182
|
-
| **
|
|
247
|
+
| **Client 构造** | `new Client(cfg)`(同步),`Client.create(cfg)`(async;预加载已有 TokenStore) |
|
|
248
|
+
| **Chat** | `chat`, `chatStream`, `chatStreamWithUsage`, `chatMessages`, `chatMessagesStream`, `buildChatRequest` |
|
|
183
249
|
| **Agent Runs** | `agentRuns.create`, `agentRuns.stream`, `agentRuns.run`, `agentRuns.cancel`, `agentRuns.get`, `agentRuns.listArtifacts`, `agentRuns.downloadArtifact`, `agentRuns.submitLocalToolResult`, `agentRuns.runWithLocalTools` |
|
|
184
|
-
| **Auth**
|
|
185
|
-
| **
|
|
186
|
-
| **
|
|
250
|
+
| **Auth — 内置 Loopback OAuth** | `login`, `loginWithHandler`, `logout`, `ensureToken`, `forceRefresh`, `isAuthorized`, `getTokenSet` |
|
|
251
|
+
| **Auth — 手动 OAuth 原语** | `discover`, `discoverWithProfile`, `register`, `authorize`, `exchangeCode`, `refreshToken`, `revokeToken`, `generateState` |
|
|
252
|
+
| **Auth — 浏览器 Web OAuth (v1.4.0+)** | `discoverWebOAuthMetadata`, `registerWebOAuthClient`, `createWebAuthorizationRequest`, `completeWebAuthorizationRequest` |
|
|
253
|
+
| **Models** | `listModels`, `listModelsWithStatus`, `getModelCapabilities`, `getQuotaSummary`, `ensureModelCached`, `modelSupportsInputModality`, `modelSupportsImageInput`, `findFirstModelByInputModality`, `findDesktopVisualUnderstandingModel` |
|
|
254
|
+
| **Skills** | `browseSkillStore`, `browseSkills`, `browseSkillsList`, `getSkillDetail`, `getSkillSummary`, `resolveSkill`, `installSkill`, `downloadSkill`, `uploadSkill`, `generateSkill`, `optimizeSkill`, `validateSkill`, `certifySkill`, `getCertificationStatus` |
|
|
187
255
|
| **Tools** | `listTools`, `getTool` |
|
|
188
256
|
| **Wallet** | `getWalletStats`, `getWalletTransactions` |
|
|
189
|
-
| **Entitlements** | `getBalance`, `getBalanceDetail`, `listEntitlements`, `claimMonthlyFree`, `getByModel`, `listBuckets`, `listCoefficients` |
|
|
190
|
-
| **Packages** | `listTokenPackages`, `buyTokenPackage`, `getOrderStatus`, `waitForPayment`
|
|
191
|
-
| **Notifications** | `listNotifications`, `getUnreadCount`, `markNotificationRead`, `registerDevice`, `listNotificationPreferences` |
|
|
257
|
+
| **Entitlements** | `getBalance`, `getBalanceDetail`, `listEntitlements`, `listConsumeRecords`, `claimMonthlyFree`, `getByModel`, `listBuckets`, `listCoefficients`, `invalidateCoefficientCache` |
|
|
258
|
+
| **Packages** | `listTokenPackages`, `getTokenPackageDetail`, `buyTokenPackage`, `getOrderStatus`, `listMyOrders`, `waitForPayment` |
|
|
259
|
+
| **Notifications** | `listNotifications`, `getUnreadCount`, `markNotificationRead`, `markAllNotificationsRead`, `deleteNotification`, `registerDevice`, `unregisterDevice`, `listNotificationPreferences`, `updateNotificationPreference` |
|
|
260
|
+
| **Notifications — WebSocket** | `connect`, `disconnect`, `isConnected` (实时推送订阅;浏览器走原生 WebSocket,Node 18-21 需自装 `ws`,Node 22+ 用原生) |
|
|
192
261
|
| **Bug Report** | `submitBugReport`, `getBugReport` |
|
|
193
262
|
| **Web Search** | `newWebSearchTool` (factory) |
|
|
194
263
|
| **Compliance** | `compliance.createEvidenceAsset`, `compliance.issueTimestamp`, `compliance.waitForTimestampVerified`, `compliance.buildEvidencePackage`, `compliance.createReport`, `compliance.downloadReport`, `compliance.createSigningEnvelope`, `compliance.signEnvelope`, `compliance.getProviderRequest`, `compliance.waitForProviderRequestTerminal` |
|
|
@@ -216,6 +285,39 @@ const client = new Client({ serverURL: process.env.ACOSMI_SERVER_URL!, store: ne
|
|
|
216
285
|
> `compliance` 分页 / gate 能力预沉淀的【共享原语】;消费这些类型的命名空间方法
|
|
217
286
|
> 须待对应后端端点就绪后才落地,当前 8 个占位命名空间尚未从根入口导出。
|
|
218
287
|
|
|
288
|
+
### `sanitize` 命名空间(历史消息清理)
|
|
289
|
+
|
|
290
|
+
`@acosmi/sdk-ts` 把 `src/sanitize/` 整体以命名空间方式导出(`import { sanitize } from '@acosmi/sdk-ts'`),同时也通过 `@acosmi/sdk-ts/sanitize` 子路径单独导入。Client 与 ChatRequest 的粘合(`Client.prototype.applyRequestSanitizers`)由 `src/core/sanitize-bridge.ts` 通过 declaration merging 自动注入。**默认零开销**——只有显式调用 `client.setDefensiveSanitize(cfg)` 或 `client.setAutoStripEphemeralHistory(true)` 后才走流水线。
|
|
291
|
+
|
|
292
|
+
| 公开符号 | 形态 | 用途 |
|
|
293
|
+
| --- | --- | --- |
|
|
294
|
+
| `client.setDefensiveSanitize(cfg)` | Client 方法(runtime 注入) | 配置请求前底线防御(`maxMessagesTurns` 历史轮深度、`permanentDenyBlocks` block 类型黑名单、`maxImageBytes` / `maxVideoBytes` / `maxPDFBytes` base64 内联媒体上限);传 `{}` 关闭 |
|
|
295
|
+
| `client.setAutoStripEphemeralHistory(on)` | Client 方法(runtime 注入) | 开启后每次请求自动从 `rawMessages` 剥除带 `acosmi_ephemeral:true` 标记的 block,并联动剥引用已剥 `tool_use_id` 的 `tool_result` |
|
|
296
|
+
| `client.applyRequestSanitizers(req)` | Client 方法(buildChatRequest 内部自动调用) | 一般无需手动调;自定义 build 链路时可直接复用 |
|
|
297
|
+
| `sanitize.sanitize(messages, cfg)` | 函数 | 对消息历史做白名单过滤 + 深度 / 尺寸校验 + ephemeral 剥离,返回新数组 |
|
|
298
|
+
| `sanitize.dropBlocks(messages, predicate)` | 函数 | 按谓词剔除 content blocks(联动剔除引用同 tool_use_id 的 tool_result) |
|
|
299
|
+
| `sanitize.stripEphemeral(messages)` | 函数 | 剥离 `acosmi_ephemeral:true` 块(端口自 Go `sanitize.StripEphemeral`,bug-for-bug) |
|
|
300
|
+
| `sanitize.MinimalSanitizeConfig` | 类型 | sanitize 配置 |
|
|
301
|
+
| `sanitize.BlockType` / `BlockText` / `BlockImage` / `BlockVideo` / `BlockDocument` / `BlockSearchResult` / `BlockThinking` / `BlockRedactedThinking` / `BlockToolUse` / `BlockToolResult` / `BlockToolReference` / `BlockServerToolUse` / `BlockWebSearchToolResult` / `BlockCodeExecutionToolResult` / `BlockMCPToolUse` / `BlockMCPToolResult` / `BlockContainerUpload` | 类型 + 常量 | 已知 block 类型常量 |
|
|
302
|
+
| `sanitize.HistoryTooDeepError` / `BlockDeniedError` / `SizeError` | 错误 | sanitize 规则不通过时分类抛出(也导出对应单例 `ErrHistoryTooDeep` / `ErrBlockDenied`) |
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
import { Client, sanitize } from '@acosmi/sdk-ts';
|
|
306
|
+
|
|
307
|
+
const client = new Client({ serverURL });
|
|
308
|
+
|
|
309
|
+
// 启用底线防御 + 自动剥 ephemeral
|
|
310
|
+
client.setDefensiveSanitize({
|
|
311
|
+
maxMessagesTurns: 64,
|
|
312
|
+
// 其他字段按 MinimalSanitizeConfig 形态填充
|
|
313
|
+
});
|
|
314
|
+
client.setAutoStripEphemeralHistory(true);
|
|
315
|
+
|
|
316
|
+
// 之后 chat / chatStream 走 buildChatRequest 时自动应用 applyRequestSanitizers。
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
> 红线:**thinking 块在 Anthropic 续轮的"上一轮返回什么、下一轮就必须原样回传"硬约束下走豁免**,禁止从历史中剔除;`tool_use_id` 联动剔除规则参考 `test/sanitize/history.test.ts` 的 P0 红线测试。详细行为见 `src/sanitize/history.ts` + `defensive.ts`。
|
|
320
|
+
|
|
219
321
|
### 示例:Skill 商店搜索
|
|
220
322
|
|
|
221
323
|
```ts
|
|
@@ -246,7 +348,7 @@ const tool = newWebSearchTool({
|
|
|
246
348
|
|
|
247
349
|
const resp = await client.chat('claude-opus-4-7', {
|
|
248
350
|
messages: [{ role: 'user', content: '查一下 Web Components 最新规范' }],
|
|
249
|
-
|
|
351
|
+
max_tokens: 2048,
|
|
250
352
|
tools: [tool],
|
|
251
353
|
});
|
|
252
354
|
```
|
|
@@ -323,13 +425,14 @@ const view = await client.getBugReport(result.feedback_id);
|
|
|
323
425
|
| 错误类型 | 触发 |
|
|
324
426
|
| -------------------- | ---------------------------------------------------------------------- |
|
|
325
427
|
| `HTTPError` | 4xx/5xx,含 `statusCode` / `body` / `type` / `retryAfter` |
|
|
326
|
-
| `NetworkError` | TCP/DNS/TLS
|
|
327
|
-
| `StreamError` |
|
|
428
|
+
| `NetworkError` | TCP/DNS/TLS 失败;含 `isTimeout()` / `isEOF()` 便捷判定 |
|
|
429
|
+
| `StreamError` | gateway `managed_model_stream_failed` 事件解析(含 `code` / `stage` / `retryable`) |
|
|
328
430
|
| `AgentRunStreamError` | Agent Runs 流返回 `error` 事件(默认抛出;可设 `throwOnError:false` 自行消费) |
|
|
329
431
|
| `BusinessError` | 网关返回 `code !== 0`,含 `code` (number) / `message` (字符串) |
|
|
330
432
|
| `RateLimitError` | 429(含 `retryAfter`) |
|
|
331
433
|
| `OrderTerminalError` | `waitForPayment` 终态失败 |
|
|
332
|
-
| `
|
|
434
|
+
| `ModelNotFoundError` | `chat` / `ensureModelCached`:listModels 自动刷新一次后仍未命中目标 modelId(v0.13.x 起替代旧硬返 anthropic 占位的行为,含 `modelId` 字段) |
|
|
435
|
+
| `CompliancePollError` | `waitForTimestampVerified` / `waitForProviderRequestTerminal` 终态失败或超时(含 `kind: 'timeout' | 'terminal_failure' | 'unknown'`) |
|
|
333
436
|
|
|
334
437
|
```ts
|
|
335
438
|
import { HTTPError, BusinessError } from '@acosmi/sdk-ts';
|
|
@@ -482,6 +585,7 @@ client.compliance.getCapabilities(signal?) // 能力闸门列表
|
|
|
482
585
|
client.compliance.getFeatureGate(action, signal?) // 单动作能力(便捷,一次网络请求)
|
|
483
586
|
client.compliance.listOperations(req?, signal?) // 操作投影分页 → PageResult
|
|
484
587
|
client.compliance.getOperation(id, signal?) // 操作投影详情
|
|
588
|
+
client.compliance.classifyError(err) // BusinessError → ComplianceErrorInfo | null(同顶层 classifyComplianceError,便于在 catch 块上链式调用)
|
|
485
589
|
|
|
486
590
|
client.compliance.listTsaProviders(signal?) // TSA provider 只读列表
|
|
487
591
|
client.compliance.getTsaStats(signal?) // 时间章统计只读视图
|
|
@@ -579,7 +683,8 @@ npm run docs # 经 TypeDoc 生成 API 参考到 docs/api/
|
|
|
579
683
|
|
|
580
684
|
| 版本 | 状态 | 概要 |
|
|
581
685
|
| --- | --- | --- |
|
|
582
|
-
| 1.5.
|
|
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` 全绿。 |
|
|
687
|
+
| 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 个平台控制面占位命名空间仍待后端契约就绪后落地。 |
|
|
583
688
|
| 1.4.2 | 稳定版 | `src/` 从扁平 36 文件按业务域重组为 per-domain 目录;公共导出符号集合、`exports`、`dist/` 路径一字未变(纯内部重组)。新增 TypeDoc API 文档。 |
|
|
584
689
|
| 1.4.1 | 稳定版 | 新增 `Config.browserRefreshMode` / `refreshProxyURL`——浏览器 Web OAuth token 刷新策略(规避 issuer CORS 403)。 |
|
|
585
690
|
| 1.4.0 | 稳定版 | 新增浏览器 Web OAuth 原语 `discoverWebOAuthMetadata` / `registerWebOAuthClient`(csign `/login` Web OAuth 接入)。 |
|
package/dist/browser/index.mjs
CHANGED
|
@@ -365,8 +365,17 @@ var init_anthropic = __esm({
|
|
|
365
365
|
body["effort"] = req.effort;
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
if (req.metadata) {
|
|
369
|
-
|
|
368
|
+
if (req.metadata || req.endUserId && req.endUserId !== "") {
|
|
369
|
+
const meta = {};
|
|
370
|
+
if (req.metadata) {
|
|
371
|
+
for (const [k, v] of Object.entries(req.metadata)) {
|
|
372
|
+
meta[k] = v;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (req.endUserId && req.endUserId !== "" && meta["user_id"] === void 0) {
|
|
376
|
+
meta["user_id"] = req.endUserId;
|
|
377
|
+
}
|
|
378
|
+
body["metadata"] = meta;
|
|
370
379
|
}
|
|
371
380
|
const allTools = [];
|
|
372
381
|
if (req.tools != null) {
|
|
@@ -710,6 +719,9 @@ var init_openai = __esm({
|
|
|
710
719
|
body[k] = v;
|
|
711
720
|
}
|
|
712
721
|
}
|
|
722
|
+
if (req.endUserId && req.endUserId !== "") {
|
|
723
|
+
body["user_id"] = req.endUserId;
|
|
724
|
+
}
|
|
713
725
|
if (req.stream === true) {
|
|
714
726
|
body["stream_options"] = { include_usage: true };
|
|
715
727
|
}
|
|
@@ -1773,6 +1785,30 @@ function extractAnthropicBlockMeta(eventType, data, blockTypeMap) {
|
|
|
1773
1785
|
// src/core/client.ts
|
|
1774
1786
|
init_openai();
|
|
1775
1787
|
|
|
1788
|
+
// src/models/enduser.ts
|
|
1789
|
+
var maxEndUserIdLength = 512;
|
|
1790
|
+
function validateEndUserId(s) {
|
|
1791
|
+
if (!s) return null;
|
|
1792
|
+
if (s.length > maxEndUserIdLength) {
|
|
1793
|
+
return `endUserId length ${s.length} > ${maxEndUserIdLength}`;
|
|
1794
|
+
}
|
|
1795
|
+
for (let i = 0; i < s.length; i++) {
|
|
1796
|
+
const c = s.charCodeAt(i);
|
|
1797
|
+
const ok = c >= 97 && c <= 122 || // a-z
|
|
1798
|
+
c >= 65 && c <= 90 || // A-Z
|
|
1799
|
+
c >= 48 && c <= 57 || // 0-9
|
|
1800
|
+
c === 95 || // _
|
|
1801
|
+
c === 45;
|
|
1802
|
+
if (!ok) {
|
|
1803
|
+
return `endUserId contains invalid char code 0x${c.toString(16)} at offset ${i} (allowed: [a-zA-Z0-9_-])`;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
return null;
|
|
1807
|
+
}
|
|
1808
|
+
function isSSECommentLine(line) {
|
|
1809
|
+
return line.length > 0 && line.charCodeAt(0) === 58;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1776
1812
|
// src/core/http.ts
|
|
1777
1813
|
init_errors();
|
|
1778
1814
|
var maxDownloadSize = 50 * 1024 * 1024;
|
|
@@ -1963,6 +1999,7 @@ var FilterStatusUnknown = "";
|
|
|
1963
1999
|
var ErrOAuthCORSBlocked = "oauth_cors_blocked";
|
|
1964
2000
|
var ErrRefreshProxyFailed = "refresh_proxy_failed";
|
|
1965
2001
|
var ErrTokenExpired = "token_expired";
|
|
2002
|
+
var CHAT_REQUEST_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
1966
2003
|
function newDeferred() {
|
|
1967
2004
|
let resolve;
|
|
1968
2005
|
let reject;
|
|
@@ -2556,7 +2593,7 @@ var Client = class _Client {
|
|
|
2556
2593
|
*/
|
|
2557
2594
|
async chat(modelID, req, signal) {
|
|
2558
2595
|
req.stream = false;
|
|
2559
|
-
const ctl = withRequestTimeout(
|
|
2596
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2560
2597
|
try {
|
|
2561
2598
|
const { body, adapter } = await this.buildChatRequest(modelID, req, ctl.signal);
|
|
2562
2599
|
const endpoint = `/managed-models/${encodeURIComponent(modelID)}${adapter.endpointSuffix()}`;
|
|
@@ -2603,7 +2640,7 @@ var Client = class _Client {
|
|
|
2603
2640
|
}
|
|
2604
2641
|
async chatMessagesAnthropic(modelID, req, adapter, signal) {
|
|
2605
2642
|
req.stream = false;
|
|
2606
|
-
const ctl = withRequestTimeout(
|
|
2643
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2607
2644
|
try {
|
|
2608
2645
|
const caps = this.getCachedCapabilities(modelID) ?? zeroModelCapabilities();
|
|
2609
2646
|
const body = adapter.buildRequestBody(caps, req);
|
|
@@ -2640,7 +2677,7 @@ var Client = class _Client {
|
|
|
2640
2677
|
}
|
|
2641
2678
|
async chatMessagesOpenAI(modelID, req, adapter, signal) {
|
|
2642
2679
|
req.stream = false;
|
|
2643
|
-
const ctl = withRequestTimeout(
|
|
2680
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2644
2681
|
try {
|
|
2645
2682
|
const caps = this.getCachedCapabilities(modelID) ?? zeroModelCapabilities();
|
|
2646
2683
|
const body = adapter.buildRequestBody(caps, req);
|
|
@@ -2721,6 +2758,7 @@ var Client = class _Client {
|
|
|
2721
2758
|
}
|
|
2722
2759
|
let currentEvent = "";
|
|
2723
2760
|
for await (const line of iterSSELines(resp.body)) {
|
|
2761
|
+
if (isSSECommentLine(line)) continue;
|
|
2724
2762
|
if (line.startsWith("event:")) {
|
|
2725
2763
|
currentEvent = line.slice("event:".length).trim();
|
|
2726
2764
|
} else if (line.startsWith("data:")) {
|
|
@@ -2786,6 +2824,7 @@ var Client = class _Client {
|
|
|
2786
2824
|
if (adapter.format() === 1 /* OpenAI */) {
|
|
2787
2825
|
const converter = newOpenAIStreamConverter();
|
|
2788
2826
|
for await (const line of iterSSELines(resp.body)) {
|
|
2827
|
+
if (isSSECommentLine(line)) continue;
|
|
2789
2828
|
if (line.startsWith("event:")) {
|
|
2790
2829
|
line.slice("event:".length).trim();
|
|
2791
2830
|
} else if (line.startsWith("data:")) {
|
|
@@ -2799,6 +2838,7 @@ var Client = class _Client {
|
|
|
2799
2838
|
const blockTypeMap = /* @__PURE__ */ new Map();
|
|
2800
2839
|
let currentEvent = "";
|
|
2801
2840
|
for await (const line of iterSSELines(resp.body)) {
|
|
2841
|
+
if (isSSECommentLine(line)) continue;
|
|
2802
2842
|
if (line.startsWith("event:")) {
|
|
2803
2843
|
currentEvent = line.slice("event:".length).trim();
|
|
2804
2844
|
} else if (line.startsWith("data:")) {
|
|
@@ -6086,6 +6126,6 @@ Client.prototype.getBugReport = async function(bugID, signal) {
|
|
|
6086
6126
|
return resp.data;
|
|
6087
6127
|
};
|
|
6088
6128
|
|
|
6089
|
-
export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, ComplianceClient, CompliancePollError, LocalStorageTokenStore as DefaultBrowserTokenStore, DefaultRetryPolicy, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, IdempotencyKeyHeader, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProviderFormat, RETRY_ADVICE_REASONS, RateLimitError, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, getAdapter, getAdapterForModel, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSLError, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge };
|
|
6129
|
+
export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, ComplianceClient, CompliancePollError, LocalStorageTokenStore as DefaultBrowserTokenStore, DefaultRetryPolicy, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, IdempotencyKeyHeader, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProviderFormat, RETRY_ADVICE_REASONS, RateLimitError, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, getAdapter, getAdapterForModel, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSECommentLine, isSSLError, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };
|
|
6090
6130
|
//# sourceMappingURL=index.mjs.map
|
|
6091
6131
|
//# sourceMappingURL=index.mjs.map
|