clefbase 1.5.3 → 2.0.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/dist/ai.d.ts ADDED
@@ -0,0 +1,369 @@
1
+ import { HttpClient } from "./http";
2
+ export type AIProvider = "anthropic" | "google";
3
+ export type AIModelCategory = "text" | "code" | "image" | "video" | "embedding";
4
+ /**
5
+ * A model available in the project's AI service.
6
+ */
7
+ export interface AIModel {
8
+ id: string;
9
+ name: string;
10
+ provider: AIProvider;
11
+ category: AIModelCategory;
12
+ description: string;
13
+ maxTokens?: number;
14
+ supportsStreaming?: boolean;
15
+ supportsSystemPrompt?: boolean;
16
+ }
17
+ export interface GenerateTextOptions {
18
+ /** Model ID, e.g. `"claude-sonnet-4-5"` or `"gemini-2.5-flash"` */
19
+ model: string;
20
+ /** The user-turn prompt */
21
+ prompt: string;
22
+ /** System-level instructions (supported by Anthropic + Gemini) */
23
+ systemPrompt?: string;
24
+ /** Hard token cap on the response */
25
+ maxTokens?: number;
26
+ /** Sampling temperature 0–2. Lower = more deterministic. */
27
+ temperature?: number;
28
+ /** Prior turns to send as context */
29
+ history?: Array<{
30
+ role: "user" | "assistant";
31
+ content: string;
32
+ }>;
33
+ }
34
+ export interface GenerateTextResult {
35
+ id: string;
36
+ model: string;
37
+ provider: AIProvider;
38
+ /** `"text"` or `"code"` */
39
+ category: AIModelCategory;
40
+ content: string;
41
+ inputTokens: number;
42
+ outputTokens: number;
43
+ durationMs: number;
44
+ createdAt: string;
45
+ }
46
+ export interface GenerateImageOptions {
47
+ /** Model ID, e.g. `"imagen-4.0-generate-001"` */
48
+ model: string;
49
+ /** Text description of the desired image */
50
+ prompt: string;
51
+ /** Things to exclude from the image */
52
+ negativePrompt?: string;
53
+ /** Output canvas ratio */
54
+ aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4";
55
+ /** Number of images to generate (1–4) */
56
+ numberOfImages?: number;
57
+ /**
58
+ * Folder name inside the project's AI-output storage bucket where
59
+ * generated images will be saved, e.g. `"marketing"`.
60
+ * Leave undefined to use the bucket root.
61
+ */
62
+ outputFolder?: string;
63
+ }
64
+ export interface GeneratedMediaFile {
65
+ /** ID of the file in project Storage */
66
+ storageFileId: string;
67
+ /** Storage bucket ID */
68
+ bucketId: string;
69
+ /** Full storage path, e.g. `"ai-outputs/images/img_123.png"` */
70
+ fullPath: string;
71
+ sizeBytes: number;
72
+ mimeType: string;
73
+ }
74
+ export interface GenerateImageResult {
75
+ id: string;
76
+ model: string;
77
+ provider: AIProvider;
78
+ category: "image";
79
+ prompt: string;
80
+ /** Each generated image as a saved storage file */
81
+ files: GeneratedMediaFile[];
82
+ durationMs: number;
83
+ createdAt: string;
84
+ }
85
+ export interface GenerateVideoOptions {
86
+ /** Model ID, e.g. `"veo-3.1-generate-preview"` */
87
+ model: string;
88
+ /** Text description of the video */
89
+ prompt: string;
90
+ negativePrompt?: string;
91
+ /** Requested clip length in seconds (1–30) */
92
+ durationSeconds?: number;
93
+ aspectRatio?: "16:9" | "9:16" | "1:1";
94
+ /**
95
+ * Folder inside the AI-output storage bucket where the video will be saved.
96
+ */
97
+ outputFolder?: string;
98
+ }
99
+ export interface GenerateVideoResult {
100
+ id: string;
101
+ model: string;
102
+ provider: AIProvider;
103
+ category: "video";
104
+ prompt: string;
105
+ /** `"completed"` once the async Veo job finishes (may take 1–5 min) */
106
+ status: "completed" | "pending" | "failed";
107
+ /** Server-side async operation name — informational */
108
+ operationName?: string;
109
+ files: GeneratedMediaFile[];
110
+ durationMs: number;
111
+ createdAt: string;
112
+ }
113
+ export interface GenerateEmbeddingOptions {
114
+ /** Model ID, e.g. `"gemini-embedding-001"` */
115
+ model: string;
116
+ /** One string or an array of strings to embed */
117
+ input: string | string[];
118
+ }
119
+ export interface GenerateEmbeddingResult {
120
+ id: string;
121
+ model: string;
122
+ provider: AIProvider;
123
+ category: "embedding";
124
+ /** One float array per input string */
125
+ embeddings: number[][];
126
+ inputTokens: number;
127
+ durationMs: number;
128
+ createdAt: string;
129
+ }
130
+ export interface AIUsageRecord {
131
+ id: string;
132
+ model: string;
133
+ provider: AIProvider;
134
+ category: AIModelCategory;
135
+ inputTokens: number;
136
+ outputTokens: number;
137
+ mediaCount: number;
138
+ durationMs: number;
139
+ status: "success" | "error";
140
+ error?: string;
141
+ createdAt: string;
142
+ }
143
+ export interface AIUsageStats {
144
+ totalRequests: number;
145
+ successRequests: number;
146
+ errorRequests: number;
147
+ totalInputTokens: number;
148
+ totalOutputTokens: number;
149
+ totalMediaGenerated: number;
150
+ byModel: Record<string, number>;
151
+ byCategory: Partial<Record<AIModelCategory, number>>;
152
+ }
153
+ /**
154
+ * Thrown by all AI SDK methods when the server returns an error.
155
+ *
156
+ * @example
157
+ * import { AIError } from "clefbase";
158
+ *
159
+ * try {
160
+ * const result = await ai.text({ model: "claude-sonnet-4-5", prompt: "Hello" });
161
+ * } catch (err) {
162
+ * if (err instanceof AIError) {
163
+ * console.error(err.message, err.httpStatus);
164
+ * }
165
+ * }
166
+ */
167
+ export declare class AIError extends Error {
168
+ /** HTTP status code returned by the server, if available */
169
+ readonly httpStatus?: number | undefined;
170
+ constructor(message: string,
171
+ /** HTTP status code returned by the server, if available */
172
+ httpStatus?: number | undefined);
173
+ }
174
+ /**
175
+ * Clefbase AI service — obtained via `getAI(app)`.
176
+ *
177
+ * Provides access to text/code generation (Claude & Gemini), image generation
178
+ * (Imagen 3), video generation (Veo 2), and text embeddings.
179
+ * Generated images and videos are automatically saved to the project's
180
+ * configured storage bucket.
181
+ *
182
+ * @example
183
+ * import { initClefbase, getAI } from "clefbase";
184
+ *
185
+ * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
186
+ * const ai = getAI(app);
187
+ *
188
+ * // ── Text / code ────────────────────────────────────────────────────────────
189
+ * const { content } = await ai.text({
190
+ * model: "claude-sonnet-4-5",
191
+ * prompt: "Explain promises in JavaScript",
192
+ * });
193
+ *
194
+ * // ── Multi-turn chat ────────────────────────────────────────────────────────
195
+ * const { content } = await ai.text({
196
+ * model: "gemini-2.5-flash",
197
+ * prompt: "What did I just ask you?",
198
+ * systemPrompt: "You are a helpful tutor.",
199
+ * history: [
200
+ * { role: "user", content: "What is 2 + 2?" },
201
+ * { role: "assistant", content: "4" },
202
+ * ],
203
+ * });
204
+ *
205
+ * // ── Image (saved to Storage) ────────────────────────────────────────────────
206
+ * const { files } = await ai.image({
207
+ * model: "imagen-4.0-generate-001",
208
+ * prompt: "A serene mountain lake at dawn, photorealistic",
209
+ * aspectRatio: "16:9",
210
+ * numberOfImages: 2,
211
+ * outputFolder: "landscapes",
212
+ * });
213
+ * // files[].fullPath → path in project Storage
214
+ * // files[].storageFileId → pass to storage SDK to get a download URL
215
+ *
216
+ * // ── Video (saved to Storage) ───────────────────────────────────────────────
217
+ * const { status, files } = await ai.video({
218
+ * model: "veo-3.1-generate-preview",
219
+ * prompt: "A slow-motion waterfall in a rainforest",
220
+ * durationSeconds: 8,
221
+ * aspectRatio: "16:9",
222
+ * });
223
+ *
224
+ * // ── Embeddings ─────────────────────────────────────────────────────────────
225
+ * const { embeddings } = await ai.embedding({
226
+ * model: "gemini-embedding-001",
227
+ * input: ["Hello world", "Semantic search"],
228
+ * });
229
+ * // embeddings: number[][]
230
+ *
231
+ * // ── Browse models ──────────────────────────────────────────────────────────
232
+ * const imageModels = await ai.listModels({ category: "image" });
233
+ *
234
+ * // ── Usage ──────────────────────────────────────────────────────────────────
235
+ * const stats = await ai.getStats();
236
+ * const history = await ai.getUsage({ limit: 50 });
237
+ */
238
+ export declare class ClefbaseAI {
239
+ private readonly _http;
240
+ /** @internal */
241
+ constructor(_http: HttpClient);
242
+ /**
243
+ * List all AI models available on the server.
244
+ * Optionally filter by `provider` or `category`.
245
+ *
246
+ * @example
247
+ * const textModels = await ai.listModels({ category: "text" });
248
+ * const googleModels = await ai.listModels({ provider: "google" });
249
+ * const all = await ai.listModels();
250
+ */
251
+ listModels(filter?: {
252
+ provider?: AIProvider;
253
+ category?: AIModelCategory;
254
+ }): Promise<AIModel[]>;
255
+ /**
256
+ * Generate text or code with a Claude or Gemini model.
257
+ *
258
+ * @example
259
+ * const { content, inputTokens, outputTokens } = await ai.text({
260
+ * model: "claude-sonnet-4-5",
261
+ * prompt: "Write a bubble-sort in Python",
262
+ * systemPrompt: "Return only code, no explanation.",
263
+ * maxTokens: 512,
264
+ * });
265
+ */
266
+ text(options: GenerateTextOptions): Promise<GenerateTextResult>;
267
+ /**
268
+ * Generate one or more images with an Imagen model.
269
+ * Outputs are automatically saved to the project's storage bucket.
270
+ *
271
+ * @example
272
+ * const { files } = await ai.image({
273
+ * model: "imagen-4.0-generate-001",
274
+ * prompt: "A futuristic city skyline at sunset",
275
+ * aspectRatio: "16:9",
276
+ * });
277
+ * const path = files[0].fullPath; // use with storage.ref()
278
+ */
279
+ image(options: GenerateImageOptions): Promise<GenerateImageResult>;
280
+ /**
281
+ * Generate a video with Veo 2.
282
+ * This is an async server-side operation — the SDK call blocks until the
283
+ * job completes (usually 1–5 minutes). Outputs are saved to project storage.
284
+ *
285
+ * @example
286
+ * const { status, files } = await ai.video({
287
+ * model: "veo-3.1-generate-preview",
288
+ * prompt: "A golden retriever running on a sunny beach",
289
+ * durationSeconds: 5,
290
+ * outputFolder: "clips",
291
+ * });
292
+ */
293
+ video(options: GenerateVideoOptions): Promise<GenerateVideoResult>;
294
+ /**
295
+ * Generate text embeddings — one float vector per input string.
296
+ *
297
+ * @example
298
+ * const { embeddings } = await ai.embedding({
299
+ * model: "gemini-embedding-001",
300
+ * input: ["cat", "dog", "automobile"],
301
+ * });
302
+ * // embeddings[0].length === 768
303
+ */
304
+ embedding(options: GenerateEmbeddingOptions): Promise<GenerateEmbeddingResult>;
305
+ /**
306
+ * Fetch aggregated usage statistics for this project.
307
+ *
308
+ * @example
309
+ * const { totalRequests, totalInputTokens, totalMediaGenerated } = await ai.getStats();
310
+ */
311
+ getStats(): Promise<AIUsageStats>;
312
+ /**
313
+ * Fetch the raw request log for this project (newest first).
314
+ *
315
+ * @param opts.limit Max records to return (default: 50, server max: 200)
316
+ *
317
+ * @example
318
+ * const records = await ai.getUsage({ limit: 20 });
319
+ * for (const r of records) {
320
+ * console.log(r.model, r.status, r.durationMs);
321
+ * }
322
+ */
323
+ getUsage(opts?: {
324
+ limit?: number;
325
+ }): Promise<AIUsageRecord[]>;
326
+ private _wrap;
327
+ }
328
+ /**
329
+ * Generate text or code. Sugar for `ai.text(options)`.
330
+ *
331
+ * @example
332
+ * const { content } = await generateText(ai, {
333
+ * model: "claude-sonnet-4-5",
334
+ * prompt: "What is the capital of France?",
335
+ * });
336
+ */
337
+ export declare function generateText(ai: ClefbaseAI, options: GenerateTextOptions): Promise<GenerateTextResult>;
338
+ /**
339
+ * Generate images. Sugar for `ai.image(options)`.
340
+ *
341
+ * @example
342
+ * const { files } = await generateImage(ai, {
343
+ * model: "imagen-4.0-generate-001",
344
+ * prompt: "A calm ocean at sunset",
345
+ * });
346
+ */
347
+ export declare function generateImage(ai: ClefbaseAI, options: GenerateImageOptions): Promise<GenerateImageResult>;
348
+ /**
349
+ * Generate a video. Sugar for `ai.video(options)`.
350
+ *
351
+ * @example
352
+ * const { files } = await generateVideo(ai, {
353
+ * model: "veo-3.1-generate-preview",
354
+ * prompt: "A timelapse of clouds over a mountain",
355
+ * durationSeconds: 6,
356
+ * });
357
+ */
358
+ export declare function generateVideo(ai: ClefbaseAI, options: GenerateVideoOptions): Promise<GenerateVideoResult>;
359
+ /**
360
+ * Generate embeddings. Sugar for `ai.embedding(options)`.
361
+ *
362
+ * @example
363
+ * const { embeddings } = await generateEmbedding(ai, {
364
+ * model: "gemini-embedding-001",
365
+ * input: "Hello world",
366
+ * });
367
+ */
368
+ export declare function generateEmbedding(ai: ClefbaseAI, options: GenerateEmbeddingOptions): Promise<GenerateEmbeddingResult>;
369
+ //# sourceMappingURL=ai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"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OAAO,CAAC,uBAAuB,CAAC;IAUpF;;;;;OAKG;IACG,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAUvC;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAWnE,OAAO,CAAC,KAAK;CAKd;AAID;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAE7B;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
package/dist/ai.js ADDED
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClefbaseAI = exports.AIError = void 0;
4
+ exports.generateText = generateText;
5
+ exports.generateImage = generateImage;
6
+ exports.generateVideo = generateVideo;
7
+ exports.generateEmbedding = generateEmbedding;
8
+ const types_1 = require("./types");
9
+ // ─── AIError ──────────────────────────────────────────────────────────────────
10
+ /**
11
+ * Thrown by all AI SDK methods when the server returns an error.
12
+ *
13
+ * @example
14
+ * import { AIError } from "clefbase";
15
+ *
16
+ * try {
17
+ * const result = await ai.text({ model: "claude-sonnet-4-5", prompt: "Hello" });
18
+ * } catch (err) {
19
+ * if (err instanceof AIError) {
20
+ * console.error(err.message, err.httpStatus);
21
+ * }
22
+ * }
23
+ */
24
+ class AIError extends Error {
25
+ constructor(message,
26
+ /** HTTP status code returned by the server, if available */
27
+ httpStatus) {
28
+ super(message);
29
+ this.httpStatus = httpStatus;
30
+ this.name = "AIError";
31
+ if (Error.captureStackTrace)
32
+ Error.captureStackTrace(this, AIError);
33
+ }
34
+ }
35
+ exports.AIError = AIError;
36
+ // ─── ClefbaseAI ───────────────────────────────────────────────────────────────
37
+ /**
38
+ * Clefbase AI service — obtained via `getAI(app)`.
39
+ *
40
+ * Provides access to text/code generation (Claude & Gemini), image generation
41
+ * (Imagen 3), video generation (Veo 2), and text embeddings.
42
+ * Generated images and videos are automatically saved to the project's
43
+ * configured storage bucket.
44
+ *
45
+ * @example
46
+ * import { initClefbase, getAI } from "clefbase";
47
+ *
48
+ * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
49
+ * const ai = getAI(app);
50
+ *
51
+ * // ── Text / code ────────────────────────────────────────────────────────────
52
+ * const { content } = await ai.text({
53
+ * model: "claude-sonnet-4-5",
54
+ * prompt: "Explain promises in JavaScript",
55
+ * });
56
+ *
57
+ * // ── Multi-turn chat ────────────────────────────────────────────────────────
58
+ * const { content } = await ai.text({
59
+ * model: "gemini-2.5-flash",
60
+ * prompt: "What did I just ask you?",
61
+ * systemPrompt: "You are a helpful tutor.",
62
+ * history: [
63
+ * { role: "user", content: "What is 2 + 2?" },
64
+ * { role: "assistant", content: "4" },
65
+ * ],
66
+ * });
67
+ *
68
+ * // ── Image (saved to Storage) ────────────────────────────────────────────────
69
+ * const { files } = await ai.image({
70
+ * model: "imagen-4.0-generate-001",
71
+ * prompt: "A serene mountain lake at dawn, photorealistic",
72
+ * aspectRatio: "16:9",
73
+ * numberOfImages: 2,
74
+ * outputFolder: "landscapes",
75
+ * });
76
+ * // files[].fullPath → path in project Storage
77
+ * // files[].storageFileId → pass to storage SDK to get a download URL
78
+ *
79
+ * // ── Video (saved to Storage) ───────────────────────────────────────────────
80
+ * const { status, files } = await ai.video({
81
+ * model: "veo-3.1-generate-preview",
82
+ * prompt: "A slow-motion waterfall in a rainforest",
83
+ * durationSeconds: 8,
84
+ * aspectRatio: "16:9",
85
+ * });
86
+ *
87
+ * // ── Embeddings ─────────────────────────────────────────────────────────────
88
+ * const { embeddings } = await ai.embedding({
89
+ * model: "gemini-embedding-001",
90
+ * input: ["Hello world", "Semantic search"],
91
+ * });
92
+ * // embeddings: number[][]
93
+ *
94
+ * // ── Browse models ──────────────────────────────────────────────────────────
95
+ * const imageModels = await ai.listModels({ category: "image" });
96
+ *
97
+ * // ── Usage ──────────────────────────────────────────────────────────────────
98
+ * const stats = await ai.getStats();
99
+ * const history = await ai.getUsage({ limit: 50 });
100
+ */
101
+ class ClefbaseAI {
102
+ /** @internal */
103
+ constructor(_http) {
104
+ this._http = _http;
105
+ }
106
+ // ─── listModels ─────────────────────────────────────────────────────────────
107
+ /**
108
+ * List all AI models available on the server.
109
+ * Optionally filter by `provider` or `category`.
110
+ *
111
+ * @example
112
+ * const textModels = await ai.listModels({ category: "text" });
113
+ * const googleModels = await ai.listModels({ provider: "google" });
114
+ * const all = await ai.listModels();
115
+ */
116
+ async listModels(filter) {
117
+ const qs = new URLSearchParams();
118
+ if (filter?.provider)
119
+ qs.set("provider", filter.provider);
120
+ if (filter?.category)
121
+ qs.set("category", filter.category);
122
+ const query = qs.toString() ? `?${qs}` : "";
123
+ try {
124
+ return await this._http.get(`/models${query}`);
125
+ }
126
+ catch (err) {
127
+ throw this._wrap(err);
128
+ }
129
+ }
130
+ // ─── text ────────────────────────────────────────────────────────────────────
131
+ /**
132
+ * Generate text or code with a Claude or Gemini model.
133
+ *
134
+ * @example
135
+ * const { content, inputTokens, outputTokens } = await ai.text({
136
+ * model: "claude-sonnet-4-5",
137
+ * prompt: "Write a bubble-sort in Python",
138
+ * systemPrompt: "Return only code, no explanation.",
139
+ * maxTokens: 512,
140
+ * });
141
+ */
142
+ async text(options) {
143
+ try {
144
+ return await this._http.post("/generate/text", options);
145
+ }
146
+ catch (err) {
147
+ throw this._wrap(err);
148
+ }
149
+ }
150
+ // ─── image ───────────────────────────────────────────────────────────────────
151
+ /**
152
+ * Generate one or more images with an Imagen model.
153
+ * Outputs are automatically saved to the project's storage bucket.
154
+ *
155
+ * @example
156
+ * const { files } = await ai.image({
157
+ * model: "imagen-4.0-generate-001",
158
+ * prompt: "A futuristic city skyline at sunset",
159
+ * aspectRatio: "16:9",
160
+ * });
161
+ * const path = files[0].fullPath; // use with storage.ref()
162
+ */
163
+ async image(options) {
164
+ try {
165
+ return await this._http.post("/generate/image", options);
166
+ }
167
+ catch (err) {
168
+ throw this._wrap(err);
169
+ }
170
+ }
171
+ // ─── video ───────────────────────────────────────────────────────────────────
172
+ /**
173
+ * Generate a video with Veo 2.
174
+ * This is an async server-side operation — the SDK call blocks until the
175
+ * job completes (usually 1–5 minutes). Outputs are saved to project storage.
176
+ *
177
+ * @example
178
+ * const { status, files } = await ai.video({
179
+ * model: "veo-3.1-generate-preview",
180
+ * prompt: "A golden retriever running on a sunny beach",
181
+ * durationSeconds: 5,
182
+ * outputFolder: "clips",
183
+ * });
184
+ */
185
+ async video(options) {
186
+ try {
187
+ return await this._http.post("/generate/video", options);
188
+ }
189
+ catch (err) {
190
+ throw this._wrap(err);
191
+ }
192
+ }
193
+ // ─── embedding ───────────────────────────────────────────────────────────────
194
+ /**
195
+ * Generate text embeddings — one float vector per input string.
196
+ *
197
+ * @example
198
+ * const { embeddings } = await ai.embedding({
199
+ * model: "gemini-embedding-001",
200
+ * input: ["cat", "dog", "automobile"],
201
+ * });
202
+ * // embeddings[0].length === 768
203
+ */
204
+ async embedding(options) {
205
+ try {
206
+ return await this._http.post("/generate/embedding", options);
207
+ }
208
+ catch (err) {
209
+ throw this._wrap(err);
210
+ }
211
+ }
212
+ // ─── getStats ────────────────────────────────────────────────────────────────
213
+ /**
214
+ * Fetch aggregated usage statistics for this project.
215
+ *
216
+ * @example
217
+ * const { totalRequests, totalInputTokens, totalMediaGenerated } = await ai.getStats();
218
+ */
219
+ async getStats() {
220
+ try {
221
+ return await this._http.get("/stats");
222
+ }
223
+ catch (err) {
224
+ throw this._wrap(err);
225
+ }
226
+ }
227
+ // ─── getUsage ────────────────────────────────────────────────────────────────
228
+ /**
229
+ * Fetch the raw request log for this project (newest first).
230
+ *
231
+ * @param opts.limit Max records to return (default: 50, server max: 200)
232
+ *
233
+ * @example
234
+ * const records = await ai.getUsage({ limit: 20 });
235
+ * for (const r of records) {
236
+ * console.log(r.model, r.status, r.durationMs);
237
+ * }
238
+ */
239
+ async getUsage(opts) {
240
+ const limit = Math.min(opts?.limit ?? 50, 200);
241
+ try {
242
+ return await this._http.get(`/usage?limit=${limit}`);
243
+ }
244
+ catch (err) {
245
+ throw this._wrap(err);
246
+ }
247
+ }
248
+ // ─── Internal ─────────────────────────────────────────────────────────────────
249
+ _wrap(err) {
250
+ if (err instanceof AIError)
251
+ return err;
252
+ if (err instanceof types_1.ClefbaseError)
253
+ return new AIError(err.message, err.status);
254
+ return new AIError(err.message ?? "Unknown AI error");
255
+ }
256
+ }
257
+ exports.ClefbaseAI = ClefbaseAI;
258
+ // ─── Top-level convenience functions ─────────────────────────────────────────
259
+ /**
260
+ * Generate text or code. Sugar for `ai.text(options)`.
261
+ *
262
+ * @example
263
+ * const { content } = await generateText(ai, {
264
+ * model: "claude-sonnet-4-5",
265
+ * prompt: "What is the capital of France?",
266
+ * });
267
+ */
268
+ async function generateText(ai, options) {
269
+ return ai.text(options);
270
+ }
271
+ /**
272
+ * Generate images. Sugar for `ai.image(options)`.
273
+ *
274
+ * @example
275
+ * const { files } = await generateImage(ai, {
276
+ * model: "imagen-4.0-generate-001",
277
+ * prompt: "A calm ocean at sunset",
278
+ * });
279
+ */
280
+ async function generateImage(ai, options) {
281
+ return ai.image(options);
282
+ }
283
+ /**
284
+ * Generate a video. Sugar for `ai.video(options)`.
285
+ *
286
+ * @example
287
+ * const { files } = await generateVideo(ai, {
288
+ * model: "veo-3.1-generate-preview",
289
+ * prompt: "A timelapse of clouds over a mountain",
290
+ * durationSeconds: 6,
291
+ * });
292
+ */
293
+ async function generateVideo(ai, options) {
294
+ return ai.video(options);
295
+ }
296
+ /**
297
+ * Generate embeddings. Sugar for `ai.embedding(options)`.
298
+ *
299
+ * @example
300
+ * const { embeddings } = await generateEmbedding(ai, {
301
+ * model: "gemini-embedding-001",
302
+ * input: "Hello world",
303
+ * });
304
+ */
305
+ async function generateEmbedding(ai, options) {
306
+ return ai.embedding(options);
307
+ }
308
+ //# sourceMappingURL=ai.js.map
package/dist/ai.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":";;;AA4bA,oCAKC;AAWD,sCAKC;AAYD,sCAKC;AAWD,8CAKC;AAjfD,mCAAwC;AA+KxC,iFAAiF;AAEjF;;;;;;;;;;;;;GAaG;AACH,MAAa,OAAQ,SAAQ,KAAK;IAChC,YACE,OAAe;IACf,4DAA4D;IAC5C,UAAmB;QAEnC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,eAAU,GAAV,UAAU,CAAS;QAGnC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,KAAK,CAAC,iBAAiB;YAAE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;CACF;AAVD,0BAUC;AAED,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,MAAa,UAAU;IACrB,gBAAgB;IAChB,YAA6B,KAAiB;QAAjB,UAAK,GAAL,KAAK,CAAY;IAAG,CAAC;IAElD,+EAA+E;IAE/E;;;;;;;;OAQG;IACH,KAAK,CAAC,UAAU,CAAC,MAGhB;QACC,MAAM,EAAE,GAAG,IAAI,eAAe,EAAE,CAAC;QACjC,IAAI,MAAM,EAAE,QAAQ;YAA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IAAI,GAAG,YAAY,qBAAa;YAAE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC9E,OAAO,IAAI,OAAO,CAAE,GAAa,CAAC,OAAO,IAAI,kBAAkB,CAAC,CAAC;IACnE,CAAC;CACF;AAjKD,gCAiKC;AAED,gFAAgF;AAEhF;;;;;;;;GAQG;AACI,KAAK,UAAU,YAAY,CAChC,EAAc,EACd,OAA4B;IAE5B,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CACjC,EAAc,EACd,OAA6B;IAE7B,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,aAAa,CACjC,EAAc,EACd,OAA6B;IAE7B,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,iBAAiB,CACrC,EAAc,EACd,OAAiC;IAEjC,OAAO,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC"}
package/dist/app.d.ts CHANGED
@@ -4,6 +4,7 @@ import { Auth } from "./auth";
4
4
  import { ClefbaseStorage } from "./storage";
