@jaypie/llm 1.3.17 → 1.3.19

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.
@@ -794,21 +794,27 @@ function buildExchangeEnvelope({ duration, initialHistoryLength, input, options,
794
794
  }
795
795
 
796
796
  const CACHE_TTL_DEFAULT = "5m";
797
+ /**
798
+ * Anthropic bills a 1h cache write at 2x input (vs 1.25x for 5m) but reads at
799
+ * the same ~0.1x, so an hour of reuse pays for itself after ~three reads and
800
+ * survives the gaps between turns in a long agentic session.
801
+ */
802
+ const CACHE_TTL_ANTHROPIC_DEFAULT = "1h";
797
803
  /**
798
804
  * Normalize the caller-facing `cache` option into a concrete decision.
799
- * - `undefined` / `true` → enabled at the default TTL
805
+ * - `undefined` / `true` → enabled at `defaultTtl`
800
806
  * - `false` / `0` → disabled
801
807
  * - `"5m"` / `"1h"` → enabled at that TTL
802
808
  */
803
- function resolveCache(cache) {
809
+ function resolveCache(cache, { defaultTtl = CACHE_TTL_DEFAULT } = {}) {
804
810
  if (cache === false || cache === 0) {
805
- return { enabled: false, ttl: CACHE_TTL_DEFAULT };
811
+ return { enabled: false, ttl: defaultTtl };
806
812
  }
807
813
  if (cache === "5m" || cache === "1h") {
808
814
  return { enabled: true, ttl: cache };
809
815
  }
810
816
  // undefined or true
811
- return { enabled: true, ttl: CACHE_TTL_DEFAULT };
817
+ return { enabled: true, ttl: defaultTtl };
812
818
  }
813
819
  /**
814
820
  * Deterministic short key for providers with automatic, prefix-based caching
@@ -2620,7 +2626,9 @@ class AnthropicAdapter extends BaseProviderAdapter {
2620
2626
  PROVIDER.ANTHROPIC.MAX_TOKENS.DEFAULT,
2621
2627
  stream: false,
2622
2628
  };
2623
- const cache = resolveCache(request.cache);
2629
+ const cache = resolveCache(request.cache, {
2630
+ defaultTtl: CACHE_TTL_ANTHROPIC_DEFAULT,
2631
+ });
2624
2632
  const cacheControl = cache.enabled
2625
2633
  ? {
2626
2634
  type: "ephemeral",
@@ -10648,7 +10656,14 @@ const getLogger$3 = () => log$1.log.lib({ lib: kit.JAYPIE.LIB.LLM });
10648
10656
  // Client initialization
10649
10657
  async function initializeClient$3({ apiKey, } = {}) {
10650
10658
  const logger = getLogger$3();
10651
- const resolvedApiKey = apiKey || (await aws.getEnvSecret("GEMINI_API_KEY"));
10659
+ let resolvedApiKey = apiKey || (await aws.getEnvSecret("GOOGLE_API_KEY"));
10660
+ if (!resolvedApiKey) {
10661
+ const geminiApiKey = await aws.getEnvSecret("GEMINI_API_KEY");
10662
+ if (geminiApiKey) {
10663
+ logger.warn("GEMINI_API_KEY is a deprecated fallback; set GOOGLE_API_KEY instead");
10664
+ resolvedApiKey = geminiApiKey;
10665
+ }
10666
+ }
10652
10667
  if (!resolvedApiKey) {
10653
10668
  throw new errors.ConfigurationError("The application could not resolve the requested keys");
10654
10669
  }