@kenkaiiii/gg-ai 5.67.1 → 5.68.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/dist/index.cjs +12 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -245,6 +245,14 @@ interface StreamOptions {
|
|
|
245
245
|
* stalls — broken SSE connections (transient CDN / proxy issues) often
|
|
246
246
|
* recover when the same request is issued over a plain HTTP request/response. */
|
|
247
247
|
streaming?: boolean;
|
|
248
|
+
/** Cache prewarm (Anthropic only; other providers ignore it). Sends the exact
|
|
249
|
+
* same request prefix (system, tools, messages, thinking, betas) with
|
|
250
|
+
* `max_tokens: 1` over a non-streaming request so the prompt cache is written
|
|
251
|
+
* before the user's next real turn. If the configured thinking mode cannot be
|
|
252
|
+
* kept identical at `max_tokens: 1` (budget thinking requires
|
|
253
|
+
* budget_tokens < max_tokens), no request is sent and the response has
|
|
254
|
+
* zero usage with stopReason "end_turn". */
|
|
255
|
+
prewarm?: boolean;
|
|
248
256
|
/** Override the User-Agent sent with OAuth-authenticated Anthropic requests.
|
|
249
257
|
* Anthropic's OAuth edge rejects requests whose claude-cli version lags too
|
|
250
258
|
* far behind the real Claude Code release; callers that track the live
|
package/dist/index.d.ts
CHANGED
|
@@ -245,6 +245,14 @@ interface StreamOptions {
|
|
|
245
245
|
* stalls — broken SSE connections (transient CDN / proxy issues) often
|
|
246
246
|
* recover when the same request is issued over a plain HTTP request/response. */
|
|
247
247
|
streaming?: boolean;
|
|
248
|
+
/** Cache prewarm (Anthropic only; other providers ignore it). Sends the exact
|
|
249
|
+
* same request prefix (system, tools, messages, thinking, betas) with
|
|
250
|
+
* `max_tokens: 1` over a non-streaming request so the prompt cache is written
|
|
251
|
+
* before the user's next real turn. If the configured thinking mode cannot be
|
|
252
|
+
* kept identical at `max_tokens: 1` (budget thinking requires
|
|
253
|
+
* budget_tokens < max_tokens), no request is sent and the response has
|
|
254
|
+
* zero usage with stopReason "end_turn". */
|
|
255
|
+
prewarm?: boolean;
|
|
248
256
|
/** Override the User-Agent sent with OAuth-authenticated Anthropic requests.
|
|
249
257
|
* Anthropic's OAuth edge rejects requests whose claude-cli version lags too
|
|
250
258
|
* far behind the real Claude Code release; callers that track the live
|
package/dist/index.js
CHANGED
|
@@ -1376,7 +1376,7 @@ function streamAnthropic(options) {
|
|
|
1376
1376
|
async function* runStream(options) {
|
|
1377
1377
|
const client = createClient(options);
|
|
1378
1378
|
const isOAuth = options.apiKey?.startsWith("sk-ant-oat");
|
|
1379
|
-
const useStreaming = options.streaming !== false;
|
|
1379
|
+
const useStreaming = options.streaming !== false && !options.prewarm;
|
|
1380
1380
|
const cacheControl = toAnthropicCacheControl(options.cacheRetention, options.baseUrl);
|
|
1381
1381
|
const supportsFirstPartyToolExtras = !options.baseUrl || options.baseUrl.includes("api.anthropic.com");
|
|
1382
1382
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
@@ -1400,6 +1400,17 @@ async function* runStream(options) {
|
|
|
1400
1400
|
outputConfig = t.outputConfig;
|
|
1401
1401
|
}
|
|
1402
1402
|
}
|
|
1403
|
+
if (options.prewarm) {
|
|
1404
|
+
const budget = thinking?.budget_tokens;
|
|
1405
|
+
if (budget != null && budget >= 1) {
|
|
1406
|
+
return {
|
|
1407
|
+
message: { role: "assistant", content: [] },
|
|
1408
|
+
stopReason: "end_turn",
|
|
1409
|
+
usage: { inputTokens: 0, outputTokens: 0 }
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
maxTokens = 1;
|
|
1413
|
+
}
|
|
1403
1414
|
const params = {
|
|
1404
1415
|
model: options.model,
|
|
1405
1416
|
max_tokens: maxTokens,
|