5
5
  import { ClefbaseHosting } from "./hosting";
6
6
  import { ClefbaseFunctions } from "./functions";
7
+ import { ClefbaseAI } from "./ai";
7
8
  import type { ClefbaseConfig } from "./types";
8
9
  /**
9
10
  * A Clefbase application instance.
@@ -16,11 +17,13 @@ export declare class ClefbaseApp {
16
17
  /** @internal */ readonly _storageHttp: HttpClient;
17
18
  /** @internal */ readonly _hostingHttp: HttpClient;
18
19
  /** @internal */ readonly _functionsHttp: HttpClient;
20
+ /** @internal */ readonly _aiHttp: HttpClient;
19
21
  private _db;
20
22
  private _auth;
21
23
  private _storage;
22
24
  private _hosting;
23
25
  private _functions;
26
+ private _ai;
24
27
  constructor(config: ClefbaseConfig);
25
28
  /** @internal */
26
29
  _getDb(): Database;
@@ -32,6 +35,8 @@ export declare class ClefbaseApp {
32
35
  _getHosting(): ClefbaseHosting;
33
36
  /** @internal */
34
37
  _getFunctions(): ClefbaseFunctions;
38
+ /** @internal */
39
+ _getAI(): ClefbaseAI;
35
40
  }
36
41
  /**
37
42
  * Initialise a Clefbase app. Call once at startup.
@@ -69,4 +74,39 @@ export declare function getHosting(app?: ClefbaseApp): ClefbaseHosting;
69
74
  * const { data } = await greet({ name: "Alice" });
70
75
  */
