@tansr/sdk 0.7.0 → 0.7.2
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/dist/index.js +32 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28806,7 +28806,11 @@ function twpErrorToIR(code, message, detail) {
|
|
|
28806
28806
|
return {
|
|
28807
28807
|
kind: mapped.kind,
|
|
28808
28808
|
message: text,
|
|
28809
|
-
|
|
28809
|
+
// S-TH4(2026-09-01):服务端确定性拒绝声明恒胜码表——detail.retryable
|
|
28810
|
+
// === false 即不可恢复(上游 4xx 同参重发恒同拒;gpt-5.6-sol 实证
|
|
28811
|
+
// reasoning_effort×tools 400 被 upstream_error 码表重试 14 次的风暴止血)。
|
|
28812
|
+
// 加法容忍:键缺席/异型恒走码表现状。
|
|
28813
|
+
recoverable: detail?.["retryable"] === false ? false : mapped.recoverable,
|
|
28810
28814
|
...retryAfterMs !== void 0 ? { retryAfterMs } : {}
|
|
28811
28815
|
};
|
|
28812
28816
|
}
|
|
@@ -32075,10 +32079,30 @@ function validateTokenTierOptions(api, options) {
|
|
|
32075
32079
|
);
|
|
32076
32080
|
}
|
|
32077
32081
|
}
|
|
32082
|
+
async function fetchTwpFeatures(base, token, fetchImpl, sessionId) {
|
|
32083
|
+
try {
|
|
32084
|
+
const response = await fetchImpl(`${base}${TWP_ENDPOINT_PATHS.heartbeat}`, {
|
|
32085
|
+
method: "POST",
|
|
32086
|
+
headers: {
|
|
32087
|
+
"content-type": "application/json",
|
|
32088
|
+
accept: "application/json",
|
|
32089
|
+
[HEADER_APP_TOKEN]: token
|
|
32090
|
+
},
|
|
32091
|
+
body: JSON.stringify({ client: "sdk", ...sessionId !== void 0 ? { sessionId } : {} })
|
|
32092
|
+
});
|
|
32093
|
+
if (!response.ok) return void 0;
|
|
32094
|
+
const raw = await response.json();
|
|
32095
|
+
const features = raw?.features;
|
|
32096
|
+
return Array.isArray(features) ? features.filter((f) => typeof f === "string") : void 0;
|
|
32097
|
+
} catch {
|
|
32098
|
+
return void 0;
|
|
32099
|
+
}
|
|
32100
|
+
}
|
|
32078
32101
|
async function assemblePlatformModel(options) {
|
|
32079
32102
|
const base = options.baseUrl.replace(/\/+$/, "");
|
|
32080
32103
|
const innerFetch = options.fetchImpl ?? fetch;
|
|
32081
32104
|
const url = `${base}${TWP_ENDPOINT_PATHS.config}`;
|
|
32105
|
+
const featuresPromise = fetchTwpFeatures(base, options.token, innerFetch, options.sessionId?.());
|
|
32082
32106
|
let response;
|
|
32083
32107
|
try {
|
|
32084
32108
|
response = await innerFetch(url, {
|
|
@@ -32115,13 +32139,18 @@ async function assemblePlatformModel(options) {
|
|
|
32115
32139
|
`App config bundle from ${url} has an unexpected shape. Check that "baseUrl" points to the tansr API.`
|
|
32116
32140
|
);
|
|
32117
32141
|
}
|
|
32142
|
+
const features = await featuresPromise;
|
|
32118
32143
|
const registry = new ProviderRegistry(appBundleRegistryConfig(bundle, base), {
|
|
32119
32144
|
// 占位哑值:满足装配期 readApiKey 非空校验;真实鉴权恒由 fetch 包装注入
|
|
32120
32145
|
env: { [APP_TOKEN_PLACEHOLDER_ENV]: APP_TOKEN_PLACEHOLDER_VALUE },
|
|
32121
32146
|
fetchImpl: createAppTokenFetch(options.token, options.fetchImpl),
|
|
32122
32147
|
// 拍板⑤:平台会话 id 供给经既有 TwpClientOptions.sessionId 缝出线——
|
|
32123
|
-
// registry 为会话私有(每次装配新建),setModel/Task
|
|
32124
|
-
|
|
32148
|
+
// registry 为会话私有(每次装配新建),setModel/Task 子代理同缝同值。
|
|
32149
|
+
// S-TH3:features 能力串同缝供给(闭包定格;undefined = 门全关同现状)
|
|
32150
|
+
twp: {
|
|
32151
|
+
...options.sessionId !== void 0 ? { sessionId: options.sessionId } : {},
|
|
32152
|
+
features: () => features
|
|
32153
|
+
}
|
|
32125
32154
|
});
|
|
32126
32155
|
const built = buildClientFromRegistry(registry, options.model ?? "main", options.onProviderSelected);
|
|
32127
32156
|
return { ...built, registry, capabilities: bundle.capabilities, platformModels: bundle.platformModels };
|
package/package.json
CHANGED