@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.d.ts CHANGED
@@ -10,6 +10,15 @@ import { AuthMaterial, ProviderAdapter, LlmError, Logger } from '@gullabs/core';
10
10
  * @module
11
11
  */
12
12
 
13
+ /**
14
+ * Narrows {@link AuthMaterial} to its `apiKey` string, rejecting the
15
+ * dev-only `CliSessionAuth` variant.
16
+ *
17
+ * Google is a production API provider and only ever accepts API-key
18
+ * credentials; `{ cliSession: true }` is reserved for the dev-only CLI
19
+ * provider packages (`@gullabs/claude-cli`, `@gullabs/codex-cli`).
20
+ */
21
+ declare function requireApiKey(auth: AuthMaterial): string;
13
22
  /**
14
23
  * Default HTTP transport timeout for Gemini Flex service-tier calls (ms).
15
24
  *
@@ -603,4 +612,4 @@ interface Citation {
603
612
  */
604
613
  declare function normalizeGroundingCitations(groundingMetadata: unknown): Citation[];
605
614
 
606
- export { type CacheKey, type Citation, FLEX_DEFAULT_TIMEOUT_MS, type GeminiAdapterOptions, type GeminiCachesClientLike, type GeminiClientLike, type GeminiFilesClientLike, type GoogleCacheHandle, GoogleCacheStore, type GoogleCacheStoreOptions, type GoogleFileHandle, GoogleFileStore, type GoogleFileStoreOptions, STANDARD_DEFAULT_TIMEOUT_MS, TRANSPORT_TIMEOUT_BUFFER_MS, buildGoogleClient, geminiAdapter, isGeminiCapacityError, normalizeGroundingCitations };
615
+ export { type CacheKey, type Citation, FLEX_DEFAULT_TIMEOUT_MS, type GeminiAdapterOptions, type GeminiCachesClientLike, type GeminiClientLike, type GeminiFilesClientLike, type GoogleCacheHandle, GoogleCacheStore, type GoogleCacheStoreOptions, type GoogleFileHandle, GoogleFileStore, type GoogleFileStoreOptions, STANDARD_DEFAULT_TIMEOUT_MS, TRANSPORT_TIMEOUT_BUFFER_MS, buildGoogleClient, geminiAdapter, isGeminiCapacityError, normalizeGroundingCitations, requireApiKey };
package/dist/index.js CHANGED
@@ -1,14 +1,22 @@
1
1
  import { LlmError, assertNever, classifyError, redactSecrets } from '@gullabs/core';
2
2
 
3
3
  // src/adapter.ts
4
-
5
- // src/client.ts
4
+ function requireApiKey(auth) {
5
+ if (!("apiKey" in auth) || typeof auth.apiKey !== "string" || auth.apiKey.trim() === "") {
6
+ throw new LlmError("@gullabs/google requires auth.apiKey", {
7
+ kind: "invalid_auth",
8
+ retryable: false,
9
+ provider: "google"
10
+ });
11
+ }
12
+ return auth.apiKey;
13
+ }
6
14
  var FLEX_DEFAULT_TIMEOUT_MS = 15e5;
7
15
  var STANDARD_DEFAULT_TIMEOUT_MS = 3e5;
8
16
  var TRANSPORT_TIMEOUT_BUFFER_MS = 5e3;
9
17
  async function buildGoogleClient(auth) {
10
18
  const { GoogleGenAI } = await import('@google/genai');
11
- const ai = new GoogleGenAI({ apiKey: auth.apiKey });
19
+ const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
12
20
  return {
13
21
  models: {
14
22
  async generateContent(params) {
@@ -669,7 +677,7 @@ var DEFAULT_TIMEOUT_MS = 3e5;
669
677
  var realSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
670
678
  async function buildFilesClient(auth) {
671
679
  const { GoogleGenAI } = await import('@google/genai');
672
- const ai = new GoogleGenAI({ apiKey: auth.apiKey });
680
+ const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
673
681
  return {
674
682
  async upload(params) {
675
683
  const fileArg = params.file instanceof Uint8Array ? new Blob(
@@ -856,7 +864,7 @@ var DEFAULT_SKEW_SECONDS = 30;
856
864
  var DEFAULT_EXTENSION_SECONDS = 3600;
857
865
  async function buildCachesClient(auth) {
858
866
  const { GoogleGenAI } = await import('@google/genai');
859
- const ai = new GoogleGenAI({ apiKey: auth.apiKey });
867
+ const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
860
868
  return {
861
869
  async create(params) {
862
870
  const result = await ai.caches.create(params);
@@ -1102,6 +1110,6 @@ function normalizeGroundingCitations(groundingMetadata) {
1102
1110
  return citations;
1103
1111
  }
1104
1112
 
1105
- export { FLEX_DEFAULT_TIMEOUT_MS, GoogleCacheStore, GoogleFileStore, STANDARD_DEFAULT_TIMEOUT_MS, TRANSPORT_TIMEOUT_BUFFER_MS, buildGoogleClient, geminiAdapter, isGeminiCapacityError, normalizeGroundingCitations };
1113
+ export { FLEX_DEFAULT_TIMEOUT_MS, GoogleCacheStore, GoogleFileStore, STANDARD_DEFAULT_TIMEOUT_MS, TRANSPORT_TIMEOUT_BUFFER_MS, buildGoogleClient, geminiAdapter, isGeminiCapacityError, normalizeGroundingCitations, requireApiKey };
1106
1114
  //# sourceMappingURL=index.js.map
1107
1115
  //# sourceMappingURL=index.js.map