@codehz/ai 0.8.2 → 0.9.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/README.md +8 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,7 +97,11 @@ type AIRequest = {
|
|
|
97
97
|
temperature?: number; // provider/model-defined generation parameter
|
|
98
98
|
maxOutputTokens?: number; // 最大输出 token
|
|
99
99
|
reasoningLevel?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"; // 可移植思考力度
|
|
100
|
-
include?: {
|
|
100
|
+
include?: {
|
|
101
|
+
usage?: "off" | "best_effort" | "required";
|
|
102
|
+
billing?: "off" | "best_effort" | "required";
|
|
103
|
+
providerMetadata?: "off" | "best_effort";
|
|
104
|
+
};
|
|
101
105
|
};
|
|
102
106
|
```
|
|
103
107
|
|
|
@@ -530,7 +534,9 @@ const r2 = await collectStream(client.stream({ input, tools }));
|
|
|
530
534
|
|
|
531
535
|
## 辅助信息采集
|
|
532
536
|
|
|
533
|
-
usage / billing / providerMetadata 由 adapter 在流结束时经 `response.auxiliary` 与 `AIResponse` 字段交付。`AuxiliaryCollector` 是 provider 内部实现细节,`0.5.0` 起不再从根入口导出。`lookup` / `postprocessBilling` 为 experimental 扩展点,库内 HTTP adapter 默认未接线。
|
|
537
|
+
`usage` / `billing` / `providerMetadata` 由 adapter 在流结束时经 `response.auxiliary` 与 `AIResponse` 字段交付。`AuxiliaryCollector` 是 provider 内部实现细节,`0.5.0` 起不再从根入口导出。`lookup` / `postprocessBilling` 为 experimental 扩展点,库内 HTTP adapter 默认未接线。
|
|
538
|
+
|
|
539
|
+
`usage` 与 `billing` 的 `include` 支持三种模式:`off` 表示不采集;`best_effort`(默认)表示尽可能采集,缺失时静默;`required` 表示缺失时发出 `USAGE_MISSING` 或 `BILLING_MISSING` warning。估算 billing 仍会发出 `BILLING_ESTIMATED` warning。
|
|
534
540
|
|
|
535
541
|
## 开发命令
|
|
536
542
|
|
package/dist/index.d.mts
CHANGED
|
@@ -207,8 +207,8 @@ type McpServerTool = {
|
|
|
207
207
|
/** Provider 托管执行的工具声明(不进客户端 tool loop) */
|
|
208
208
|
type ServerToolDefinition = WebSearchServerTool | CodeExecutionServerTool | McpServerTool;
|
|
209
209
|
type IncludeSettings = {
|
|
210
|
-
usage?: "off" | "best_effort";
|
|
211
|
-
billing?: "off" | "best_effort";
|
|
210
|
+
usage?: "off" | "best_effort" | "required";
|
|
211
|
+
billing?: "off" | "best_effort" | "required";
|
|
212
212
|
providerMetadata?: "off" | "best_effort";
|
|
213
213
|
};
|
|
214
214
|
/** Portable reasoning / thinking effort. Mapped per-adapter to provider wire fields. */
|
package/dist/index.mjs
CHANGED
|
@@ -1091,11 +1091,11 @@ var AdapterAuxiliaryState = class {
|
|
|
1091
1091
|
billing: built.billing,
|
|
1092
1092
|
auxiliary: built.auxiliary
|
|
1093
1093
|
}));
|
|
1094
|
-
if (this.request.include?.usage
|
|
1095
|
-
if (this.request.include?.billing
|
|
1094
|
+
if (this.request.include?.usage === "required" && !built.usage) events.push(factory.responseWarning("Usage information was not provided by the provider", WarningCode.USAGE_MISSING));
|
|
1095
|
+
if (this.request.include?.billing === "required") {
|
|
1096
1096
|
if (!built.billing) events.push(factory.responseWarning("Billing information was not provided by the provider", WarningCode.BILLING_MISSING));
|
|
1097
1097
|
else if (built.billing.isEstimated) events.push(factory.responseWarning("Billing amount is an estimate", WarningCode.BILLING_ESTIMATED));
|
|
1098
|
-
}
|
|
1098
|
+
} else if (built.billing?.isEstimated) events.push(factory.responseWarning("Billing amount is an estimate", WarningCode.BILLING_ESTIMATED));
|
|
1099
1099
|
return {
|
|
1100
1100
|
events,
|
|
1101
1101
|
usage: built.usage,
|