@tansr/serve 0.2.0 → 0.3.1
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.d.ts +42 -2
- package/dist/index.js +42 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4397,7 +4397,24 @@ declare const CreateSessionBodySchema: z.ZodObject<{
|
|
|
4397
4397
|
readOnly?: boolean | undefined;
|
|
4398
4398
|
}>, "many">>;
|
|
4399
4399
|
capabilitiesProfile: z.ZodOptional<z.ZodString>;
|
|
4400
|
+
/**
|
|
4401
|
+
* S-TH2(用户拍板 2026-09-01,doc/98 冻结面加法):思考生成(生成面旋钮)
|
|
4402
|
+
* ——逐轮透传内核 IRRequest.thinking(budget = 思考 token 预算,按模型
|
|
4403
|
+
* 方言映射;平台令牌档经 TWP reasoning 档位出线,S-TH1)。缺席 = 装配面
|
|
4404
|
+
* 缺省(工厂 thinking 选项),两级皆缺席恒不注入(现状零漂移)。思考的
|
|
4405
|
+
* 呈现走客户端 SessionView delivery(呈现面),与本键正交。
|
|
4406
|
+
*/
|
|
4407
|
+
thinking: z.ZodOptional<z.ZodObject<{
|
|
4408
|
+
budget: z.ZodOptional<z.ZodNumber>;
|
|
4409
|
+
}, "strip", z.ZodTypeAny, {
|
|
4410
|
+
budget?: number | undefined;
|
|
4411
|
+
}, {
|
|
4412
|
+
budget?: number | undefined;
|
|
4413
|
+
}>>;
|
|
4400
4414
|
}, "strip", z.ZodTypeAny, {
|
|
4415
|
+
thinking?: {
|
|
4416
|
+
budget?: number | undefined;
|
|
4417
|
+
} | undefined;
|
|
4401
4418
|
model?: string | undefined;
|
|
4402
4419
|
tools?: string[] | undefined;
|
|
4403
4420
|
budget?: {
|
|
@@ -4422,6 +4439,9 @@ declare const CreateSessionBodySchema: z.ZodObject<{
|
|
|
4422
4439
|
}[] | undefined;
|
|
4423
4440
|
capabilitiesProfile?: string | undefined;
|
|
4424
4441
|
}, {
|
|
4442
|
+
thinking?: {
|
|
4443
|
+
budget?: number | undefined;
|
|
4444
|
+
} | undefined;
|
|
4425
4445
|
model?: string | undefined;
|
|
4426
4446
|
tools?: string[] | undefined;
|
|
4427
4447
|
budget?: {
|
|
@@ -4815,6 +4835,10 @@ interface AgentSessionCreateInit {
|
|
|
4815
4835
|
resume?: {
|
|
4816
4836
|
sessionId: string;
|
|
4817
4837
|
};
|
|
4838
|
+
/** S-TH2:思考生成(生成面;缺席 = 装配面缺省,两级皆缺席恒不注入) */
|
|
4839
|
+
thinking?: {
|
|
4840
|
+
budget?: number;
|
|
4841
|
+
};
|
|
4818
4842
|
}
|
|
4819
4843
|
interface AgentSessionCreateResult {
|
|
4820
4844
|
handle: AgentSessionHandle;
|
|
@@ -4916,6 +4940,14 @@ interface SessionInit {
|
|
|
4916
4940
|
maxUsd?: number;
|
|
4917
4941
|
maxTokens?: number;
|
|
4918
4942
|
};
|
|
4943
|
+
/**
|
|
4944
|
+
* S-TH2(2026-09-01):思考生成(生成面旋钮)——逐轮透传 IRRequest.thinking。
|
|
4945
|
+
* 优先级:本键(wire,per-会话)> 装配面缺省(工厂选项/profile effort)>
|
|
4946
|
+
* 恒不注入(现状)。
|
|
4947
|
+
*/
|
|
4948
|
+
thinking?: {
|
|
4949
|
+
budget?: number;
|
|
4950
|
+
};
|
|
4919
4951
|
}
|
|
4920
4952
|
/**
|
|
4921
4953
|
* 会话句柄——装配层对内核会话的最小操控面。
|
|
@@ -9522,8 +9554,9 @@ interface ServeSessionDriverOptions {
|
|
|
9522
9554
|
/** 缺省 8192 */
|
|
9523
9555
|
maxTokens?: number;
|
|
9524
9556
|
/**
|
|
9525
|
-
*
|
|
9526
|
-
*
|
|
9557
|
+
* 思考预算:逐轮透传 runQuery → IRRequest.thinking。取值三级(S-TH2
|
|
9558
|
+
* 用户拍板 2026-09-01):wire thinking 键(per-会话)> 装配面缺省(平台
|
|
9559
|
+
* 形工厂 options.thinking / cli 形 profile effort 档)> 缺席恒不注入。
|
|
9527
9560
|
*/
|
|
9528
9561
|
thinking?: {
|
|
9529
9562
|
budget?: number;
|
|
@@ -9830,6 +9863,13 @@ interface PlatformServeSessionFactoryOptions {
|
|
|
9830
9863
|
maxTokens?: number;
|
|
9831
9864
|
/** 单轮 modelTurns 上限(防失控;缺省不设) */
|
|
9832
9865
|
maxTurnsPerQuery?: number;
|
|
9866
|
+
/**
|
|
9867
|
+
* S-TH2(用户拍板 2026-09-01):装配面思考生成缺省(serve 旋钮)——
|
|
9868
|
+
* 会话未带 wire thinking 键时的兜底;wire 键恒胜。两级皆缺席恒不注入。
|
|
9869
|
+
*/
|
|
9870
|
+
thinking?: {
|
|
9871
|
+
budget?: number;
|
|
9872
|
+
};
|
|
9833
9873
|
/** runQuery 注入缝(测试脚本化;缺省 kernel runQuery) */
|
|
9834
9874
|
runQueryImpl?: typeof runQuery;
|
|
9835
9875
|
}
|
package/dist/index.js
CHANGED
|
@@ -37955,7 +37955,15 @@ var CreateSessionBodySchema = z11.object({
|
|
|
37955
37955
|
endUser: z11.object({ id: z11.string().regex(END_USER_ID_PATTERN) }).optional(),
|
|
37956
37956
|
resume: z11.object({ sessionId: z11.string().min(1) }).optional(),
|
|
37957
37957
|
clientTools: z11.array(ClientToolDeclSchema).max(V2_LIMITS.maxClientTools).optional(),
|
|
37958
|
-
capabilitiesProfile: z11.string().min(1).optional()
|
|
37958
|
+
capabilitiesProfile: z11.string().min(1).optional(),
|
|
37959
|
+
/**
|
|
37960
|
+
* S-TH2(用户拍板 2026-09-01,doc/98 冻结面加法):思考生成(生成面旋钮)
|
|
37961
|
+
* ——逐轮透传内核 IRRequest.thinking(budget = 思考 token 预算,按模型
|
|
37962
|
+
* 方言映射;平台令牌档经 TWP reasoning 档位出线,S-TH1)。缺席 = 装配面
|
|
37963
|
+
* 缺省(工厂 thinking 选项),两级皆缺席恒不注入(现状零漂移)。思考的
|
|
37964
|
+
* 呈现走客户端 SessionView delivery(呈现面),与本键正交。
|
|
37965
|
+
*/
|
|
37966
|
+
thinking: z11.object({ budget: z11.number().int().positive().optional() }).optional()
|
|
37959
37967
|
});
|
|
37960
37968
|
var MessageBlockSchema = z11.discriminatedUnion("t", [
|
|
37961
37969
|
z11.object({ t: z11.literal("text"), text: z11.string().min(1).max(V2_LIMITS.textBlockMaxChars) }),
|
|
@@ -38509,7 +38517,8 @@ function createAgentRoutesHandler(deps) {
|
|
|
38509
38517
|
...init.tools !== void 0 ? { tools: init.tools } : {},
|
|
38510
38518
|
...init.clientTools !== void 0 ? { clientTools: init.clientTools } : {},
|
|
38511
38519
|
...init.capabilitiesProfile !== void 0 ? { capabilitiesProfile: init.capabilitiesProfile } : {},
|
|
38512
|
-
...init.resume !== void 0 ? { resume: init.resume } : {}
|
|
38520
|
+
...init.resume !== void 0 ? { resume: init.resume } : {},
|
|
38521
|
+
...init.thinking !== void 0 ? { thinking: init.thinking } : {}
|
|
38513
38522
|
};
|
|
38514
38523
|
let handle;
|
|
38515
38524
|
let resumed;
|
|
@@ -60547,10 +60556,30 @@ function createAppTokenFetch(token, inner) {
|
|
|
60547
60556
|
};
|
|
60548
60557
|
return wrapped;
|
|
60549
60558
|
}
|
|
60559
|
+
async function fetchTwpFeatures(base, token, fetchImpl, sessionId) {
|
|
60560
|
+
try {
|
|
60561
|
+
const response = await fetchImpl(`${base}${TWP_ENDPOINT_PATHS.heartbeat}`, {
|
|
60562
|
+
method: "POST",
|
|
60563
|
+
headers: {
|
|
60564
|
+
"content-type": "application/json",
|
|
60565
|
+
accept: "application/json",
|
|
60566
|
+
[HEADER_APP_TOKEN]: token
|
|
60567
|
+
},
|
|
60568
|
+
body: JSON.stringify({ client: "sdk", ...sessionId !== void 0 ? { sessionId } : {} })
|
|
60569
|
+
});
|
|
60570
|
+
if (!response.ok) return void 0;
|
|
60571
|
+
const raw = await response.json();
|
|
60572
|
+
const features = raw?.features;
|
|
60573
|
+
return Array.isArray(features) ? features.filter((f) => typeof f === "string") : void 0;
|
|
60574
|
+
} catch {
|
|
60575
|
+
return void 0;
|
|
60576
|
+
}
|
|
60577
|
+
}
|
|
60550
60578
|
async function assemblePlatformModel(options) {
|
|
60551
60579
|
const base = options.baseUrl.replace(/\/+$/, "");
|
|
60552
60580
|
const innerFetch = options.fetchImpl ?? fetch;
|
|
60553
60581
|
const url = `${base}${TWP_ENDPOINT_PATHS.config}`;
|
|
60582
|
+
const featuresPromise = fetchTwpFeatures(base, options.token, innerFetch, options.sessionId?.());
|
|
60554
60583
|
let response;
|
|
60555
60584
|
try {
|
|
60556
60585
|
response = await innerFetch(url, {
|
|
@@ -60587,13 +60616,18 @@ async function assemblePlatformModel(options) {
|
|
|
60587
60616
|
`App config bundle from ${url} has an unexpected shape. Check that "baseUrl" points to the tansr API.`
|
|
60588
60617
|
);
|
|
60589
60618
|
}
|
|
60619
|
+
const features = await featuresPromise;
|
|
60590
60620
|
const registry = new ProviderRegistry(appBundleRegistryConfig(bundle, base), {
|
|
60591
60621
|
// 占位哑值:满足装配期 readApiKey 非空校验;真实鉴权恒由 fetch 包装注入
|
|
60592
60622
|
env: { [APP_TOKEN_PLACEHOLDER_ENV]: APP_TOKEN_PLACEHOLDER_VALUE },
|
|
60593
60623
|
fetchImpl: createAppTokenFetch(options.token, options.fetchImpl),
|
|
60594
60624
|
// 拍板⑤:平台会话 id 供给经既有 TwpClientOptions.sessionId 缝出线——
|
|
60595
|
-
// registry 为会话私有(每次装配新建),setModel/Task
|
|
60596
|
-
|
|
60625
|
+
// registry 为会话私有(每次装配新建),setModel/Task 子代理同缝同值。
|
|
60626
|
+
// S-TH3:features 能力串同缝供给(闭包定格;undefined = 门全关同现状)
|
|
60627
|
+
twp: {
|
|
60628
|
+
...options.sessionId !== void 0 ? { sessionId: options.sessionId } : {},
|
|
60629
|
+
features: () => features
|
|
60630
|
+
}
|
|
60597
60631
|
});
|
|
60598
60632
|
const built = buildClientFromRegistry(registry, options.model ?? "main", options.onProviderSelected);
|
|
60599
60633
|
return { ...built, registry, capabilities: bundle.capabilities, platformModels: bundle.platformModels };
|
|
@@ -61126,6 +61160,8 @@ function createPlatformServeSessionFactory(options) {
|
|
|
61126
61160
|
compaction: assembled.compaction ?? {},
|
|
61127
61161
|
...assembled.compactionManagerOptions !== void 0 ? { compactionManagerOptions: assembled.compactionManagerOptions } : {},
|
|
61128
61162
|
reminders: createReminderProvider({ todoStore }),
|
|
61163
|
+
// S-TH2:思考生成两级取值——wire 键(per-会话)恒胜装配面缺省
|
|
61164
|
+
...init.thinking !== void 0 ? { thinking: init.thinking } : options.thinking !== void 0 ? { thinking: options.thinking } : {},
|
|
61129
61165
|
...extras?.onTurnEnd !== void 0 ? { onTurnEnd: extras.onTurnEnd } : {},
|
|
61130
61166
|
...options.runQueryImpl !== void 0 ? { runQueryImpl: options.runQueryImpl } : {}
|
|
61131
61167
|
});
|
|
@@ -61327,7 +61363,8 @@ function createAgentSessionFactory(options) {
|
|
|
61327
61363
|
...init.profile !== void 0 ? { profile: init.profile } : {},
|
|
61328
61364
|
...init.labels !== void 0 ? { labels: init.labels } : {},
|
|
61329
61365
|
...init.budget !== void 0 ? { budget: init.budget } : {},
|
|
61330
|
-
...effectiveTools !== void 0 ? { tools: [...effectiveTools] } : {}
|
|
61366
|
+
...effectiveTools !== void 0 ? { tools: [...effectiveTools] } : {},
|
|
61367
|
+
...init.thinking !== void 0 ? { thinking: init.thinking } : {}
|
|
61331
61368
|
},
|
|
61332
61369
|
{
|
|
61333
61370
|
sessionId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tansr/serve",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|