@gullabs/google 0.6.0 → 0.6.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 CHANGED
@@ -3,14 +3,22 @@
3
3
  var core = require('@gullabs/core');
4
4
 
5
5
  // src/adapter.ts
6
-
7
- // src/client.ts
6
+ function requireApiKey(auth) {
7
+ if (!("apiKey" in auth) || typeof auth.apiKey !== "string" || auth.apiKey.trim() === "") {
8
+ throw new core.LlmError("@gullabs/google requires auth.apiKey", {
9
+ kind: "invalid_auth",
10
+ retryable: false,
11
+ provider: "google"
12
+ });
13
+ }
14
+ return auth.apiKey;
15
+ }
8
16
  var FLEX_DEFAULT_TIMEOUT_MS = 15e5;
9
17
  var STANDARD_DEFAULT_TIMEOUT_MS = 3e5;
10
18
  var TRANSPORT_TIMEOUT_BUFFER_MS = 5e3;
11
19
  async function buildGoogleClient(auth) {
12
20
  const { GoogleGenAI } = await import('@google/genai');
13
- const ai = new GoogleGenAI({ apiKey: auth.apiKey });
21
+ const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
14
22
  return {
15
23
  models: {
16
24
  async generateContent(params) {
@@ -671,7 +679,7 @@ var DEFAULT_TIMEOUT_MS = 3e5;
671
679
  var realSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
672
680
  async function buildFilesClient(auth) {
673
681
  const { GoogleGenAI } = await import('@google/genai');
674
- const ai = new GoogleGenAI({ apiKey: auth.apiKey });
682
+ const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
675
683
  return {
676
684
  async upload(params) {
677
685
  const fileArg = params.file instanceof Uint8Array ? new Blob(
@@ -858,7 +866,7 @@ var DEFAULT_SKEW_SECONDS = 30;
858
866
  var DEFAULT_EXTENSION_SECONDS = 3600;
859
867
  async function buildCachesClient(auth) {
860
868
  const { GoogleGenAI } = await import('@google/genai');
861
- const ai = new GoogleGenAI({ apiKey: auth.apiKey });
869
+ const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
862
870
  return {
863
871
  async create(params) {
864
872
  const result = await ai.caches.create(params);
@@ -1113,5 +1121,6 @@ exports.buildGoogleClient = buildGoogleClient;
1113
1121
  exports.geminiAdapter = geminiAdapter;
1114
1122
  exports.isGeminiCapacityError = isGeminiCapacityError;
1115
1123
  exports.normalizeGroundingCitations = normalizeGroundingCitations;
1124
+ exports.requireApiKey = requireApiKey;
1116
1125
  //# sourceMappingURL=index.cjs.map
1117
1126
  //# sourceMappingURL=index.cjs.map