@prestyj/ai 4.14.0 → 5.0.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.cjs +24 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1149,7 +1149,13 @@ async function prewarmAnthropicCache(options) {
|
|
|
1149
1149
|
},
|
|
1150
1150
|
{
|
|
1151
1151
|
signal: options.signal ?? void 0,
|
|
1152
|
-
...
|
|
1152
|
+
...(() => {
|
|
1153
|
+
const betas = [
|
|
1154
|
+
...isOAuth ? ["claude-code-20250219", "oauth-2025-04-20"] : [],
|
|
1155
|
+
...cacheControl?.ttl === "1h" ? ["extended-cache-ttl-2025-04-11"] : []
|
|
1156
|
+
];
|
|
1157
|
+
return betas.length ? { headers: { "anthropic-beta": betas.join(",") } } : {};
|
|
1158
|
+
})()
|
|
1153
1159
|
}
|
|
1154
1160
|
);
|
|
1155
1161
|
} catch {
|
|
@@ -1233,7 +1239,12 @@ async function* runStream(options) {
|
|
|
1233
1239
|
...options.compaction ? ["compact-2026-01-12"] : [],
|
|
1234
1240
|
...options.clearToolUses ? ["context-management-2025-06-27"] : [],
|
|
1235
1241
|
"fine-grained-tool-streaming-2025-05-14",
|
|
1236
|
-
...!hasAdaptiveThinking ? ["interleaved-thinking-2025-05-14"] : []
|
|
1242
|
+
...!hasAdaptiveThinking ? ["interleaved-thinking-2025-05-14"] : [],
|
|
1243
|
+
// The 1-h cache TTL (cacheRetention "long") is gated behind this beta. Without
|
|
1244
|
+
// it Anthropic silently ignores ttl:"1h" and falls back to the 5-min default,
|
|
1245
|
+
// so a pre-warmed cache expires before the user's first turn. cacheControl.ttl
|
|
1246
|
+
// is only "1h" on the first-party endpoint (see toAnthropicCacheControl).
|
|
1247
|
+
...cacheControl?.ttl === "1h" ? ["extended-cache-ttl-2025-04-11"] : []
|
|
1237
1248
|
];
|
|
1238
1249
|
const requestOptions = {
|
|
1239
1250
|
signal: options.signal ?? void 0,
|
|
@@ -3147,11 +3158,17 @@ providerRegistry.register("anthropic", {
|
|
|
3147
3158
|
stream: (options) => streamAnthropic(options)
|
|
3148
3159
|
});
|
|
3149
3160
|
providerRegistry.register("xiaomi", {
|
|
3150
|
-
stream: (options) =>
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3161
|
+
stream: (options) => {
|
|
3162
|
+
const TOKEN_PLAN_URL = "https://token-plan-sgp.xiaomimimo.com/v1";
|
|
3163
|
+
const PLATFORM_URL = "https://api.xiaomimimo.com/v1";
|
|
3164
|
+
let baseUrl;
|
|
3165
|
+
if (options.model === "mimo-v2.5-pro-ultraspeed") {
|
|
3166
|
+
baseUrl = options.baseUrl && options.baseUrl !== TOKEN_PLAN_URL ? options.baseUrl : PLATFORM_URL;
|
|
3167
|
+
} else {
|
|
3168
|
+
baseUrl = options.baseUrl ?? TOKEN_PLAN_URL;
|
|
3169
|
+
}
|
|
3170
|
+
return streamOpenAI({ ...options, baseUrl, webSearch: false });
|
|
3171
|
+
}
|
|
3155
3172
|
});
|
|
3156
3173
|
providerRegistry.register("openai", {
|
|
3157
3174
|
stream: (options) => {
|