71
76
  export declare function getFunctions(app?: ClefbaseApp): ClefbaseFunctions;
77
+ /**
78
+ * Get the AI service.
79
+ *
80
+ * @example
81
+ * import { initClefbase, getAI } from "clefbase";
82
+ *
83
+ * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
84
+ * const ai = getAI(app);
85
+ *
86
+ * // Text generation
87
+ * const { content } = await ai.text({
88
+ * model: "claude-sonnet-4-5",
89
+ * prompt: "Explain closures in JavaScript",
90
+ * });
91
+ *
92
+ * // Image generation — saved to project Storage automatically
93
+ * const { files } = await ai.image({
94
+ * model: "imagen-3.0-generate-002",
95
+ * prompt: "A futuristic cityscape at sunset",
96
+ * });
97
+ *
98
+ * // Video generation
99
+ * const { status, files: videoFiles } = await ai.video({
100
+ * model: "veo-2.0-generate-001",
101
+ * prompt: "A dog running on a beach",
102
+ * durationSeconds: 5,
103
+ * });
104
+ *
105
+ * // Embeddings
106
+ * const { embeddings } = await ai.embedding({
107
+ * model: "text-embedding-004",
108
+ * input: ["Hello", "World"],
109
+ * });
110
+ */
111
+ export declare function getAI(app?: ClefbaseApp): ClefbaseAI;
72
112
  //# sourceMappingURL=app.d.ts.map
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MA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;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,KAAK,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,UAAU,CAEnD"}
package/dist/app.js CHANGED
@@ -8,12 +8,14 @@ exports.getAuth = getAuth;
8
8
  exports.getStorage = getStorage;
