@prestyj/ai 4.13.3 → 5.0.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.d.cts CHANGED
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
3
  import OpenAI from 'openai';
4
4
 
5
- type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "palsu";
5
+ type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "sakana" | "palsu";
6
6
  type ThinkingLevel = "low" | "medium" | "high" | "xhigh" | "max";
7
7
  type CacheRetention = "none" | "short" | "long";
8
8
  interface TextContent {
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
3
  import OpenAI from 'openai';
4
4
 
5
- type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "palsu";
5
+ type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "sakana" | "palsu";
6
6
  type ThinkingLevel = "low" | "medium" | "high" | "xhigh" | "max";
7
7
  type CacheRetention = "none" | "short" | "long";
8
8
  interface TextContent {
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ var PROVIDER_DISPLAY = {
57
57
  moonshot: "Moonshot",
58
58
  deepseek: "DeepSeek",
59
59
  openrouter: "OpenRouter",
60
+ sakana: "Sakana",
60
61
  xiaomi: "Xiaomi (MiMo)",
61
62
  minimax: "MiniMax"
62
63
  };
@@ -965,8 +966,12 @@ function toOpenAIToolChoice(choice) {
965
966
  if (choice === "required") return "required";
966
967
  return { type: "function", function: { name: choice.name } };
967
968
  }
968
- function toOpenAIReasoningEffort(level, _model) {
969
- return level === "max" ? "xhigh" : level;
969
+ function toOpenAIReasoningEffort(level, model) {
970
+ const effort = level === "max" ? "xhigh" : level;
971
+ if (model.startsWith("fugu") && (effort === "low" || effort === "medium")) {
972
+ return "high";
973
+ }
974
+ return effort;
970
975
  }
971
976
  function normalizeAnthropicStopReason(reason) {
972
977
  switch (reason) {
@@ -1089,7 +1094,13 @@ async function prewarmAnthropicCache(options) {
1089
1094
  },
1090
1095
  {
1091
1096
  signal: options.signal ?? void 0,
1092
- ...isOAuth ? { headers: { "anthropic-beta": "claude-code-20250219,oauth-2025-04-20" } } : {}
1097
+ ...(() => {
1098
+ const betas = [
1099
+ ...isOAuth ? ["claude-code-20250219", "oauth-2025-04-20"] : [],
1100
+ ...cacheControl?.ttl === "1h" ? ["extended-cache-ttl-2025-04-11"] : []
1101
+ ];
1102
+ return betas.length ? { headers: { "anthropic-beta": betas.join(",") } } : {};
1103
+ })()
1093
1104
  }
1094
1105
  );
1095
1106
  } catch {
@@ -1173,7 +1184,12 @@ async function* runStream(options) {
1173
1184
  ...options.compaction ? ["compact-2026-01-12"] : [],
1174
1185
  ...options.clearToolUses ? ["context-management-2025-06-27"] : [],
1175
1186
  "fine-grained-tool-streaming-2025-05-14",
1176
- ...!hasAdaptiveThinking ? ["interleaved-thinking-2025-05-14"] : []
1187
+ ...!hasAdaptiveThinking ? ["interleaved-thinking-2025-05-14"] : [],
1188
+ // The 1-h cache TTL (cacheRetention "long") is gated behind this beta. Without
1189
+ // it Anthropic silently ignores ttl:"1h" and falls back to the 5-min default,
1190
+ // so a pre-warmed cache expires before the user's first turn. cacheControl.ttl
1191
+ // is only "1h" on the first-party endpoint (see toAnthropicCacheControl).
1192
+ ...cacheControl?.ttl === "1h" ? ["extended-cache-ttl-2025-04-11"] : []
1177
1193
  ];
1178
1194
  const requestOptions = {
1179
1195
  signal: options.signal ?? void 0,
@@ -3129,6 +3145,16 @@ providerRegistry.register("openrouter", {
3129
3145
  baseUrl: options.baseUrl ?? "https://openrouter.ai/api/v1"
3130
3146
  })
3131
3147
  });
3148
+ providerRegistry.register("sakana", {
3149
+ // Sakana Fugu is a multi-agent system exposed as a standard LLM through the
3150
+ // OpenAI-compatible Sakana API. We ride the Chat Completions transport (the
3151
+ // Responses API is also offered). Fugu models only accept "high"/"xhigh"
3152
+ // reasoning effort — clamped centrally in toOpenAIReasoningEffort.
3153
+ stream: (options) => streamOpenAI({
3154
+ ...options,
3155
+ baseUrl: options.baseUrl ?? "https://api.sakana.ai/v1"
3156
+ })
3157
+ });
3132
3158
  providerRegistry.register("minimax", {
3133
3159
  stream: (options) => streamAnthropic({
3134
3160
  ...options,