@jay-framework/gemini-agent-plugin 0.24.1 → 0.24.3
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 +2 -10
- package/dist/index.js +2 -68
- package/dist/tools.d.ts +11 -0
- package/dist/tools.js +71 -0
- package/package.json +13 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _jay_framework_fullstack_component from '@jay-framework/fullstack-component';
|
|
2
2
|
import { Signals } from '@jay-framework/fullstack-component';
|
|
3
3
|
import * as _google_genai from '@google/genai';
|
|
4
|
-
import { PluginSetupContext, PluginSetupResult, ActionMetadata } from '@jay-framework/stack-server-runtime';
|
|
5
4
|
import * as _jay_framework_component from '@jay-framework/component';
|
|
6
5
|
import { HTMLElementProxy } from '@jay-framework/runtime';
|
|
6
|
+
import { ActionMetadata } from '@jay-framework/stack-server-runtime';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Shared type definitions for the Gemini agent plugin.
|
|
@@ -107,14 +107,6 @@ declare class GeminiService {
|
|
|
107
107
|
declare const GEMINI_SERVICE: _jay_framework_fullstack_component.ServiceMarker<GeminiService>;
|
|
108
108
|
declare const init: _jay_framework_fullstack_component.JayInitBuilderWithServer<{}>;
|
|
109
109
|
|
|
110
|
-
/**
|
|
111
|
-
* Setup handler for gemini-agent plugin.
|
|
112
|
-
*
|
|
113
|
-
* Creates config/.gemini.yaml template if missing, validates the API key.
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
declare function setupGeminiAgent(ctx: PluginSetupContext): Promise<PluginSetupResult>;
|
|
117
|
-
|
|
118
110
|
/**
|
|
119
111
|
* Tool Description Loader — reads .jay-contract files and extracts
|
|
120
112
|
* descriptions for interactive tags.
|
|
@@ -294,4 +286,4 @@ declare function compactPageState(value: unknown): unknown;
|
|
|
294
286
|
*/
|
|
295
287
|
declare function buildSystemPrompt(pageState: object, toolSummary: string, customPrefix?: string): string;
|
|
296
288
|
|
|
297
|
-
export { DISCOVERY_TOOL, GEMINI_SERVICE, type GeminiAgentConfig, type GeminiFunctionCallPart, type GeminiFunctionDeclaration, type GeminiFunctionResponsePart, type GeminiMessage, type GeminiPart, GeminiService, type GeminiServiceConfig, type GeminiTextPart, PAGE_STATE_TOOL, type PendingToolCall, type SendMessageInput, type SendMessageOutput, type SerializedToolDef, type SubmitToolResultsInput, type SubmitToolResultsOutput, type ToolCallResult, buildSystemPrompt, buildToolSummary, compactPageState, geminiChat, getToolDescriptions, init, resolveToolCallTarget, sendMessage,
|
|
289
|
+
export { DISCOVERY_TOOL, GEMINI_SERVICE, type GeminiAgentConfig, type GeminiFunctionCallPart, type GeminiFunctionDeclaration, type GeminiFunctionResponsePart, type GeminiMessage, type GeminiPart, GeminiService, type GeminiServiceConfig, type GeminiTextPart, PAGE_STATE_TOOL, type PendingToolCall, type SendMessageInput, type SendMessageOutput, type SerializedToolDef, type SubmitToolResultsInput, type SubmitToolResultsOutput, type ToolCallResult, buildSystemPrompt, buildToolSummary, compactPageState, geminiChat, getToolDescriptions, init, resolveToolCallTarget, sendMessage, submitToolResults, toGeminiTools, toSlimGeminiTools };
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import * as yaml from "js-yaml";
|
|
|
9
9
|
import { Type, GoogleGenAI } from "@google/genai";
|
|
10
10
|
import * as fs$1 from "node:fs";
|
|
11
11
|
import * as path$1 from "node:path";
|
|
12
|
-
const CONFIG_FILE_NAME
|
|
12
|
+
const CONFIG_FILE_NAME = ".gemini.yaml";
|
|
13
13
|
const DEFAULT_MODEL = "gemini-2.0-flash";
|
|
14
14
|
function loadConfig() {
|
|
15
|
-
const configPath = path.join(process.cwd(), "config", CONFIG_FILE_NAME
|
|
15
|
+
const configPath = path.join(process.cwd(), "config", CONFIG_FILE_NAME);
|
|
16
16
|
if (!fs.existsSync(configPath)) {
|
|
17
17
|
throw new Error(
|
|
18
18
|
`Gemini config file not found at: ${configPath}
|
|
@@ -118,71 +118,6 @@ const init = makeJayInit().withServer(() => {
|
|
|
118
118
|
console.log(`[gemini-agent] Initialized (model: ${config.model})`);
|
|
119
119
|
return {};
|
|
120
120
|
});
|
|
121
|
-
const CONFIG_FILE_NAME = ".gemini.yaml";
|
|
122
|
-
const CONFIG_TEMPLATE = `# Gemini Agent Configuration
|
|
123
|
-
#
|
|
124
|
-
# This file contains credentials for the Gemini AI agent plugin.
|
|
125
|
-
# Get your API key from: https://aistudio.google.com/apikey
|
|
126
|
-
#
|
|
127
|
-
# IMPORTANT: This file contains secrets. Add config/.gemini.yaml to .gitignore.
|
|
128
|
-
|
|
129
|
-
# Required: Your Gemini API key
|
|
130
|
-
apiKey: "<your-gemini-api-key>"
|
|
131
|
-
|
|
132
|
-
# Optional: Model name (default: gemini-2.0-flash)
|
|
133
|
-
# model: gemini-2.0-flash
|
|
134
|
-
|
|
135
|
-
# Optional: Custom system prompt prefix (prepended to the generated system prompt)
|
|
136
|
-
# systemPrompt: "You are a helpful assistant for this web application."
|
|
137
|
-
`;
|
|
138
|
-
async function setupGeminiAgent(ctx) {
|
|
139
|
-
const configPath = path.join(ctx.configDir, CONFIG_FILE_NAME);
|
|
140
|
-
if (!fs.existsSync(configPath)) {
|
|
141
|
-
if (!fs.existsSync(ctx.configDir)) {
|
|
142
|
-
fs.mkdirSync(ctx.configDir, { recursive: true });
|
|
143
|
-
}
|
|
144
|
-
fs.writeFileSync(configPath, CONFIG_TEMPLATE, "utf-8");
|
|
145
|
-
return {
|
|
146
|
-
status: "needs-config",
|
|
147
|
-
configCreated: [`config/${CONFIG_FILE_NAME}`],
|
|
148
|
-
message: "Fill in your Gemini API key and re-run: jay-stack setup gemini-agent"
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
153
|
-
const config = yaml.load(configContent);
|
|
154
|
-
if (!config) {
|
|
155
|
-
return {
|
|
156
|
-
status: "error",
|
|
157
|
-
message: `Config file is empty: config/${CONFIG_FILE_NAME}`
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
const apiKey = config.apiKey || "";
|
|
161
|
-
const hasPlaceholder = apiKey.startsWith("<");
|
|
162
|
-
const isEmpty = !apiKey;
|
|
163
|
-
if (hasPlaceholder || isEmpty) {
|
|
164
|
-
return {
|
|
165
|
-
status: "needs-config",
|
|
166
|
-
message: `Config has placeholder value. Set your Gemini API key in config/${CONFIG_FILE_NAME}`
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
if (ctx.initError) {
|
|
170
|
-
return {
|
|
171
|
-
status: "error",
|
|
172
|
-
message: `Gemini initialization failed: ${ctx.initError.message}`
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
return {
|
|
176
|
-
status: "configured",
|
|
177
|
-
message: `Gemini agent configured (model: ${config.model || "gemini-2.0-flash"})`
|
|
178
|
-
};
|
|
179
|
-
} catch (error) {
|
|
180
|
-
return {
|
|
181
|
-
status: "error",
|
|
182
|
-
message: `Failed to read config: ${error.message}`
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
121
|
const defaultLogger = {
|
|
187
122
|
important: (msg, ...args) => console.log(msg, ...args),
|
|
188
123
|
info: (msg, ...args) => console.log(msg, ...args),
|
|
@@ -648,7 +583,6 @@ export {
|
|
|
648
583
|
init,
|
|
649
584
|
resolveToolCallTarget,
|
|
650
585
|
sendMessage,
|
|
651
|
-
setupGeminiAgent,
|
|
652
586
|
submitToolResults,
|
|
653
587
|
toGeminiTools,
|
|
654
588
|
toSlimGeminiTools
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PluginSetupContext, PluginSetupResult } from '@jay-framework/stack-server-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Setup handler for gemini-agent plugin.
|
|
5
|
+
*
|
|
6
|
+
* Creates config/.gemini.yaml template if missing, validates the API key.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare function setupGeminiAgent(ctx: PluginSetupContext): Promise<PluginSetupResult>;
|
|
10
|
+
|
|
11
|
+
export { setupGeminiAgent };
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as yaml from "js-yaml";
|
|
4
|
+
const CONFIG_FILE_NAME = ".gemini.yaml";
|
|
5
|
+
const CONFIG_TEMPLATE = `# Gemini Agent Configuration
|
|
6
|
+
#
|
|
7
|
+
# This file contains credentials for the Gemini AI agent plugin.
|
|
8
|
+
# Get your API key from: https://aistudio.google.com/apikey
|
|
9
|
+
#
|
|
10
|
+
# IMPORTANT: This file contains secrets. Add config/.gemini.yaml to .gitignore.
|
|
11
|
+
|
|
12
|
+
# Required: Your Gemini API key
|
|
13
|
+
apiKey: "<your-gemini-api-key>"
|
|
14
|
+
|
|
15
|
+
# Optional: Model name (default: gemini-2.0-flash)
|
|
16
|
+
# model: gemini-2.0-flash
|
|
17
|
+
|
|
18
|
+
# Optional: Custom system prompt prefix (prepended to the generated system prompt)
|
|
19
|
+
# systemPrompt: "You are a helpful assistant for this web application."
|
|
20
|
+
`;
|
|
21
|
+
async function setupGeminiAgent(ctx) {
|
|
22
|
+
const configPath = path.join(ctx.configDir, CONFIG_FILE_NAME);
|
|
23
|
+
if (!fs.existsSync(configPath)) {
|
|
24
|
+
if (!fs.existsSync(ctx.configDir)) {
|
|
25
|
+
fs.mkdirSync(ctx.configDir, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
fs.writeFileSync(configPath, CONFIG_TEMPLATE, "utf-8");
|
|
28
|
+
return {
|
|
29
|
+
status: "needs-config",
|
|
30
|
+
configCreated: [`config/${CONFIG_FILE_NAME}`],
|
|
31
|
+
message: "Fill in your Gemini API key and re-run: jay-stack setup gemini-agent"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
36
|
+
const config = yaml.load(configContent);
|
|
37
|
+
if (!config) {
|
|
38
|
+
return {
|
|
39
|
+
status: "error",
|
|
40
|
+
message: `Config file is empty: config/${CONFIG_FILE_NAME}`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const apiKey = config.apiKey || "";
|
|
44
|
+
const hasPlaceholder = apiKey.startsWith("<");
|
|
45
|
+
const isEmpty = !apiKey;
|
|
46
|
+
if (hasPlaceholder || isEmpty) {
|
|
47
|
+
return {
|
|
48
|
+
status: "needs-config",
|
|
49
|
+
message: `Config has placeholder value. Set your Gemini API key in config/${CONFIG_FILE_NAME}`
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (ctx.initError) {
|
|
53
|
+
return {
|
|
54
|
+
status: "error",
|
|
55
|
+
message: `Gemini initialization failed: ${ctx.initError.message}`
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
status: "configured",
|
|
60
|
+
message: `Gemini agent configured (model: ${config.model || "gemini-2.0-flash"})`
|
|
61
|
+
};
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return {
|
|
64
|
+
status: "error",
|
|
65
|
+
message: `Failed to read config: ${error.message}`
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
setupGeminiAgent
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/gemini-agent-plugin",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Gemini AI agent plugin for jay-stack — embedded chat agent with page automation and server action calling",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": "./dist/index.js",
|
|
11
11
|
"./client": "./dist/index.client.js",
|
|
12
|
+
"./tools": "./dist/tools.js",
|
|
12
13
|
"./gemini-chat.jay-contract": "./dist/contracts/gemini-chat.jay-contract",
|
|
13
14
|
"./send-message.jay-action": "./dist/actions/send-message.jay-action",
|
|
14
15
|
"./submit-tool-results.jay-action": "./dist/actions/submit-tool-results.jay-action",
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"build:client": "vite build",
|
|
24
25
|
"build:server": "vite build --ssr",
|
|
25
26
|
"build:copy-contract": "mkdir -p dist/contracts && cp lib/contracts/*.jay-contract* dist/contracts/ && mkdir -p dist/actions && cp lib/actions/*.jay-action dist/actions/",
|
|
26
|
-
"build:types": "tsup lib/index.ts --dts-only --format esm",
|
|
27
|
+
"build:types": "tsup lib/index.ts lib/tools.ts --dts-only --format esm",
|
|
27
28
|
"build:check-types": "tsc",
|
|
28
29
|
"definitions": "jay-cli definitions lib",
|
|
29
30
|
"clean": "rimraf dist",
|
|
@@ -33,19 +34,19 @@
|
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@google/genai": "^0.14.0",
|
|
36
|
-
"@jay-framework/component": "^0.24.
|
|
37
|
-
"@jay-framework/fullstack-component": "^0.24.
|
|
38
|
-
"@jay-framework/logger": "^0.24.
|
|
39
|
-
"@jay-framework/runtime": "^0.24.
|
|
40
|
-
"@jay-framework/runtime-automation": "^0.24.
|
|
41
|
-
"@jay-framework/stack-client-runtime": "^0.24.
|
|
42
|
-
"@jay-framework/stack-server-runtime": "^0.24.
|
|
37
|
+
"@jay-framework/component": "^0.24.3",
|
|
38
|
+
"@jay-framework/fullstack-component": "^0.24.3",
|
|
39
|
+
"@jay-framework/logger": "^0.24.3",
|
|
40
|
+
"@jay-framework/runtime": "^0.24.3",
|
|
41
|
+
"@jay-framework/runtime-automation": "^0.24.3",
|
|
42
|
+
"@jay-framework/stack-client-runtime": "^0.24.3",
|
|
43
|
+
"@jay-framework/stack-server-runtime": "^0.24.3",
|
|
43
44
|
"js-yaml": "^4.1.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@jay-framework/compiler-jay-stack": "^0.24.
|
|
47
|
-
"@jay-framework/dev-environment": "^0.24.
|
|
48
|
-
"@jay-framework/jay-cli": "^0.24.
|
|
47
|
+
"@jay-framework/compiler-jay-stack": "^0.24.3",
|
|
48
|
+
"@jay-framework/dev-environment": "^0.24.3",
|
|
49
|
+
"@jay-framework/jay-cli": "^0.24.3",
|
|
49
50
|
"@types/js-yaml": "^4.0.9",
|
|
50
51
|
"@types/node": "^22.15.21",
|
|
51
52
|
"rimraf": "^5.0.5",
|