@code-yeongyu/senpi-ai 2026.9.4 → 2026.9.5
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/api/anthropic-messages.d.ts +1 -1
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +130 -15
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/cursor-agent.js +4 -4
- package/dist/api/cursor-agent.js.map +1 -1
- package/dist/api/mistral-conversations.js +1 -1
- package/dist/api/mistral-conversations.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +3 -1
- package/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/api/openai-completions.d.ts.map +1 -1
- package/dist/api/openai-completions.js +30 -10
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/api/openai-responses-shared.d.ts +3 -3
- package/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/dist/api/openai-responses-shared.js.map +1 -1
- package/dist/api/openai-responses.d.ts +1 -1
- package/dist/api/openai-responses.d.ts.map +1 -1
- package/dist/api/openai-responses.js +8 -5
- package/dist/api/openai-responses.js.map +1 -1
- package/dist/api/pi-messages.d.ts +2 -0
- package/dist/api/pi-messages.d.ts.map +1 -1
- package/dist/api/pi-messages.js +6 -0
- package/dist/api/pi-messages.js.map +1 -1
- package/dist/api/warm-prompt-cache.js +1 -1
- package/dist/api/warm-prompt-cache.js.map +1 -1
- package/dist/image-models.generated.d.ts +30 -0
- package/dist/image-models.generated.d.ts.map +1 -1
- package/dist/image-models.generated.js +30 -0
- package/dist/image-models.generated.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +3 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +27 -3
- package/dist/models.js.map +1 -1
- package/dist/openai-responses-compat.d.ts +2 -0
- package/dist/openai-responses-compat.d.ts.map +1 -1
- package/dist/openai-responses-compat.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/anthropic.json +1 -1
- package/dist/providers/data/azure-openai-responses.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/openai-codex.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.d.ts.map +1 -1
- package/dist/providers/openrouter.js +8 -1
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/drop-failed-assistant-turns.d.ts +23 -0
- package/dist/utils/drop-failed-assistant-turns.d.ts.map +1 -0
- package/dist/utils/drop-failed-assistant-turns.js +58 -0
- package/dist/utils/drop-failed-assistant-turns.js.map +1 -0
- package/dist/utils/node-http-proxy.d.ts.map +1 -1
- package/dist/utils/node-http-proxy.js +53 -12
- package/dist/utils/node-http-proxy.js.map +1 -1
- package/dist/utils/prompt-cache-ttl.d.ts +4 -2
- package/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
- package/dist/utils/prompt-cache-ttl.js +3 -0
- package/dist/utils/prompt-cache-ttl.js.map +1 -1
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +3 -0
- package/dist/utils/retry.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
|
-
import { calculateCost, clampThinkingLevel, supportsMax, supportsXhigh } from "../models.js";
|
|
2
|
+
import { calculateCost, clampThinkingLevel, inferOpenAIThinkingLevelMap, supportsMax, supportsXhigh, } from "../models.js";
|
|
3
3
|
import { formatProviderError, normalizeProviderError } from "../utils/error-body.js";
|
|
4
4
|
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
5
5
|
import { shortHash } from "../utils/hash.js";
|
|
@@ -62,9 +62,9 @@ const OLLAMA_THINKING_LEVEL_MAP = {
|
|
|
62
62
|
max: "high",
|
|
63
63
|
};
|
|
64
64
|
function getThinkingLevelMap(model, compat) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const inferred = inferOpenAIThinkingLevelMap(model);
|
|
66
|
+
if (inferred !== undefined)
|
|
67
|
+
return inferred;
|
|
68
68
|
const id = model.id.toLowerCase();
|
|
69
69
|
const isKimiK3 = id === "k3" || id.startsWith("k3-") || /(?:^|[/:-])kimi-k3(?:$|[/.:_-])/.test(id);
|
|
70
70
|
const isDeepSeek = id.includes("deepseek");
|
|
@@ -262,6 +262,14 @@ export const stream = (model, context, options) => {
|
|
|
262
262
|
stopReason: "pending",
|
|
263
263
|
timestamp: Date.now(),
|
|
264
264
|
};
|
|
265
|
+
// `reasoning_details` are replay metadata, not user-visible stream deltas.
|
|
266
|
+
// Keep them in memory during streaming and serialize once when the block is finalized.
|
|
267
|
+
let streamedReasoningDetails;
|
|
268
|
+
const applyStreamedReasoningDetails = (block) => {
|
|
269
|
+
if (streamedReasoningDetails !== undefined) {
|
|
270
|
+
block.thinkingSignature = JSON.stringify(streamedReasoningDetails);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
265
273
|
try {
|
|
266
274
|
const clientAuth = resolveOpenAIClientAuth(model.provider, options?.apiKey, options?.headers);
|
|
267
275
|
const compat = getCompat(model);
|
|
@@ -341,6 +349,7 @@ export const stream = (model, context, options) => {
|
|
|
341
349
|
});
|
|
342
350
|
}
|
|
343
351
|
else if (block.type === "thinking") {
|
|
352
|
+
applyStreamedReasoningDetails(block);
|
|
344
353
|
stream.push({
|
|
345
354
|
type: "thinking_end",
|
|
346
355
|
contentIndex,
|
|
@@ -671,6 +680,9 @@ export const stream = (model, context, options) => {
|
|
|
671
680
|
}
|
|
672
681
|
catch (error) {
|
|
673
682
|
for (const block of output.content) {
|
|
683
|
+
if (block.type === "thinking") {
|
|
684
|
+
applyStreamedReasoningDetails(block);
|
|
685
|
+
}
|
|
674
686
|
delete block.index;
|
|
675
687
|
// Streaming scratch buffers are only used during parsing; never persist them.
|
|
676
688
|
delete block.partialArgs;
|
|
@@ -704,12 +716,17 @@ export const streamSimple = (model, context, options) => {
|
|
|
704
716
|
const compat = getCompat(model);
|
|
705
717
|
const thinkingLevelMap = getThinkingLevelMap(model, compat);
|
|
706
718
|
const thinkingModel = thinkingLevelMap === model.thinkingLevelMap ? model : { ...model, thinkingLevelMap };
|
|
707
|
-
const clampedReasoning = options?.reasoning
|
|
708
|
-
|
|
719
|
+
const clampedReasoning = options?.reasoning
|
|
720
|
+
? clampThinkingLevel(thinkingModel, options.reasoning)
|
|
721
|
+
: model.id.includes("gpt-6-astra")
|
|
722
|
+
? "off"
|
|
723
|
+
: undefined;
|
|
724
|
+
const normalizedReasoning = clampedReasoning === "off" && model.id.includes("gpt-6-astra") ? "low" : clampedReasoning;
|
|
725
|
+
const reasoningEffort = normalizedReasoning === "off"
|
|
709
726
|
? undefined
|
|
710
|
-
:
|
|
727
|
+
: normalizedReasoning === "max" && supportsMax(thinkingModel)
|
|
711
728
|
? "max"
|
|
712
|
-
: clampMaxForOpenAI(
|
|
729
|
+
: clampMaxForOpenAI(normalizedReasoning, supportsXhigh(thinkingModel));
|
|
713
730
|
return stream(model, context, {
|
|
714
731
|
...base,
|
|
715
732
|
reasoningEffort,
|
|
@@ -803,9 +820,12 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
|
|
|
803
820
|
if (cacheControl) {
|
|
804
821
|
applyAnthropicCacheControl(messages, params.tools, cacheControl);
|
|
805
822
|
}
|
|
806
|
-
if (options?.toolChoice
|
|
823
|
+
if (options?.toolChoice) {
|
|
807
824
|
params.tool_choice = options.toolChoice;
|
|
808
825
|
}
|
|
826
|
+
if (compat.vllmPriority !== undefined) {
|
|
827
|
+
params.priority = compat.vllmPriority;
|
|
828
|
+
}
|
|
809
829
|
const thinkingTokenBudgetField = resolveThinkingTokenBudgetField(compat);
|
|
810
830
|
const thinkingBudget = resolveClampedThinkingBudget(model, options, params);
|
|
811
831
|
if (compat.thinkingFormat === "zai" && model.reasoning) {
|
|
@@ -849,7 +869,7 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
|
|
|
849
869
|
}
|
|
850
870
|
if (compat.supportsReasoningEffort) {
|
|
851
871
|
const requestedEffort = options?.reasoningEffort;
|
|
852
|
-
const mappedEffort = requestedEffort ?
|
|
872
|
+
const mappedEffort = requestedEffort ? thinkingLevelMap?.[requestedEffort] : thinkingLevelMap?.off;
|
|
853
873
|
const effort = mappedEffort === undefined ? requestedEffort : mappedEffort;
|
|
854
874
|
if (typeof effort === "string") {
|
|
855
875
|
basetenParams.reasoning_effort = effort;
|