@tansr/serve 0.3.0 → 0.3.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
|
@@ -56935,7 +56935,11 @@ function twpErrorToIR(code, message, detail) {
|
|
|
56935
56935
|
return {
|
|
56936
56936
|
kind: mapped.kind,
|
|
56937
56937
|
message: text,
|
|
56938
|
-
|
|
56938
|
+
// S-TH4(2026-09-01):服务端确定性拒绝声明恒胜码表——detail.retryable
|
|
56939
|
+
// === false 即不可恢复(上游 4xx 同参重发恒同拒;gpt-5.6-sol 实证
|
|
56940
|
+
// reasoning_effort×tools 400 被 upstream_error 码表重试 14 次的风暴止血)。
|
|
56941
|
+
// 加法容忍:键缺席/异型恒走码表现状。
|
|
56942
|
+
recoverable: detail?.["retryable"] === false ? false : mapped.recoverable,
|
|
56939
56943
|
...retryAfterMs !== void 0 ? { retryAfterMs } : {}
|
|
56940
56944
|
};
|
|
56941
56945
|
}
|
|
@@ -60556,10 +60560,30 @@ function createAppTokenFetch(token, inner) {
|
|
|
60556
60560
|
};
|
|
60557
60561
|
return wrapped;
|
|
60558
60562
|
}
|
|
60563
|
+
async function fetchTwpFeatures(base, token, fetchImpl, sessionId) {
|
|
60564
|
+
try {
|
|
60565
|
+
const response = await fetchImpl(`${base}${TWP_ENDPOINT_PATHS.heartbeat}`, {
|
|
60566
|
+
method: "POST",
|
|
60567
|
+
headers: {
|
|
60568
|
+
"content-type": "application/json",
|
|
60569
|
+
accept: "application/json",
|
|
60570
|
+
[HEADER_APP_TOKEN]: token
|
|
60571
|
+
},
|
|
60572
|
+
body: JSON.stringify({ client: "sdk", ...sessionId !== void 0 ? { sessionId } : {} })
|
|
60573
|
+
});
|
|
60574
|
+
if (!response.ok) return void 0;
|
|
60575
|
+
const raw = await response.json();
|
|
60576
|
+
const features = raw?.features;
|
|
60577
|
+
return Array.isArray(features) ? features.filter((f) => typeof f === "string") : void 0;
|
|
60578
|
+
} catch {
|
|
60579
|
+
return void 0;
|
|
60580
|
+
}
|
|
60581
|
+
}
|
|
60559
60582
|
async function assemblePlatformModel(options) {
|
|
60560
60583
|
const base = options.baseUrl.replace(/\/+$/, "");
|
|
60561
60584
|
const innerFetch = options.fetchImpl ?? fetch;
|
|
60562
60585
|
const url = `${base}${TWP_ENDPOINT_PATHS.config}`;
|
|
60586
|
+
const featuresPromise = fetchTwpFeatures(base, options.token, innerFetch, options.sessionId?.());
|
|
60563
60587
|
let response;
|
|
60564
60588
|
try {
|
|
60565
60589
|
response = await innerFetch(url, {
|
|
@@ -60596,13 +60620,18 @@ async function assemblePlatformModel(options) {
|
|
|
60596
60620
|
`App config bundle from ${url} has an unexpected shape. Check that "baseUrl" points to the tansr API.`
|
|
60597
60621
|
);
|
|
60598
60622
|
}
|
|
60623
|
+
const features = await featuresPromise;
|
|
60599
60624
|
const registry = new ProviderRegistry(appBundleRegistryConfig(bundle, base), {
|
|
60600
60625
|
// 占位哑值:满足装配期 readApiKey 非空校验;真实鉴权恒由 fetch 包装注入
|
|
60601
60626
|
env: { [APP_TOKEN_PLACEHOLDER_ENV]: APP_TOKEN_PLACEHOLDER_VALUE },
|
|
60602
60627
|
fetchImpl: createAppTokenFetch(options.token, options.fetchImpl),
|
|
60603
60628
|
// 拍板⑤:平台会话 id 供给经既有 TwpClientOptions.sessionId 缝出线——
|
|
60604
|
-
// registry 为会话私有(每次装配新建),setModel/Task
|
|
60605
|
-
|
|
60629
|
+
// registry 为会话私有(每次装配新建),setModel/Task 子代理同缝同值。
|
|
60630
|
+
// S-TH3:features 能力串同缝供给(闭包定格;undefined = 门全关同现状)
|
|
60631
|
+
twp: {
|
|
60632
|
+
...options.sessionId !== void 0 ? { sessionId: options.sessionId } : {},
|
|
60633
|
+
features: () => features
|
|
60634
|
+
}
|
|
60606
60635
|
});
|
|
60607
60636
|
const built = buildClientFromRegistry(registry, options.model ?? "main", options.onProviderSelected);
|
|
60608
60637
|
return { ...built, registry, capabilities: bundle.capabilities, platformModels: bundle.platformModels };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tansr/serve",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Tansr agent session server: the bare /v2 agent-session protocol engine (REST + SSE) you embed in your own Node service. Session auth is fully yours via the authenticate seam. Published as @tansr/serve (decided 2026-09-01); the pack script stamps the publish name into the tarball.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|