@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProviderAdapter,
|
|
1
|
+
import { P as ProviderAdapter, i as ProviderFormat, h as ModelCapabilities, e as ChatRequest, f as ChatResponse, l as StreamEvent } from './index-C9X5Yuyk.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Anthropic 内容块
|
|
@@ -122,4 +122,4 @@ declare class OpenAIStreamConverter {
|
|
|
122
122
|
}
|
|
123
123
|
declare function newOpenAIStreamConverter(): OpenAIStreamConverter;
|
|
124
124
|
|
|
125
|
-
export { type
|
|
125
|
+
export { type AnthropicContentBlock as A, OpenAIAdapter as O, type AnthropicResponse as a, type AnthropicUsage as b, OpenAIStreamConverter as c, anthropicResponseTextContent as d, anthropicResponseThinkingContent as e, anthropicResponseToolUseBlocks as f, resolveOpenAIResponseFormat as g, newOpenAIStreamConverter as n, parseOpenAIResponseToAnthropic as p, resolveOpenAIReasoningEffort as r };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProviderAdapter,
|
|
1
|
+
import { P as ProviderAdapter, i as ProviderFormat, h as ModelCapabilities, e as ChatRequest, f as ChatResponse, l as StreamEvent } from './index-C9X5Yuyk.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Anthropic 内容块
|
|
@@ -122,4 +122,4 @@ declare class OpenAIStreamConverter {
|
|
|
122
122
|
}
|
|
123
123
|
declare function newOpenAIStreamConverter(): OpenAIStreamConverter;
|
|
124
124
|
|
|
125
|
-
export { type
|
|
125
|
+
export { type AnthropicContentBlock as A, OpenAIAdapter as O, type AnthropicResponse as a, type AnthropicUsage as b, OpenAIStreamConverter as c, anthropicResponseTextContent as d, anthropicResponseThinkingContent as e, anthropicResponseToolUseBlocks as f, resolveOpenAIResponseFormat as g, newOpenAIStreamConverter as n, parseOpenAIResponseToAnthropic as p, resolveOpenAIReasoningEffort as r };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BlockCodeExecutionToolResult, a as BlockContainerUpload, b as BlockDeniedError, c as BlockDocument, d as BlockImage, e as BlockMCPToolResult, f as BlockMCPToolUse, g as BlockPredicate, h as BlockRedactedThinking,
|
|
1
|
+
export { B as BlockCodeExecutionToolResult, a as BlockContainerUpload, b as BlockDeniedError, c as BlockDocument, d as BlockImage, e as BlockMCPToolResult, f as BlockMCPToolUse, g as BlockPredicate, h as BlockRedactedThinking, i as BlockSearchResult, j as BlockServerToolUse, k as BlockText, l as BlockThinking, m as BlockToolReference, n as BlockToolResult, o as BlockToolUse, p as BlockType, q as BlockVideo, r as BlockWebSearchToolResult, D as DeltaCitations, s as DeltaInputJSON, t as DeltaSignature, u as DeltaText, v as DeltaThinking, w as DeltaType, E as EphemeralMarkerField, x as ErrBlockDenied, y as ErrHistoryTooDeep, H as HistoryTooDeepError, M as MinimalSanitizeConfig, S as SizeError, z as dropBlocks, C as sanitize, F as stripEphemeral } from '../index-Bah9A83R.cjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BlockCodeExecutionToolResult, a as BlockContainerUpload, b as BlockDeniedError, c as BlockDocument, d as BlockImage, e as BlockMCPToolResult, f as BlockMCPToolUse, g as BlockPredicate, h as BlockRedactedThinking,
|
|
1
|
+
export { B as BlockCodeExecutionToolResult, a as BlockContainerUpload, b as BlockDeniedError, c as BlockDocument, d as BlockImage, e as BlockMCPToolResult, f as BlockMCPToolUse, g as BlockPredicate, h as BlockRedactedThinking, i as BlockSearchResult, j as BlockServerToolUse, k as BlockText, l as BlockThinking, m as BlockToolReference, n as BlockToolResult, o as BlockToolUse, p as BlockType, q as BlockVideo, r as BlockWebSearchToolResult, D as DeltaCitations, s as DeltaInputJSON, t as DeltaSignature, u as DeltaText, v as DeltaThinking, w as DeltaType, E as EphemeralMarkerField, x as ErrBlockDenied, y as ErrHistoryTooDeep, H as HistoryTooDeepError, M as MinimalSanitizeConfig, S as SizeError, z as dropBlocks, C as sanitize, F as stripEphemeral } from '../index-Bah9A83R.js';
|
package/docs/compliance.md
CHANGED
|
@@ -90,15 +90,15 @@ Report scopes are split by action:
|
|
|
90
90
|
again) so the new scope is granted.
|
|
91
91
|
- `ScopeComplianceReportsPublish` — `publishReport` (also requires step-up).
|
|
92
92
|
|
|
93
|
-
Contract-template scopes (added in v1.
|
|
94
|
-
require step-up:
|
|
93
|
+
Contract-template scopes (added in v1.5.0; originally planned as v1.10.0 — see
|
|
94
|
+
CHANGELOG §"S5:合同模板") are split by direction and do not require step-up:
|
|
95
95
|
|
|
96
96
|
- `ScopeComplianceContractTemplateRead` — `getContractTemplate`,
|
|
97
97
|
`listContractTemplates`, `listContractTemplateVersions`.
|
|
98
98
|
- `ScopeComplianceContractTemplateWrite` — `createContractTemplate`,
|
|
99
99
|
`updateContractTemplate`, `deleteContractTemplate`,
|
|
100
100
|
`uploadContractTemplatePdf`, `publishContractTemplate`,
|
|
101
|
-
`archiveContractTemplate`. Tokens issued before v1.
|
|
101
|
+
`archiveContractTemplate`. Tokens issued before v1.5.0 do **not** carry these
|
|
102
102
|
scopes; existing users must re-authorize so the new scopes are granted.
|
|
103
103
|
|
|
104
104
|
## Base URL
|
|
@@ -244,7 +244,8 @@ if (view.status === 'SUCCESS') {
|
|
|
244
244
|
|
|
245
245
|
## Paginated Lists
|
|
246
246
|
|
|
247
|
-
Since v1.
|
|
247
|
+
Since v1.5.0 (originally planned as v1.6.0 — see CHANGELOG §"S1:6 个分页列表")
|
|
248
|
+
the SDK exposes paginated list reads against the backend
|
|
248
249
|
compliance gateway (`GET .../page`). Each returns a yudao `PageResult<T>`
|
|
249
250
|
(`{ total, list }` — the single SDK-wide pagination result shape, an alias of
|
|
250
251
|
`YudaoPageResult<T>`):
|
|
@@ -330,7 +331,8 @@ release.
|
|
|
330
331
|
|
|
331
332
|
## Capabilities And Operation Projection
|
|
332
333
|
|
|
333
|
-
Since v1.
|
|
334
|
+
Since v1.5.0 (originally planned as v1.7.0 — see CHANGELOG §"S2:capabilities +
|
|
335
|
+
operations 投影") the SDK exposes the compliance gateway S2 reads: a capability gate
|
|
334
336
|
query and an operation-projection view.
|
|
335
337
|
|
|
336
338
|
```ts
|
|
@@ -421,7 +423,8 @@ by the backend as `yyyy-MM-dd HH:mm:ss`; the SDK passes them through verbatim.
|
|
|
421
423
|
|
|
422
424
|
## TSA Readonly Views
|
|
423
425
|
|
|
424
|
-
Since v1.
|
|
426
|
+
Since v1.5.0 (originally planned as v1.8.0 — see CHANGELOG §"S3:TSA readonly
|
|
427
|
+
视图") the SDK exposes the compliance gateway S3 reads: two timestamp
|
|
425
428
|
authority (TSA) readonly views.
|
|
426
429
|
|
|
427
430
|
```ts
|
|
@@ -463,7 +466,8 @@ when no timestamps exist.
|
|
|
463
466
|
|
|
464
467
|
## Envelope Completion
|
|
465
468
|
|
|
466
|
-
Since v1.
|
|
469
|
+
Since v1.5.0 (originally planned as v1.9.0 — see CHANGELOG §"S4:envelope 收尾
|
|
470
|
+
+ void") the SDK exposes the compliance gateway S4 envelope-completion
|
|
467
471
|
surface: two readonly views and one write.
|
|
468
472
|
|
|
469
473
|
```ts
|
|
@@ -526,7 +530,8 @@ methods in this release.
|
|
|
526
530
|
|
|
527
531
|
## Contract Templates
|
|
528
532
|
|
|
529
|
-
Since v1.
|
|
533
|
+
Since v1.5.0 (originally planned as v1.10.0 — see CHANGELOG §"S5:合同模板")
|
|
534
|
+
the SDK exposes the compliance gateway S5 contract-template
|
|
530
535
|
surface: a `DRAFT` → `PUBLISHED` → `ARCHIVED` lifecycle with PDF upload, field
|
|
531
536
|
overlay, and immutable version snapshots.
|
|
532
537
|
|
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
// 说明:
|
|
12
12
|
// - 大多数场景直接用 `client.login(appName, scopes)` 即可(内部封装了下面全部步骤)。
|
|
13
13
|
// 本示例演示底层 helper,适用于需要自定义授权流程 / 自管 token 的 CLI。
|
|
14
|
-
// - authorize 仅在 Node 环境可用(需要本地 HTTP 回调 server
|
|
15
|
-
//
|
|
14
|
+
// - authorize 仅在 Node 环境可用(需要本地 HTTP 回调 server)。
|
|
15
|
+
// - 浏览器侧(无 loopback server)请改用 v1.4.0+ Web OAuth 原语:
|
|
16
|
+
// discoverWebOAuthMetadata + registerWebOAuthClient +
|
|
17
|
+
// createWebAuthorizationRequest + completeWebAuthorizationRequest,
|
|
18
|
+
// 由调用方实现 popup / 同窗口 redirect handler,SDK 负责 PKCE / state 校验 / token 兑换。
|
|
19
|
+
// 浏览器 token 刷新可配 Config.browserRefreshMode / refreshProxyURL (v1.4.1+) 规避 issuer CORS 403。
|
|
16
20
|
|
|
17
21
|
import {
|
|
18
22
|
discover,
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
ScopeComplianceTimestampIssue,
|
|
23
23
|
ScopeComplianceTimestampVerify,
|
|
24
24
|
ScopeComplianceReportsRead,
|
|
25
|
+
ScopeComplianceReportsWrite,
|
|
25
26
|
} from '@acosmi/sdk-ts';
|
|
26
27
|
|
|
27
28
|
// 模拟持久化的 Idempotency-Key 存储;生产环境应落 DB / 本地文件 / 业务订单表。
|
|
@@ -51,7 +52,8 @@ async function main() {
|
|
|
51
52
|
ScopeComplianceEvidenceWrite,
|
|
52
53
|
ScopeComplianceTimestampIssue,
|
|
53
54
|
ScopeComplianceTimestampVerify,
|
|
54
|
-
ScopeComplianceReportsRead,
|
|
55
|
+
ScopeComplianceReportsRead, // getReport / downloadReport
|
|
56
|
+
ScopeComplianceReportsWrite, // createReport(v1.3.2 起从 read 切到独立 write scope)
|
|
55
57
|
]);
|
|
56
58
|
|
|
57
59
|
// 1) 本地 sha256 (用户业务内容)
|
package/examples/core-chat.ts
CHANGED
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
// 5. 流式 chatStreamWithUsage 并聚合 usage / 结算事件
|
|
9
9
|
//
|
|
10
10
|
// 说明:
|
|
11
|
-
// - SDK 自动按 ManagedModel 的
|
|
12
|
-
// 或 OpenAI adapter
|
|
11
|
+
// - SDK 自动按 ManagedModel 的 preferred_format / supported_formats(snake_case
|
|
12
|
+
// wire 字段)选 Anthropic 或 OpenAI adapter,调用方无需关心。详见
|
|
13
|
+
// src/models/adapters/index.ts:getAdapterForModel。
|
|
13
14
|
// - 金额 / 余额字段是 string(避免 JS number 精度损失),不要做浮点运算。
|
|
15
|
+
// - ChatRequest 走 snake_case wire 字段(max_tokens 等),与上游 Go json tag 对齐;
|
|
16
|
+
// ManagedModel 顶层多为 camelCase(modelId / isEnabled / inputModalities)。
|
|
14
17
|
|
|
15
18
|
import { Client, allScopes, FileTokenStore } from '@acosmi/sdk-ts';
|
|
16
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acosmi/sdk-ts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Acosmi TypeScript SDK:模型网关、Agent Run Gateway 与 Compliance(电子证据、时间章、报告、签署 envelope)统一客户端,支持浏览器 / Node ≥18 / Deno / Bun。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.cjs",
|
|
@@ -94,6 +94,6 @@
|
|
|
94
94
|
"typedoc": "^0.28.19",
|
|
95
95
|
"typedoc-plugin-markdown": "^4.11.0",
|
|
96
96
|
"typescript": "^5.4.0",
|
|
97
|
-
"vitest": "^1.
|
|
97
|
+
"vitest": "^4.1.7"
|
|
98
98
|
}
|
|
99
99
|
}
|