9
9
  exports.getHosting = getHosting;
10
10
  exports.getFunctions = getFunctions;
11
+ exports.getAI = getAI;
11
12
  const http_1 = require("./http");
12
13
  const db_1 = require("./db");
13
14
  const auth_1 = require("./auth");
14
15
  const storage_1 = require("./storage");
15
16
  const hosting_1 = require("./hosting");
16
17
  const functions_1 = require("./functions");
18
+ const ai_1 = require("./ai");
17
19
  // ─── App ──────────────────────────────────────────────────────────────────────
18
20
  /**
19
21
  * A Clefbase application instance.
@@ -30,6 +32,7 @@ class ClefbaseApp {
30
32
  this._storageHttp = new http_1.HttpClient(`${base}/storage`, cfxKey);
31
33
  this._hostingHttp = new http_1.HttpClient(`${base}/api/hosting`, admin);
32
34
  this._functionsHttp = new http_1.HttpClient(`${base}/functions`, cfxKey);
35
+ this._aiHttp = new http_1.HttpClient(`${base}/ai`, cfxKey);
33
36
  }
34
37
  /** @internal */
35
38
  _getDb() {
@@ -61,6 +64,12 @@ class ClefbaseApp {
61
64
  this._functions = new functions_1.ClefbaseFunctions(this._functionsHttp);
62
65
  return this._functions;
63
66
  }
67
+ /** @internal */
68
+ _getAI() {
69
+ if (!this._ai)
70
+ this._ai = new ai_1.ClefbaseAI(this._aiHttp);
71
+ return this._ai;
72
+ }
64
73
  }
