@tansy/ai-google 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ What changed in each release of `@tansy/ai-google`. Releases up to 0.1.0 went out with every other package
4
+ on one version and are described in [tansy's changelog](../../CHANGELOG.md).
5
+
6
+ ## 0.1.1 — 2026-11-22
7
+
8
+ No changes of its own. Released beside `tansy` 0.1.1, from which every package moves on its own
9
+ version, and it now requires it: the `tansy` peer range is ^0.1.1.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mohamed Salah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ <!-- Generated by scripts/package-metadata.mjs. Change that script, not this file. -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # @tansy/ai-google
4
+
5
+ Google Gemini for @tansy/ai.
6
+
7
+ ```bash
8
+ npm install @tansy/ai-google
9
+ ```
10
+
11
+ Add it to `tansy.config.ts`. See [the ai plugin documentation](https://github.com/mhmdsalahsebai/tansy/blob/main/docs/plugins/ai.md) for what it adds and the options it takes.
12
+
13
+ A first-party plugin for [tansy](https://github.com/mhmdsalahsebai/tansy), a self-hosted, runtime-schema CMS for Next.js. MIT licensed.
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /** Google Gemini, through the AI SDK's @ai-sdk/google. */
2
+ export declare const google: (options?: {
3
+ defaultModel?: string;
4
+ }) => import("@tansy/ai/provider").AiProvider;
package/index.js ADDED
@@ -0,0 +1,46 @@
1
+ import { createGoogleGenerativeAI } from "@ai-sdk/google";
2
+ import { defineAiProvider, fetchModelsJson, guessCapabilities, str } from "@tansy/ai/provider";
3
+ /** Google Gemini, through the AI SDK's @ai-sdk/google. */
4
+ export const google = (options = {}) => defineAiProvider({
5
+ id: "google",
6
+ label: "Google Gemini",
7
+ defaultModel: options.defaultModel ?? "gemini-pro-latest",
8
+ // Its settings in other interface languages. English is each setting's own label and description.
9
+ messages: {
10
+ ar: {
11
+ settings: {
12
+ googleApiKey: {
13
+ label: "مفتاح API لـ Google Gemini",
14
+ description: "من aistudio.google.com ← Get API key."
15
+ }
16
+ }
17
+ }
18
+ },
19
+ settings: () => [
20
+ { name: "googleApiKey", type: "secret", env: "GOOGLE_GENERATIVE_AI_API_KEY", label: "Google Gemini API key", description: "From aistudio.google.com → Get API key." },
21
+ ],
22
+ ready: (settings) => Boolean(str(settings.googleApiKey)),
23
+ model: (settings, modelId) => createGoogleGenerativeAI({ apiKey: str(settings.googleApiKey) })(modelId),
24
+ // Imagen draws pictures through its own API. Gemini's image models answer in the chat, through `model`.
25
+ imageModel: (settings, modelId) => (/^imagen/.test(modelId) ? createGoogleGenerativeAI({ apiKey: str(settings.googleApiKey) }).image(modelId) : undefined),
26
+ // Google lists what each model's API can be called with: generateContent for Gemini, predict for Imagen.
27
+ models: async (settings) => {
28
+ const json = await fetchModelsJson("https://generativelanguage.googleapis.com/v1beta/models?pageSize=1000", { headers: { "x-goog-api-key": str(settings.googleApiKey) } });
29
+ return (Array.isArray(json.models) ? json.models : [])
30
+ .filter((model) => typeof model.name === "string")
31
+ .flatMap((model) => {
32
+ const id = model.name.replace(/^models\//, "");
33
+ const methods = Array.isArray(model.supportedGenerationMethods) ? model.supportedGenerationMethods : [];
34
+ const guess = guessCapabilities(id);
35
+ let capabilities;
36
+ if (/^imagen/.test(id))
37
+ capabilities = { input: ["text"], output: ["image"], reported: true };
38
+ else if (methods.includes("generateContent"))
39
+ capabilities = { input: ["text", "image", "audio", "video", "file"], output: guess.output ?? ["text"], tools: !/image|tts|embedding/.test(id), structured: !/image|tts/.test(id), reasoning: Boolean(model.thinking) || (guess.reasoning ?? false), reported: true };
40
+ else
41
+ return [];
42
+ return [{ value: id, label: typeof model.displayName === "string" ? model.displayName : undefined, capabilities }];
43
+ })
44
+ .sort((a, b) => a.value.localeCompare(b.value));
45
+ },
46
+ });
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@tansy/ai-google",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Google Gemini for @tansy/ai.",
5
+ "keywords": [
6
+ "tansy",
7
+ "tansy-ai-provider"
8
+ ],
9
+ "license": "MIT",
10
+ "author": "Mohamed Salah <mohamedsalahsebai@gmail.com>",
11
+ "homepage": "https://github.com/mhmdsalahsebai/tansy",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/mhmdsalahsebai/tansy.git",
15
+ "directory": "plugins/ai-google"
16
+ },
17
+ "bugs": "https://github.com/mhmdsalahsebai/tansy/issues",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./index.d.ts",
21
+ "default": "./index.js"
22
+ }
23
+ },
24
+ "peerDependencies": {
25
+ "@tansy/ai": "^0.1.1",
26
+ "tansy": "^0.1.1"
27
+ },
28
+ "dependencies": {
29
+ "@ai-sdk/google": "^4.0.121"
30
+ }
31
+ }