ak-gemini 2.1.5 → 2.3.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/base.js +52 -13
- package/code-agent.js +190 -40
- package/image-generator.js +186 -0
- package/index.cjs +368 -54
- package/index.js +3 -1
- package/package.json +3 -2
- package/types.d.ts +78 -3
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "ak-gemini",
|
|
3
3
|
"author": "ak@mixpanel.com",
|
|
4
4
|
"description": "AK's Generative AI Helper for doing... everything",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.3.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"index.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"code-agent.js",
|
|
16
16
|
"rag-agent.js",
|
|
17
17
|
"embedding.js",
|
|
18
|
+
"image-generator.js",
|
|
18
19
|
"json-helpers.js",
|
|
19
20
|
"types.d.ts",
|
|
20
21
|
"logger.js",
|
|
@@ -64,7 +65,7 @@
|
|
|
64
65
|
],
|
|
65
66
|
"license": "ISC",
|
|
66
67
|
"dependencies": {
|
|
67
|
-
"@google/genai": "^
|
|
68
|
+
"@google/genai": "^2.6.0",
|
|
68
69
|
"dotenv": "^17.3.1",
|
|
69
70
|
"pino": "^10.3.1",
|
|
70
71
|
"pino-pretty": "^13.1.3"
|
package/types.d.ts
CHANGED
|
@@ -68,12 +68,14 @@ export interface UsageData {
|
|
|
68
68
|
totalTokens: number;
|
|
69
69
|
/** Number of attempts (1 = first try success, 2+ = retries needed) */
|
|
70
70
|
attempts: number;
|
|
71
|
-
/** Actual model that responded (e.g., 'gemini-
|
|
71
|
+
/** Actual model that responded (e.g., 'gemini-3-flash-preview-001') */
|
|
72
72
|
modelVersion: string | null;
|
|
73
|
-
/** Model you requested (e.g., 'gemini-
|
|
73
|
+
/** Model you requested (e.g., 'gemini-3-flash-preview') */
|
|
74
74
|
requestedModel: string;
|
|
75
75
|
timestamp: number;
|
|
76
76
|
groundingMetadata?: GroundingMetadata | null;
|
|
77
|
+
/** Model lifecycle status from Google (e.g., 'DEPRECATED'). Surfaced from @google/genai 1.47+. */
|
|
78
|
+
modelStatus?: string | null;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
export interface TransformationExample {
|
|
@@ -130,11 +132,12 @@ export interface CachedContentInfo {
|
|
|
130
132
|
|
|
131
133
|
export type AsyncValidatorFunction = (payload: Record<string, unknown>) => Promise<unknown>;
|
|
132
134
|
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'none';
|
|
135
|
+
export type ServiceTier = 'STANDARD' | 'FLEX' | 'PRIORITY';
|
|
133
136
|
|
|
134
137
|
// ── Constructor Options ──────────────────────────────────────────────────────
|
|
135
138
|
|
|
136
139
|
export interface BaseGeminiOptions {
|
|
137
|
-
/** Gemini model to use (default: 'gemini-
|
|
140
|
+
/** Gemini model to use (default: 'gemini-3-flash-preview') */
|
|
138
141
|
modelName?: string;
|
|
139
142
|
/** System prompt for the model (null or false to disable) */
|
|
140
143
|
systemPrompt?: string | null | false;
|
|
@@ -177,6 +180,12 @@ export interface BaseGeminiOptions {
|
|
|
177
180
|
|
|
178
181
|
/** Run models.list() health check during init() (default: false) */
|
|
179
182
|
healthCheck?: boolean;
|
|
183
|
+
|
|
184
|
+
/** Service tier for generateContent (STANDARD | FLEX | PRIORITY). @google/genai 1.47+ */
|
|
185
|
+
serviceTier?: ServiceTier;
|
|
186
|
+
|
|
187
|
+
/** Surface server-side tool invocations (e.g. Google Search) in the response. @google/genai 1.46+ */
|
|
188
|
+
includeServerSideToolInvocations?: boolean;
|
|
180
189
|
}
|
|
181
190
|
|
|
182
191
|
export interface TransformerOptions extends BaseGeminiOptions {
|
|
@@ -254,6 +263,48 @@ export interface EmbeddingResult {
|
|
|
254
263
|
statistics?: { tokenCount?: number; truncated?: boolean };
|
|
255
264
|
}
|
|
256
265
|
|
|
266
|
+
// ── ImageGenerator ───────────────────────────────────────────────────────────
|
|
267
|
+
|
|
268
|
+
export type ImageAspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '9:16' | '16:9' | '21:9';
|
|
269
|
+
export type ImageSize = '1K' | '2K' | '4K';
|
|
270
|
+
export type PersonGeneration = 'ALLOW_ALL' | 'ALLOW_ADULT' | 'ALLOW_NONE';
|
|
271
|
+
|
|
272
|
+
export interface ImageGeneratorOptions extends BaseGeminiOptions {
|
|
273
|
+
/** Default aspect ratio for generated images */
|
|
274
|
+
aspectRatio?: ImageAspectRatio;
|
|
275
|
+
/** Default output resolution (1K/2K/4K) */
|
|
276
|
+
imageSize?: ImageSize;
|
|
277
|
+
/** Default people-generation policy */
|
|
278
|
+
personGeneration?: PersonGeneration;
|
|
279
|
+
/** Include text output alongside images (default: false) */
|
|
280
|
+
includeText?: boolean;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface ImageGenerateOptions {
|
|
284
|
+
aspectRatio?: ImageAspectRatio;
|
|
285
|
+
imageSize?: ImageSize;
|
|
286
|
+
personGeneration?: PersonGeneration;
|
|
287
|
+
includeText?: boolean;
|
|
288
|
+
/** Reference images for editing / multi-image composition (base64) */
|
|
289
|
+
inputImages?: Array<{ data: string; mimeType: string }>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface GeneratedImage {
|
|
293
|
+
/** Base64-encoded image data */
|
|
294
|
+
data: string;
|
|
295
|
+
/** MIME type (e.g. "image/png") */
|
|
296
|
+
mimeType: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface ImageGenerationResult {
|
|
300
|
+
/** One or more generated images */
|
|
301
|
+
images: GeneratedImage[];
|
|
302
|
+
/** Optional text response (only when includeText: true) */
|
|
303
|
+
text: string | null;
|
|
304
|
+
/** Token usage */
|
|
305
|
+
usage: UsageData | null;
|
|
306
|
+
}
|
|
307
|
+
|
|
257
308
|
/** Tool declaration in @google/genai FunctionDeclaration format */
|
|
258
309
|
export interface ToolDeclaration {
|
|
259
310
|
name: string;
|
|
@@ -302,6 +353,10 @@ export interface RagAgentOptions extends BaseGeminiOptions {
|
|
|
302
353
|
export interface CodeAgentOptions extends BaseGeminiOptions {
|
|
303
354
|
/** Working directory for code execution (default: process.cwd()) */
|
|
304
355
|
workingDirectory?: string;
|
|
356
|
+
/** Programming language for code execution: 'javascript' (default) or 'python' */
|
|
357
|
+
language?: 'javascript' | 'python';
|
|
358
|
+
/** Path to the Python binary (only used when language is 'python'; default: auto-detect python3/python) */
|
|
359
|
+
pythonPath?: string;
|
|
305
360
|
/** Max code execution loop iterations (default: 10) */
|
|
306
361
|
maxRounds?: number;
|
|
307
362
|
/** Per-execution timeout in milliseconds (default: 30000) */
|
|
@@ -527,6 +582,8 @@ export declare class BaseGemini {
|
|
|
527
582
|
enableGrounding: boolean;
|
|
528
583
|
groundingConfig: Record<string, any>;
|
|
529
584
|
cachedContent: string | null;
|
|
585
|
+
serviceTier: ServiceTier | null;
|
|
586
|
+
includeServerSideToolInvocations: boolean;
|
|
530
587
|
|
|
531
588
|
init(force?: boolean): Promise<void>;
|
|
532
589
|
seed(examples?: TransformationExample[], opts?: SeedOptions): Promise<any[]>;
|
|
@@ -633,6 +690,8 @@ export declare class CodeAgent extends BaseGemini {
|
|
|
633
690
|
constructor(options?: CodeAgentOptions);
|
|
634
691
|
|
|
635
692
|
workingDirectory: string;
|
|
693
|
+
language: 'javascript' | 'python';
|
|
694
|
+
pythonPath: string | null;
|
|
636
695
|
maxRounds: number;
|
|
637
696
|
timeout: number;
|
|
638
697
|
onBeforeExecution: ((content: string, toolName: string) => Promise<boolean> | boolean) | null;
|
|
@@ -671,6 +730,21 @@ export declare class Embedding extends BaseGemini {
|
|
|
671
730
|
similarity(a: number[], b: number[]): number;
|
|
672
731
|
}
|
|
673
732
|
|
|
733
|
+
export declare class ImageGenerator extends BaseGemini {
|
|
734
|
+
constructor(options?: ImageGeneratorOptions);
|
|
735
|
+
|
|
736
|
+
aspectRatio: ImageAspectRatio | null;
|
|
737
|
+
imageSize: ImageSize | null;
|
|
738
|
+
personGeneration: PersonGeneration | null;
|
|
739
|
+
includeText: boolean;
|
|
740
|
+
|
|
741
|
+
init(force?: boolean): Promise<void>;
|
|
742
|
+
/** Generate one or more images from a text prompt. Supports optional reference images for editing. */
|
|
743
|
+
generate(prompt: string, opts?: ImageGenerateOptions): Promise<ImageGenerationResult>;
|
|
744
|
+
/** Write generated images to disk (suffixes `_N` before extension if >1 image) */
|
|
745
|
+
save(result: ImageGenerationResult, filePath: string): string[];
|
|
746
|
+
}
|
|
747
|
+
|
|
674
748
|
// ── Module Exports ───────────────────────────────────────────────────────────
|
|
675
749
|
|
|
676
750
|
export declare function extractJSON(text: string): any;
|
|
@@ -684,6 +758,7 @@ declare const _default: {
|
|
|
684
758
|
CodeAgent: typeof CodeAgent;
|
|
685
759
|
RagAgent: typeof RagAgent;
|
|
686
760
|
Embedding: typeof Embedding;
|
|
761
|
+
ImageGenerator: typeof ImageGenerator;
|
|
687
762
|
};
|
|
688
763
|
|
|
689
764
|
export default _default;
|