65
74
  exports.ClefbaseApp = ClefbaseApp;
66
75
  // ─── Registry ─────────────────────────────────────────────────────────────────
@@ -125,4 +134,41 @@ function getHosting(app) {
125
134
  function getFunctions(app) {
126
135
  return (app ?? getApp())._getFunctions();
127
136
  }
137
+ /**
138
+ * Get the AI service.
139
+ *
140
+ * @example
141
+ * import { initClefbase, getAI } from "clefbase";
142
+ *
143
+ * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
144
+ * const ai = getAI(app);
145
+ *
146
+ * // Text generation
147
+ * const { content } = await ai.text({
148
+ * model: "claude-sonnet-4-5",
149
+ * prompt: "Explain closures in JavaScript",
150
+ * });
151
+ *
152
+ * // Image generation — saved to project Storage automatically
153
+ * const { files } = await ai.image({
154
+ * model: "imagen-3.0-generate-002",
155
+ * prompt: "A futuristic cityscape at sunset",
156
+ * });
157
+ *
158
+ * // Video generation
159
+ * const { status, files: videoFiles } = await ai.video({
160
+ * model: "veo-2.0-generate-001",
161
+ * prompt: "A dog running on a beach",
162
+ * durationSeconds: 5,
163
+ * });
164
+ *
165
+ * // Embeddings
166
+ * const { embeddings } = await ai.embedding({
167
+ * model: "text-embedding-004",
168
+ * input: ["Hello", "World"],
169
+ * });
170
+ */
171
+ function getAI(app) {
172
+ return (app ?? getApp())._getAI();
173
+ }
128
174
  //# sourceMappingURL=app.js.map
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;AAqGA,oCAQC;AAGD,wBAQC;AAKD,kCAEC;AAGD,0BAEC;AAGD,gCAEC;AAGD,gCAEC;AAcD,oCAEC;AA9JD,iCAAoC;AACpC,6BAAgC;AAChC,iCAA8B;AAC9B,uCAA4C;AAC5C,uCAA4C;AAC5C,2CAAgD;AAGhD,iFAAiF;AAEjF;;;GAGG;AACH,MAAa,WAAW;IAetB,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,IAAI,GAAK,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,EAAE,WAAW,EAAO,MAAM,CAAC,MAAM,EAAE,CAAC;QACnD,MAAM,KAAK,GAAI,EAAE,gBAAgB,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;QAE9D,IAAI,CAAC,OAAO,GAAU,IAAI,iBAAU,CA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ChC,SAAgB,WAAW,CAAC,GAAiB;IAC3C,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AACpC,CAAC;AAED,4BAA4B;AAC5B,SAAgB,OAAO,CAAC,GAAiB;IACvC,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtC,CAAC;AAED,+BAA+B;AAC/B,SAAgB,UAAU,CAAC,GAAiB;IAC1C,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC;AAED,iEAAiE;AACjE,SAAgB,UAAU,CAAC,GAAiB;IAC1C,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,YAAY,CAAC,GAAiB;IAC5C,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,KAAK,CAAC,GAAiB;IACrC,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AACpC,CAAC"}
package/dist/cli.js CHANGED
@@ -34878,7 +34878,7 @@ async function promptRequired(message) {
34878
34878
  }
34879
34879
 
34880
34880
  // package.json
34881
- var version = "1.5.3";
34881
+ var version = "2.0.0";
34882
34882
 
34883
34883
  // src/cli/index.ts
34884
34884
  var program2 = new Command();
package/dist/index.d.ts CHANGED
@@ -4,58 +4,94 @@
4
4
  * @example
5
5
  * import {
6
6
  * initClefbase, getDatabase, getAuth, getStorage, getHosting,
7
- * getFunctions, httpsCallable, callFunction, deployFunction, deployFromFile,
8
- * setAuthToken, FunctionsError, FieldValue,
7
+ * getFunctions, getAI,
8
+ * httpsCallable, callFunction, deployFunction, deployFromFile,
9
+ * generateText, generateImage, generateVideo, generateEmbedding,
10
+ * setAuthToken, FunctionsError, AIError, FieldValue,
9
11
  * } from "clefbase";
10
12
  *
11
- * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
12
- * const fns = getFunctions(app);
13
- * const auth = getAuth(app);
13
+ * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
14
14
  *
15
- * // ── Auth-aware function call ───────────────────────────────────────────────
15
+ * // ── Auth ──────────────────────────────────────────────────────────────────
16
+ * const auth = getAuth(app);
16
17
  * const { token } = await auth.signIn("alice@example.com", "password123");
17
- * setAuthToken(app, token); // ctx.auth.uid / email now available in function
18
18
  *
19
- * // ── Typed callable ────────────────────────────────────────────────────────
19
+ * // ── Database ──────────────────────────────────────────────────────────────
20
+ * const db = getDatabase(app);
21
+ * await db.collection("posts").doc("p1").update({
22
+ * views: FieldValue.increment(1),
23
+ * publishedAt: FieldValue.serverTimestamp(),
24
+ * });
25
+ *
26
+ * // ── Storage ───────────────────────────────────────────────────────────────
27
+ * const storage = getStorage(app);
28
+ * const url = await storage.ref("avatars/user-123.jpg").getDownloadURL();
29
+ *
30
+ * // ── Functions ─────────────────────────────────────────────────────────────
31
+ * const fns = getFunctions(app);
20
32
  * const greet = httpsCallable<{ name: string }, { message: string }>(fns, "greetUser");
21
33
  * const { data } = await greet({ name: "Alice" });
22
34
  *
23
- * // ── One-shot call ─────────────────────────────────────────────────────────
24
- * const { data } = await callFunction(fns, "greetUser", { name: "Bob" });
35
+ * // ── AI text / code ──────────────────────────────────────────────────────
36
+ * const ai = getAI(app);
25
37
  *
26
- * // ── Deploy from source ────────────────────────────────────────────────────
27
- * await deployFunction(fns, {
28
- * name: "greetUser",
29
- * runtime: "node",
30
- * trigger: { type: "http" },
31
- * source: `export async function handler(ctx) { return { message: "Hi " + ctx.data.name }; }`,
38
+ * const { content } = await ai.text({
39
+ * model: "claude-sonnet-4-5",
40
+ * prompt: "Explain async/await in JavaScript",
32
41
  * });
33
42
  *
34
- * // ── Deploy from file (Node.js) ────────────────────────────────────────────
35
- * await deployFromFile(fns, {
36
- * name: "processOrder",
37
- * runtime: "node",
38
- * trigger: { type: "http" },
39
- * filePath: "./src/functions/processOrder.ts",
43
+ * // Multi-turn chat
44
+ * const reply = await ai.text({
45
+ * model: "gemini-2.5-flash",
46
+ * prompt: "Give me a harder example",
47
+ * systemPrompt: "You are a JavaScript tutor.",
48
+ * history: [{ role: "user", content: "Explain closures" }, { role: "assistant", content: "..." }],
40
49
  * });
41
50
  *
42
- * // ── Error handling ────────────────────────────────────────────────────────
43
- * try {
44
- * await callFunction(fns, "mayFail");
45
- * } catch (err) {
46
- * if (err instanceof FunctionsError) {
47
- * console.error(err.httpStatus, err.message);
48
- * }
49
- * }
51
+ * // ── AI image generation (auto-saved to Storage) ─────────────────────────
52
+ * const { files } = await ai.image({
53
+ * model: "imagen-4.0-generate-001",
54
+ * prompt: "A serene mountain lake at dawn, photorealistic",
55
+ * aspectRatio: "16:9",
56
+ * numberOfImages: 2,
57
+ * outputFolder: "landscapes",
58
+ * });
59
+ * // files[].fullPath → path in project Storage
60
+ * // files[].storageFileId → use with storage.ref() to get the download URL
50
61
  *
51
- * // ── Database ──────────────────────────────────────────────────────────────
52
- * const db = getDatabase(app);
53
- * await db.collection("posts").doc("p1").update({
54
- * views: FieldValue.increment(1),
55
- * publishedAt: FieldValue.serverTimestamp(),
62
+ * // ── AI — video generation (auto-saved to Storage) ─────────────────────────
63
+ * const { status, files: clips } = await ai.video({
64
+ * model: "veo-3.1-generate-preview",
65
+ * prompt: "A slow-motion waterfall in a rainforest",
66
+ * durationSeconds: 8,
67
+ * aspectRatio: "16:9",
68
+ * });
69
+ *
70
+ * // ── AI — embeddings ───────────────────────────────────────────────────────
71
+ * const { embeddings } = await ai.embedding({
72
+ * model: "gemini-embedding-001",
73
+ * input: ["Hello world", "Semantic search"],
74
+ * });
75
+ *
76
+ * // ── AI — browse models ────────────────────────────────────────────────────
77
+ * const imageModels = await ai.listModels({ category: "image" });
78
+ * const allModels = await ai.listModels();
79
+ *
80
+ * // ── AI — usage stats ──────────────────────────────────────────────────────
81
+ * const stats = await ai.getStats();
82
+ * const history = await ai.getUsage({ limit: 20 });
83
+ *
84
+ * // ── AI — convenience top-level functions ──────────────────────────────────
85
+ * const { content: code } = await generateText(ai, {
86
+ * model: "claude-sonnet-4-5",
87
+ * prompt: "Write a merge sort in TypeScript",
88
+ * });
89
+ * const { files: imgs } = await generateImage(ai, {
90
+ * model: "imagen-4.0-fast-generate-001",
91
+ * prompt: "A cute cartoon robot",
56
92
  * });
57
93
  */
58
- export { ClefbaseApp, initClefbase, getApp, getDatabase, getAuth, getStorage, getHosting, getFunctions, } from "./app";
94
+ export { ClefbaseApp, initClefbase, getApp, getDatabase, getAuth, getStorage, getHosting, getFunctions, getAI, } from "./app";
59
95
  export { Database, CollectionReference, CollectionGroup, DocumentReference, Query, WriteBatch, Transaction, runTransaction, } from "./db";
60
96
  export { Auth } from "./auth";
61
97
  export type { GoogleButtonOptions } from "./auth";
@@ -67,6 +103,8 @@ export { ClefbaseHosting, SiteReference } from "./hosting";
67
103
  export type { HostingSite, HostingDeploy, HostingFile, DeployResult, DeployOptions, HostingStatus, DeployStatus, } from "./hosting";
68
104
  export { ClefbaseFunctions, FunctionsError, httpsCallable, callFunction, deployFunction, deleteFunction, listFunctions, getFunctionExecutions, setAuthToken, deployFromFile, } from "./functions";
69
105
  export type { FunctionRuntime, FunctionTrigger, FunctionTriggerType, FunctionDef, FunctionExecution, FunctionsConfig, FunctionStats, DeployFunctionOptions, HttpsCallableResult, } from "./functions";
106
+ export { ClefbaseAI, AIError, generateText, generateImage, generateVideo, generateEmbedding, } from "./ai";
107
+ export type { AIModel, AIProvider, AIModelCategory, GenerateTextOptions, GenerateTextResult, GenerateImageOptions, GenerateImageResult, GeneratedMediaFile, GenerateVideoOptions, GenerateVideoResult, GenerateEmbeddingOptions, GenerateEmbeddingResult, AIUsageRecord, AIUsageStats, } from "./ai";
70
108
  export { FieldValue, FieldValueSentinel } from "./field_value";
71
109
  export type { FieldValueType } from "./field_value";
72
110
  export type { ClefbaseConfig, ClefbaseDocument, QueryOptions, QueryResult, FilterOperator, WhereClause, WhereValue, AuthUser, AuthSession, AuthResult, } from "./types";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAGH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,MAAM,EACN,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACV,YAAY,GACb,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,GACf,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,YAAY,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,GACb,MAAM,WAAW,CAAC;AAGnB,OAAO,EAEL,iBAAiB,EAEjB,cAAc,EAEd,aAAa,EACb,YAAY,EACZ,cAAc,EACd,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,aAA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getAuth, getStorage, getHosting,
8
- * getFunctions, httpsCallable, callFunction, deployFunction, deployFromFile,
9
- * setAuthToken, FunctionsError, FieldValue,
8
+ * getFunctions, getAI,
9
+ * httpsCallable, callFunction, deployFunction, deployFromFile,
10
+ * generateText, generateImage, generateVideo, generateEmbedding,
11
+ * setAuthToken, FunctionsError, AIError, FieldValue,
10
12
  * } from "clefbase";
11
13
  *
12
- * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
13
- * const fns = getFunctions(app);
14
- * const auth = getAuth(app);
14
+ * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
15
15
  *
16
- * // ── Auth-aware function call ───────────────────────────────────────────────
16
+ * // ── Auth ──────────────────────────────────────────────────────────────────
17
+ * const auth = getAuth(app);
17
18
  * const { token } = await auth.signIn("alice@example.com", "password123");
18
- * setAuthToken(app, token); // ctx.auth.uid / email now available in function
19
19
  *
20
- * // ── Typed callable ────────────────────────────────────────────────────────
20
+ * // ── Database ──────────────────────────────────────────────────────────────
21
+ * const db = getDatabase(app);
22
+ * await db.collection("posts").doc("p1").update({
23
+ * views: FieldValue.increment(1),
24
+ * publishedAt: FieldValue.serverTimestamp(),
25
+ * });
26
+ *
27
+ * // ── Storage ───────────────────────────────────────────────────────────────
28
+ * const storage = getStorage(app);
29
+ * const url = await storage.ref("avatars/user-123.jpg").getDownloadURL();
30
+ *
31
+ * // ── Functions ─────────────────────────────────────────────────────────────
32
+ * const fns = getFunctions(app);
21
33
  * const greet = httpsCallable<{ name: string }, { message: string }>(fns, "greetUser");
22
34
  * const { data } = await greet({ name: "Alice" });
23
35
  *
24
- * // ── One-shot call ─────────────────────────────────────────────────────────
25
- * const { data } = await callFunction(fns, "greetUser", { name: "Bob" });
36
+ * // ── AI text / code ──────────────────────────────────────────────────────
37
+ * const ai = getAI(app);
26
38
  *
27
- * // ── Deploy from source ────────────────────────────────────────────────────
28
- * await deployFunction(fns, {
29
- * name: "greetUser",
30
- * runtime: "node",
31
- * trigger: { type: "http" },
32
- * source: `export async function handler(ctx) { return { message: "Hi " + ctx.data.name }; }`,
39
+ * const { content } = await ai.text({
40
+ * model: "claude-sonnet-4-5",
41
+ * prompt: "Explain async/await in JavaScript",
33
42
  * });
34
43
  *
35
- * // ── Deploy from file (Node.js) ────────────────────────────────────────────
36
- * await deployFromFile(fns, {
37
- * name: "processOrder",
38
- * runtime: "node",
39
- * trigger: { type: "http" },
40
- * filePath: "./src/functions/processOrder.ts",
44
+ * // Multi-turn chat
45
+ * const reply = await ai.text({
46
+ * model: "gemini-2.5-flash",
47
+ * prompt: "Give me a harder example",
48
+ * systemPrompt: "You are a JavaScript tutor.",
49
+ * history: [{ role: "user", content: "Explain closures" }, { role: "assistant", content: "..." }],
41
50
  * });
42
51
  *
43
- * // ── Error handling ────────────────────────────────────────────────────────
44
- * try {
45
- * await callFunction(fns, "mayFail");
46
- * } catch (err) {
47
- * if (err instanceof FunctionsError) {
48
- * console.error(err.httpStatus, err.message);
49
- * }
50
- * }
52
+ * // ── AI image generation (auto-saved to Storage) ─────────────────────────
53
+ * const { files } = await ai.image({
54
+ * model: "imagen-4.0-generate-001",
55
+ * prompt: "A serene mountain lake at dawn, photorealistic",
56
+ * aspectRatio: "16:9",
57
+ * numberOfImages: 2,
58
+ * outputFolder: "landscapes",
59
+ * });
60
+ * // files[].fullPath → path in project Storage
61
+ * // files[].storageFileId → use with storage.ref() to get the download URL
51
62
  *
52
- * // ── Database ──────────────────────────────────────────────────────────────
53
- * const db = getDatabase(app);
54
- * await db.collection("posts").doc("p1").update({
55
- * views: FieldValue.increment(1),
56
- * publishedAt: FieldValue.serverTimestamp(),
63
+ * // ── AI — video generation (auto-saved to Storage) ─────────────────────────
64
+ * const { status, files: clips } = await ai.video({
65
+ * model: "veo-3.1-generate-preview",
66
+ * prompt: "A slow-motion waterfall in a rainforest",
67
+ * durationSeconds: 8,
68
+ * aspectRatio: "16:9",
69
+ * });
70
+ *
71
+ * // ── AI — embeddings ───────────────────────────────────────────────────────
72
+ * const { embeddings } = await ai.embedding({
73
+ * model: "gemini-embedding-001",
74
+ * input: ["Hello world", "Semantic search"],
75
+ * });
76
+ *
77
+ * // ── AI — browse models ────────────────────────────────────────────────────
78
+ * const imageModels = await ai.listModels({ category: "image" });
79
+ * const allModels = await ai.listModels();
80
+ *
81
+ * // ── AI — usage stats ──────────────────────────────────────────────────────
82
+ * const stats = await ai.getStats();
83
+ * const history = await ai.getUsage({ limit: 20 });
84
+ *
85
+ * // ── AI — convenience top-level functions ──────────────────────────────────
86
+ * const { content: code } = await generateText(ai, {
87
+ * model: "claude-sonnet-4-5",
88
+ * prompt: "Write a merge sort in TypeScript",
89
+ * });
90
+ * const { files: imgs } = await generateImage(ai, {
91
+ * model: "imagen-4.0-fast-generate-001",
92
+ * prompt: "A cute cartoon robot",
57
93
  * });
58
94
  */
59
95
  Object.defineProperty(exports, "__esModule", { value: true });
60
- exports.ClefbaseError = exports.FieldValueSentinel = exports.FieldValue = exports.deployFromFile = exports.setAuthToken = exports.getFunctionExecutions = exports.listFunctions = exports.deleteFunction = exports.deployFunction = exports.callFunction = exports.httpsCallable = exports.FunctionsError = exports.ClefbaseFunctions = exports.SiteReference = exports.ClefbaseHosting = exports.EmailVerificationCard = exports.BucketReference = exports.StorageReference = exports.ClefbaseStorage = exports.Auth = exports.runTransaction = exports.Transaction = exports.WriteBatch = exports.Query = exports.DocumentReference = exports.CollectionGroup = exports.CollectionReference = exports.Database = exports.getFunctions = exports.getHosting = exports.getStorage = exports.getAuth = exports.getDatabase = exports.getApp = exports.initClefbase = exports.ClefbaseApp = void 0;
96
+ exports.ClefbaseError = exports.FieldValueSentinel = exports.FieldValue = exports.generateEmbedding = exports.generateVideo = exports.generateImage = exports.generateText = exports.AIError = exports.ClefbaseAI = exports.deployFromFile = exports.setAuthToken = exports.getFunctionExecutions = exports.listFunctions = exports.deleteFunction = exports.deployFunction = exports.callFunction = exports.httpsCallable = exports.FunctionsError = exports.ClefbaseFunctions = exports.SiteReference = exports.ClefbaseHosting = exports.EmailVerificationCard = exports.BucketReference = exports.StorageReference = exports.ClefbaseStorage = exports.Auth = exports.runTransaction = exports.Transaction = exports.WriteBatch = exports.Query = exports.DocumentReference = exports.CollectionGroup = exports.CollectionReference = exports.Database = exports.getAI = exports.getFunctions = exports.getHosting = exports.getStorage = exports.getAuth = exports.getDatabase = exports.getApp = exports.initClefbase = exports.ClefbaseApp = void 0;
61
97
  // ─── App ──────────────────────────────────────────────────────────────────────
62
98
  var app_1 = require("./app");
63
99
  Object.defineProperty(exports, "ClefbaseApp", { enumerable: true, get: function () { return app_1.ClefbaseApp; } });
@@ -68,6 +104,7 @@ Object.defineProperty(exports, "getAuth", { enumerable: true, get: function () {
68
104
  Object.defineProperty(exports, "getStorage", { enumerable: true, get: function () { return app_1.getStorage; } });
69
105
  Object.defineProperty(exports, "getHosting", { enumerable: true, get: function () { return app_1.getHosting; } });
70
106
  Object.defineProperty(exports, "getFunctions", { enumerable: true, get: function () { return app_1.getFunctions; } });
107
+ Object.defineProperty(exports, "getAI", { enumerable: true, get: function () { return app_1.getAI; } });
71
108
  // ─── Database ─────────────────────────────────────────────────────────────────
72
109
  var db_1 = require("./db");
73
110
  Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return db_1.Database; } });
@@ -99,7 +136,7 @@ var functions_1 = require("./functions");
99
136
  Object.defineProperty(exports, "ClefbaseFunctions", { enumerable: true, get: function () { return functions_1.ClefbaseFunctions; } });
100
137
  // Error
101
138
  Object.defineProperty(exports, "FunctionsError", { enumerable: true, get: function () { return functions_1.FunctionsError; } });
102
- // Top-level factory / convenience (mirrors the standalone SDK's API shape)
139
+ // Top-level factory / convenience
103
140
  Object.defineProperty(exports, "httpsCallable", { enumerable: true, get: function () { return functions_1.httpsCallable; } });
104
141
  Object.defineProperty(exports, "callFunction", { enumerable: true, get: function () { return functions_1.callFunction; } });
105
142
  Object.defineProperty(exports, "deployFunction", { enumerable: true, get: function () { return functions_1.deployFunction; } });
@@ -108,6 +145,17 @@ Object.defineProperty(exports, "listFunctions", { enumerable: true, get: functio
108
145
  Object.defineProperty(exports, "getFunctionExecutions", { enumerable: true, get: function () { return functions_1.getFunctionExecutions; } });
109
146
  Object.defineProperty(exports, "setAuthToken", { enumerable: true, get: function () { return functions_1.setAuthToken; } });
110
147
  Object.defineProperty(exports, "deployFromFile", { enumerable: true, get: function () { return functions_1.deployFromFile; } });
148
+ // ─── AI ───────────────────────────────────────────────────────────────────────
149
+ var ai_1 = require("./ai");
150
+ // Class
151
+ Object.defineProperty(exports, "ClefbaseAI", { enumerable: true, get: function () { return ai_1.ClefbaseAI; } });
152
+ // Error
153
+ Object.defineProperty(exports, "AIError", { enumerable: true, get: function () { return ai_1.AIError; } });
154
+ // Top-level convenience functions
155
+ Object.defineProperty(exports, "generateText", { enumerable: true, get: function () { return ai_1.generateText; } });
156
+ Object.defineProperty(exports, "generateImage", { enumerable: true, get: function () { return ai_1.generateImage; } });
157
+ Object.defineProperty(exports, "generateVideo", { enumerable: true, get: function () { return ai_1.generateVideo; } });
158
+ Object.defineProperty(exports, "generateEmbedding", { enumerable: true, get: function () { return ai_1.generateEmbedding; } });
111
159
  // ─── FieldValue ───────────────────────────────────────────────────────────────
112
160
  var field_value_1 = require("./field_value");
113
161
  Object.defineProperty(exports, "FieldValue", { enumerable: true, get: function () { return field_value_1.FieldValue; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;;;AAEH,iFAAiF;AACjF,6BASe;AARb,kGAAA,WAAW,OAAA;AACX,mGAAA,YAAY,OAAA;AACZ,6FAAA,MAAM,OAAA;AACN,kGAAA,WAAW,OAAA;AACX,8FAAA,OAAO,OAAA;AACP,iGAAA,UAAU,OAAA;AACV,iGAAA,UAAU,OAAA;AACV,mGAAA,YAAY,OAAA;A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uGAAA,iBAAiB,OAAA;AA0BnB,iFAAiF;AACjF,6CAA+D;AAAtD,yGAAA,UAAU,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AAiBvC,iCAAwC;AAA/B,sGAAA,aAAa,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clefbase",
3
- "version": "1.5.3",
3
+ "version": "2.0.0",
4
4
  "description": "Firebase-style SDK and CLI for Clefbase — database, auth, storage, hosting, and functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",