@gullabs/google 0.6.0 → 0.7.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/README.md +2 -1
- package/dist/index.cjs +20 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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
|
-
|
|
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
|
|
19
|
+
const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
|
|
12
20
|
return {
|
|
13
21
|
models: {
|
|
14
22
|
async generateContent(params) {
|
|
@@ -341,6 +349,12 @@ function geminiAdapter(opts) {
|
|
|
341
349
|
return {
|
|
342
350
|
id: "google",
|
|
343
351
|
async run(req, ctx) {
|
|
352
|
+
if (req.provider !== "google") {
|
|
353
|
+
throw new LlmError(
|
|
354
|
+
`geminiAdapter received a request for provider "${req.provider}", expected "google".`,
|
|
355
|
+
{ kind: "bad_request", retryable: false }
|
|
356
|
+
);
|
|
357
|
+
}
|
|
344
358
|
const warnings = [];
|
|
345
359
|
const model = req.model;
|
|
346
360
|
const mapPart = (p) => {
|
|
@@ -669,7 +683,7 @@ var DEFAULT_TIMEOUT_MS = 3e5;
|
|
|
669
683
|
var realSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
670
684
|
async function buildFilesClient(auth) {
|
|
671
685
|
const { GoogleGenAI } = await import('@google/genai');
|
|
672
|
-
const ai = new GoogleGenAI({ apiKey: auth
|
|
686
|
+
const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
|
|
673
687
|
return {
|
|
674
688
|
async upload(params) {
|
|
675
689
|
const fileArg = params.file instanceof Uint8Array ? new Blob(
|
|
@@ -856,7 +870,7 @@ var DEFAULT_SKEW_SECONDS = 30;
|
|
|
856
870
|
var DEFAULT_EXTENSION_SECONDS = 3600;
|
|
857
871
|
async function buildCachesClient(auth) {
|
|
858
872
|
const { GoogleGenAI } = await import('@google/genai');
|
|
859
|
-
const ai = new GoogleGenAI({ apiKey: auth
|
|
873
|
+
const ai = new GoogleGenAI({ apiKey: requireApiKey(auth) });
|
|
860
874
|
return {
|
|
861
875
|
async create(params) {
|
|
862
876
|
const result = await ai.caches.create(params);
|
|
@@ -1102,6 +1116,6 @@ function normalizeGroundingCitations(groundingMetadata) {
|
|
|
1102
1116
|
return citations;
|
|
1103
1117
|
}
|
|
1104
1118
|
|
|
1105
|
-
export { FLEX_DEFAULT_TIMEOUT_MS, GoogleCacheStore, GoogleFileStore, STANDARD_DEFAULT_TIMEOUT_MS, TRANSPORT_TIMEOUT_BUFFER_MS, buildGoogleClient, geminiAdapter, isGeminiCapacityError, normalizeGroundingCitations };
|
|
1119
|
+
export { FLEX_DEFAULT_TIMEOUT_MS, GoogleCacheStore, GoogleFileStore, STANDARD_DEFAULT_TIMEOUT_MS, TRANSPORT_TIMEOUT_BUFFER_MS, buildGoogleClient, geminiAdapter, isGeminiCapacityError, normalizeGroundingCitations, requireApiKey };
|
|
1106
1120
|
//# sourceMappingURL=index.js.map
|
|
1107
1121
|
//# sourceMappingURL=index.js.map
|