@acosmi/sdk-ts 2.2.1 → 2.3.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 +16 -0
- package/dist/browser/index.mjs +4 -1
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +4 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +19 -0
- package/dist/node/index.d.ts +19 -0
- package/dist/node/index.mjs +4 -1
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ 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.3.0] - 2026-05-30 — `apiBaseURL` 可配置网关 base(additive,零回归)
|
|
9
|
+
|
|
10
|
+
Additive minor。新增一个可选 client 配置项,让浏览器侧 `/api/v4` 网关调用(managed-model / agent-run / **casehall**)可经**同源代理**转发,规避非网关同源域名(如 `sign.zhonglvbao.com`)下 acosmi.com 对带 `Origin` 跨域浏览器请求的 403。
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **`ClientConfig.apiBaseURL?: string`** — `/api/v4` 网关调用的 base 覆盖。未配置时 `apiURL()` 仍用 `serverURL`(**既有行为逐字节不变**,全部既有消费方 tk-dist-web / acosmi-web / CrabCode / 桌面不受影响)。与 `complianceBaseURL` 同构(compliance 走 `/admin-api`,本字段走 `/api/v4`),尾随 `/` 自动 trim,`apiURL()` 仍按需追加 `/api/v4` 不重复。
|
|
15
|
+
|
|
16
|
+
### 用法(浏览器经同源代理接 casehall,规避跨域 403)
|
|
17
|
+
|
|
18
|
+
1. 部署域名 nginx 加 `location /api/v4/ { proxy_pass https://acosmi.com/api/v4/; proxy_set_header Host acosmi.com; proxy_set_header Origin ""; proxy_set_header Authorization $http_authorization; }`(**仅 `/api/v4/`,不要用 `/api/`**——否则会劫持应用自身的 `/api/*` Route Handler)。
|
|
19
|
+
2. **浏览器端** client 配 `apiBaseURL: window.location.origin`。同源 GET 无 `Origin` 头 → nginx 服务端转发 acosmi.com → 不触跨域 403。
|
|
20
|
+
3. **服务端**(Route Handler)client **不设**本字段,直连 `serverURL`(服务端到 acosmi.com 无跨域)。
|
|
21
|
+
|
|
22
|
+
从 v2.2.x 升级无需任何 review:不传 `apiBaseURL` 即维持原状。
|
|
23
|
+
|
|
8
24
|
## [2.2.1] - 2026-05-29 — README 字段名修正(docs-only patch)
|
|
9
25
|
|
|
10
26
|
纯文档修正,无源码 / 类型 / 方法签名改动。修复 v2.2.0 README「图片/视频生成」示例中把能力字段误写为 camelCase(`supportsImageGeneration`)的问题——`ModelCapabilities` 是 wire snake_case 对象,正确字段为 `capabilities.supports_image_generation` / `supports_video_generation`(`listModels` 对 `capabilities` 对象原样透传,不归一化)。补充说明:这两个字段随 catalog 下发、为可选(缺省按 false)、且**无专用 catalog helper**(需直接读字段筛模型)。从 v2.2.0 升级无需任何 review。
|
package/dist/browser/index.mjs
CHANGED
|
@@ -2079,6 +2079,8 @@ var Client = class _Client {
|
|
|
2079
2079
|
serverURL;
|
|
2080
2080
|
/** Compliance API 根地址 (已 trim 尾随 /); null = 走默认 ${serverURL}/admin-api */
|
|
2081
2081
|
complianceBaseURL;
|
|
2082
|
+
/** `/api/v4` 网关调用 base 覆盖 (已 trim 尾随 /); null = 走默认 serverURL */
|
|
2083
|
+
apiBaseURL;
|
|
2082
2084
|
/** OAuth metadata profile — 刷新 token 时发现 metadata 用 (默认 'desktop') */
|
|
2083
2085
|
oauthMetadataProfile;
|
|
2084
2086
|
/** Browser Web OAuth refresh strategy (default 'direct') */
|
|
@@ -2120,6 +2122,7 @@ var Client = class _Client {
|
|
|
2120
2122
|
const picked = pickAndNormalizeGatewayURL(cfg);
|
|
2121
2123
|
this.serverURL = picked ?? DEFAULT_GATEWAY_BASE_URL;
|
|
2122
2124
|
this.complianceBaseURL = cfg.complianceBaseURL ? cfg.complianceBaseURL.replace(/\/+$/, "") : null;
|
|
2125
|
+
this.apiBaseURL = cfg.apiBaseURL ? cfg.apiBaseURL.replace(/\/+$/, "") : null;
|
|
2123
2126
|
this.oauthMetadataProfile = cfg.oauthMetadataProfile ?? "desktop";
|
|
2124
2127
|
this.browserRefreshMode = cfg.browserRefreshMode ?? "direct";
|
|
2125
2128
|
this.refreshProxyURL = cfg.refreshProxyURL ?? null;
|
|
@@ -3046,7 +3049,7 @@ var Client = class _Client {
|
|
|
3046
3049
|
// Internal HTTP
|
|
3047
3050
|
// ===========================================================================
|
|
3048
3051
|
apiURL(path) {
|
|
3049
|
-
let base = this.serverURL;
|
|
3052
|
+
let base = this.apiBaseURL ?? this.serverURL;
|
|
3050
3053
|
if (!base.endsWith("/api/v4")) {
|
|
3051
3054
|
base += "/api/v4";
|
|
3052
3055
|
}
|