tachibot-mcp 2.0.2
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/.env.example +260 -0
- package/CHANGELOG.md +54 -0
- package/CODE_OF_CONDUCT.md +56 -0
- package/CONTRIBUTING.md +54 -0
- package/Dockerfile +36 -0
- package/LICENSE +644 -0
- package/README.md +201 -0
- package/SECURITY.md +95 -0
- package/dist/personality/komaai-expressions.js +12 -0
- package/dist/profiles/balanced.json +33 -0
- package/dist/profiles/code_focus.json +33 -0
- package/dist/profiles/full.json +33 -0
- package/dist/profiles/minimal.json +33 -0
- package/dist/profiles/research_power.json +33 -0
- package/dist/scripts/build-profiles.js +46 -0
- package/dist/src/application/services/focus/FocusModeRegistry.js +46 -0
- package/dist/src/application/services/focus/FocusTool.service.js +109 -0
- package/dist/src/application/services/focus/ModeRegistry.js +46 -0
- package/dist/src/application/services/focus/modes/focus-deep.mode.js +27 -0
- package/dist/src/application/services/focus/modes/status.mode.js +50 -0
- package/dist/src/application/services/focus/modes/tachibot-status.mode.js +50 -0
- package/dist/src/collaborative-orchestrator.js +391 -0
- package/dist/src/config/model-constants.js +188 -0
- package/dist/src/config/model-defaults.js +57 -0
- package/dist/src/config/model-preferences.js +382 -0
- package/dist/src/config/timeout-config.js +130 -0
- package/dist/src/config.js +173 -0
- package/dist/src/domain/interfaces/IFocusMode.js +5 -0
- package/dist/src/domain/interfaces/IProvider.js +6 -0
- package/dist/src/domain/interfaces/ITool.js +5 -0
- package/dist/src/focus-deep.js +245 -0
- package/dist/src/infrastructure/ascii/art/robots.ascii.js +16 -0
- package/dist/src/mcp-client.js +90 -0
- package/dist/src/memory/index.js +17 -0
- package/dist/src/memory/memory-config.js +135 -0
- package/dist/src/memory/memory-interface.js +174 -0
- package/dist/src/memory/memory-manager.js +383 -0
- package/dist/src/memory/providers/devlog-provider.js +385 -0
- package/dist/src/memory/providers/hybrid-provider.js +399 -0
- package/dist/src/memory/providers/local-provider.js +388 -0
- package/dist/src/memory/providers/mem0-provider.js +337 -0
- package/dist/src/modes/architect.js +477 -0
- package/dist/src/modes/auditor.js +362 -0
- package/dist/src/modes/challenger.js +841 -0
- package/dist/src/modes/code-reviewer.js +382 -0
- package/dist/src/modes/commit-guardian.js +424 -0
- package/dist/src/modes/documentation-writer.js +572 -0
- package/dist/src/modes/scout.js +587 -0
- package/dist/src/modes/shared/helpers/challenger-helpers.js +454 -0
- package/dist/src/modes/shared/helpers/index.js +17 -0
- package/dist/src/modes/shared/helpers/scout-helpers.js +270 -0
- package/dist/src/modes/shared/helpers/verifier-helpers.js +332 -0
- package/dist/src/modes/test-architect.js +767 -0
- package/dist/src/modes/verifier.js +378 -0
- package/dist/src/monitoring/performance-monitor.js +435 -0
- package/dist/src/optimization/batch-executor.js +121 -0
- package/dist/src/optimization/context-pruner.js +196 -0
- package/dist/src/optimization/cost-monitor.js +338 -0
- package/dist/src/optimization/index.js +65 -0
- package/dist/src/optimization/model-router.js +264 -0
- package/dist/src/optimization/result-cache.js +114 -0
- package/dist/src/optimization/token-optimizer.js +257 -0
- package/dist/src/optimization/token-tracker.js +118 -0
- package/dist/src/orchestrator-instructions.js +128 -0
- package/dist/src/orchestrator-lite.js +139 -0
- package/dist/src/orchestrator.js +191 -0
- package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionEngine.js +1 -0
- package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionStrategy.js +5 -0
- package/dist/src/orchestrators/collaborative/interfaces/IVisualizationRenderer.js +1 -0
- package/dist/src/orchestrators/collaborative/registries/ModelProviderRegistry.js +95 -0
- package/dist/src/orchestrators/collaborative/registries/ToolAdapterRegistry.js +64 -0
- package/dist/src/orchestrators/collaborative/services/tool-execution/ToolExecutionService.js +502 -0
- package/dist/src/orchestrators/collaborative/services/visualization/VisualizationService.js +206 -0
- package/dist/src/orchestrators/collaborative/types/session-types.js +5 -0
- package/dist/src/profiles/balanced.js +37 -0
- package/dist/src/profiles/code_focus.js +37 -0
- package/dist/src/profiles/debug_intensive.js +59 -0
- package/dist/src/profiles/full.js +37 -0
- package/dist/src/profiles/minimal.js +37 -0
- package/dist/src/profiles/research_code.js +59 -0
- package/dist/src/profiles/research_power.js +37 -0
- package/dist/src/profiles/types.js +5 -0
- package/dist/src/profiles/workflow_builder.js +53 -0
- package/dist/src/prompt-engineer-lite.js +78 -0
- package/dist/src/prompt-engineer.js +399 -0
- package/dist/src/reasoning-chain.js +508 -0
- package/dist/src/sequential-thinking.js +291 -0
- package/dist/src/server-diagnostic.js +74 -0
- package/dist/src/server-raw.js +158 -0
- package/dist/src/server-simple.js +58 -0
- package/dist/src/server.js +514 -0
- package/dist/src/session/session-logger.js +617 -0
- package/dist/src/session/session-manager.js +571 -0
- package/dist/src/session/session-tools.js +400 -0
- package/dist/src/tools/advanced-modes.js +200 -0
- package/dist/src/tools/claude-integration.js +356 -0
- package/dist/src/tools/consolidated/ai-router.js +174 -0
- package/dist/src/tools/consolidated/ai-tool.js +48 -0
- package/dist/src/tools/consolidated/brainstorm-tool.js +87 -0
- package/dist/src/tools/consolidated/environment-detector.js +80 -0
- package/dist/src/tools/consolidated/index.js +50 -0
- package/dist/src/tools/consolidated/search-tool.js +110 -0
- package/dist/src/tools/consolidated/workflow-tool.js +238 -0
- package/dist/src/tools/gemini-tools.js +329 -0
- package/dist/src/tools/grok-enhanced.js +376 -0
- package/dist/src/tools/grok-tools.js +299 -0
- package/dist/src/tools/lmstudio-tools.js +223 -0
- package/dist/src/tools/openai-tools.js +498 -0
- package/dist/src/tools/openrouter-tools.js +317 -0
- package/dist/src/tools/optimized-wrapper.js +204 -0
- package/dist/src/tools/perplexity-tools.js +294 -0
- package/dist/src/tools/pingpong-tool.js +343 -0
- package/dist/src/tools/qwen-wrapper.js +74 -0
- package/dist/src/tools/tool-router.js +444 -0
- package/dist/src/tools/unified-ai-provider.js +260 -0
- package/dist/src/tools/workflow-runner.js +425 -0
- package/dist/src/tools/workflow-validator-tool.js +107 -0
- package/dist/src/types.js +23 -0
- package/dist/src/utils/input-validator.js +130 -0
- package/dist/src/utils/model-router.js +91 -0
- package/dist/src/utils/progress-stream.js +255 -0
- package/dist/src/utils/provider-router.js +88 -0
- package/dist/src/utils/smart-api-client.js +146 -0
- package/dist/src/utils/table-builder.js +218 -0
- package/dist/src/utils/timestamp-formatter.js +134 -0
- package/dist/src/utils/tool-compressor.js +257 -0
- package/dist/src/utils/tool-config.js +201 -0
- package/dist/src/validators/dependency-graph-validator.js +147 -0
- package/dist/src/validators/interpolation-validator.js +222 -0
- package/dist/src/validators/output-usage-validator.js +151 -0
- package/dist/src/validators/syntax-validator.js +102 -0
- package/dist/src/validators/tool-registry-validator.js +123 -0
- package/dist/src/validators/tool-types.js +97 -0
- package/dist/src/validators/types.js +8 -0
- package/dist/src/validators/workflow-validator.js +134 -0
- package/dist/src/visualizer-lite.js +42 -0
- package/dist/src/visualizer.js +179 -0
- package/dist/src/workflows/circuit-breaker.js +199 -0
- package/dist/src/workflows/custom-workflows.js +451 -0
- package/dist/src/workflows/engine/AutoSynthesizer.js +97 -0
- package/dist/src/workflows/engine/StepParameterResolver.js +74 -0
- package/dist/src/workflows/engine/VariableInterpolator.js +123 -0
- package/dist/src/workflows/engine/WorkflowDiscovery.js +125 -0
- package/dist/src/workflows/engine/WorkflowExecutionEngine.js +485 -0
- package/dist/src/workflows/engine/WorkflowExecutor.js +113 -0
- package/dist/src/workflows/engine/WorkflowFileManager.js +244 -0
- package/dist/src/workflows/engine/WorkflowHelpers.js +114 -0
- package/dist/src/workflows/engine/WorkflowOutputFormatter.js +83 -0
- package/dist/src/workflows/engine/events/WorkflowEventBus.js +132 -0
- package/dist/src/workflows/engine/events/interfaces/IEventBus.js +5 -0
- package/dist/src/workflows/engine/handlers/ErrorRecoveryHandler.js +162 -0
- package/dist/src/workflows/engine/handlers/PromptEnhancementHandler.js +115 -0
- package/dist/src/workflows/engine/handlers/SessionPersistenceHandler.js +167 -0
- package/dist/src/workflows/engine/handlers/StepExecutionHandler.js +231 -0
- package/dist/src/workflows/engine/handlers/ToolInvocationHandler.js +46 -0
- package/dist/src/workflows/engine/interfaces/IAutoSynthesizer.js +5 -0
- package/dist/src/workflows/engine/interfaces/IStepParameterResolver.js +5 -0
- package/dist/src/workflows/engine/interfaces/IVariableInterpolator.js +5 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowDiscovery.js +4 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowFileManager.js +5 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowOutputFormatter.js +5 -0
- package/dist/src/workflows/engine/state/WorkflowStateMachine.js +194 -0
- package/dist/src/workflows/engine/state/interfaces/IStateMachine.js +17 -0
- package/dist/src/workflows/fallback-strategies.js +373 -0
- package/dist/src/workflows/message-queue.js +455 -0
- package/dist/src/workflows/model-router.js +189 -0
- package/dist/src/workflows/orchestrator-examples.js +174 -0
- package/dist/src/workflows/orchestrator-integration.js +200 -0
- package/dist/src/workflows/self-healing.js +524 -0
- package/dist/src/workflows/tool-mapper.js +407 -0
- package/dist/src/workflows/tool-orchestrator.js +796 -0
- package/dist/src/workflows/workflow-engine.js +573 -0
- package/dist/src/workflows/workflow-parser.js +283 -0
- package/dist/src/workflows/workflow-types.js +95 -0
- package/dist/src/workflows.js +568 -0
- package/dist/test-workflow-file-output.js +93 -0
- package/docs/API_KEYS.md +570 -0
- package/docs/CLAUDE_CODE_SETUP.md +181 -0
- package/docs/CLAUDE_DESKTOP_MANUAL.md +127 -0
- package/docs/CONFIGURATION.md +745 -0
- package/docs/FOCUS_MODES.md +240 -0
- package/docs/INSTALLATION_BOTH.md +145 -0
- package/docs/TERMS.md +352 -0
- package/docs/TOOLS_REFERENCE.md +1622 -0
- package/docs/TOOL_PARAMETERS.md +496 -0
- package/docs/TOOL_PROFILES.md +236 -0
- package/docs/WORKFLOWS.md +987 -0
- package/docs/WORKFLOW_OUTPUT.md +198 -0
- package/docs/WORKFLOW_PROGRESS_TRACKING.md +305 -0
- package/docs/workflows/design-brainstorm.md +335 -0
- package/package.json +97 -0
- package/profiles/balanced.json +37 -0
- package/profiles/code_focus.json +37 -0
- package/profiles/debug_intensive.json +34 -0
- package/profiles/full.json +37 -0
- package/profiles/minimal.json +37 -0
- package/profiles/research_power.json +37 -0
- package/profiles/workflow_builder.json +37 -0
- package/smithery.yaml +66 -0
- package/start.sh +8 -0
- package/tools.config.json +81 -0
- package/tsconfig.json +18 -0
- package/workflows/accessibility-code-audit.yaml +92 -0
- package/workflows/code-architecture-review.yaml +202 -0
- package/workflows/code-review.yaml +142 -0
- package/workflows/core/iterative-problem-solver.yaml +283 -0
- package/workflows/creative-brainstorm-yaml.yaml +215 -0
- package/workflows/pingpong.yaml +141 -0
- package/workflows/system/README.md +412 -0
- package/workflows/system/challenger.yaml +175 -0
- package/workflows/system/scout.yaml +164 -0
- package/workflows/system/verifier.yaml +133 -0
- package/workflows/ultra-creative-brainstorm.yaml +318 -0
- package/workflows/ux-research-flow.yaml +92 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini Tools Implementation
|
|
3
|
+
* Provides all Gemini capabilities directly in tachibot-mcp
|
|
4
|
+
* No need for separate gemini-mcp server
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { validateToolInput } from "../utils/input-validator.js";
|
|
8
|
+
// NOTE: dotenv is loaded in server.ts before any imports
|
|
9
|
+
// No need to reload here - just read from process.env
|
|
10
|
+
// Gemini API configuration
|
|
11
|
+
const GEMINI_API_KEY = process.env.GOOGLE_API_KEY || process.env.GEMINI_API_KEY;
|
|
12
|
+
const GEMINI_API_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
13
|
+
// Available Gemini models (2025 - Latest)
|
|
14
|
+
export var GeminiModel;
|
|
15
|
+
(function (GeminiModel) {
|
|
16
|
+
// Primary models (Gemini 2.5 - preferred)
|
|
17
|
+
GeminiModel["FLASH"] = "gemini-2.5-flash";
|
|
18
|
+
GeminiModel["PRO"] = "gemini-2.5-pro";
|
|
19
|
+
GeminiModel["FLASH_LITE"] = "gemini-2.5-flash-lite";
|
|
20
|
+
})(GeminiModel || (GeminiModel = {}));
|
|
21
|
+
/**
|
|
22
|
+
* Call Gemini API directly
|
|
23
|
+
*/
|
|
24
|
+
export async function callGemini(prompt, model = GeminiModel.PRO, systemPrompt, temperature = 0.7, skipValidation = false) {
|
|
25
|
+
if (!GEMINI_API_KEY) {
|
|
26
|
+
return `[Gemini API key not configured. Add GOOGLE_API_KEY to .env file]`;
|
|
27
|
+
}
|
|
28
|
+
// Validate and sanitize prompt (skip for internal workflow calls)
|
|
29
|
+
let sanitizedPrompt = prompt;
|
|
30
|
+
if (!skipValidation) {
|
|
31
|
+
const promptValidation = validateToolInput(prompt);
|
|
32
|
+
if (!promptValidation.valid) {
|
|
33
|
+
return `[Error: ${promptValidation.error}]`;
|
|
34
|
+
}
|
|
35
|
+
sanitizedPrompt = promptValidation.sanitized;
|
|
36
|
+
}
|
|
37
|
+
// Validate and sanitize system prompt if provided
|
|
38
|
+
let sanitizedSystemPrompt = systemPrompt;
|
|
39
|
+
if (systemPrompt && !skipValidation) {
|
|
40
|
+
const systemValidation = validateToolInput(systemPrompt);
|
|
41
|
+
if (!systemValidation.valid) {
|
|
42
|
+
return `[Error: ${systemValidation.error}]`;
|
|
43
|
+
}
|
|
44
|
+
sanitizedSystemPrompt = systemValidation.sanitized;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const url = `${GEMINI_API_URL}/models/${model}:generateContent?key=${GEMINI_API_KEY}`;
|
|
48
|
+
const requestBody = {
|
|
49
|
+
contents: [
|
|
50
|
+
{
|
|
51
|
+
parts: [
|
|
52
|
+
{
|
|
53
|
+
text: sanitizedSystemPrompt
|
|
54
|
+
? `${sanitizedSystemPrompt}\n\nUser request: ${sanitizedPrompt}\n\nProvide your complete response as visible text:`
|
|
55
|
+
: `${sanitizedPrompt}\n\nProvide a complete, detailed response as visible text:`
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
generationConfig: {
|
|
61
|
+
temperature,
|
|
62
|
+
maxOutputTokens: 49152, // 48k - compromise between quality and cost (max is 65k)
|
|
63
|
+
candidateCount: 1,
|
|
64
|
+
topK: 40,
|
|
65
|
+
topP: 0.95,
|
|
66
|
+
stopSequences: []
|
|
67
|
+
},
|
|
68
|
+
// Configure safety settings to prevent false positives on technical content
|
|
69
|
+
// BLOCK_ONLY_HIGH allows code blocks, technical terms, and LLM-to-LLM content
|
|
70
|
+
safetySettings: [
|
|
71
|
+
{
|
|
72
|
+
category: "HARM_CATEGORY_HARASSMENT",
|
|
73
|
+
threshold: "BLOCK_ONLY_HIGH"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
category: "HARM_CATEGORY_HATE_SPEECH",
|
|
77
|
+
threshold: "BLOCK_ONLY_HIGH"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
81
|
+
threshold: "BLOCK_ONLY_HIGH"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
category: "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
85
|
+
threshold: "BLOCK_ONLY_HIGH"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
const response = await fetch(url, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
},
|
|
94
|
+
body: JSON.stringify(requestBody)
|
|
95
|
+
});
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
throw new Error(`Gemini API error: ${response.statusText}`);
|
|
98
|
+
}
|
|
99
|
+
const data = await response.json();
|
|
100
|
+
// Debug logging for response structure
|
|
101
|
+
if (!data.candidates?.[0]?.content?.parts?.[0]?.text) {
|
|
102
|
+
console.warn('Gemini response missing text:', JSON.stringify(data, null, 2).substring(0, 500));
|
|
103
|
+
}
|
|
104
|
+
// Check for safety blocking BEFORE trying to extract text
|
|
105
|
+
const candidate = data.candidates?.[0];
|
|
106
|
+
if (candidate?.finishReason === 'SAFETY') {
|
|
107
|
+
const safetyRatings = candidate.safetyRatings || [];
|
|
108
|
+
const blockedCategories = safetyRatings
|
|
109
|
+
.filter((r) => r.probability === 'HIGH' || r.probability === 'MEDIUM')
|
|
110
|
+
.map((r) => r.category.replace('HARM_CATEGORY_', ''))
|
|
111
|
+
.join(', ');
|
|
112
|
+
return `[Gemini blocked response due to safety filters: ${blockedCategories || 'SAFETY'}. This is likely a false positive with technical content. The safety settings have been configured to BLOCK_ONLY_HIGH, but Gemini may still flag certain patterns. Try rephrasing the prompt or removing potentially sensitive keywords.]`;
|
|
113
|
+
}
|
|
114
|
+
// Handle different response structures
|
|
115
|
+
const text = candidate?.content?.parts?.[0]?.text;
|
|
116
|
+
// Extract and log token usage for cost tracking
|
|
117
|
+
const usage = data.usageMetadata;
|
|
118
|
+
if (usage) {
|
|
119
|
+
const promptTokens = usage.promptTokenCount || 0;
|
|
120
|
+
const outputTokens = usage.candidatesTokenCount || 0;
|
|
121
|
+
const totalTokens = usage.totalTokenCount || 0;
|
|
122
|
+
const thinkingTokens = usage.thoughtsTokenCount || 0;
|
|
123
|
+
console.error(`📊 Gemini tokens: ${promptTokens} input, ${outputTokens} output${thinkingTokens > 0 ? `, ${thinkingTokens} thinking` : ''}, ${totalTokens} total`);
|
|
124
|
+
}
|
|
125
|
+
if (!text) {
|
|
126
|
+
// Check if Gemini used only thinking tokens
|
|
127
|
+
if (data.usageMetadata?.thoughtsTokenCount > 0 && !text) {
|
|
128
|
+
return "[Gemini used thinking tokens but produced no output. Try a more specific prompt.]";
|
|
129
|
+
}
|
|
130
|
+
return "No response from Gemini";
|
|
131
|
+
}
|
|
132
|
+
return text;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return `[Gemini error: ${error instanceof Error ? error.message : String(error)}]`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Gemini Query Tool
|
|
140
|
+
* Direct querying of Gemini models for general information
|
|
141
|
+
*/
|
|
142
|
+
export const geminiQueryTool = {
|
|
143
|
+
name: "gemini_query",
|
|
144
|
+
description: "Query Gemini",
|
|
145
|
+
parameters: z.object({
|
|
146
|
+
prompt: z.string(),
|
|
147
|
+
model: z.enum(["pro", "flash"]).optional().default("pro")
|
|
148
|
+
}),
|
|
149
|
+
execute: async (args, { log }) => {
|
|
150
|
+
const model = args.model === "flash" ? GeminiModel.FLASH : GeminiModel.PRO;
|
|
151
|
+
return await callGemini(args.prompt, model);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Gemini Brainstorm Tool
|
|
156
|
+
* Collaborative problem-solving and ideation
|
|
157
|
+
*/
|
|
158
|
+
export const geminiBrainstormTool = {
|
|
159
|
+
name: "gemini_brainstorm",
|
|
160
|
+
description: "Brainstorming",
|
|
161
|
+
parameters: z.object({
|
|
162
|
+
prompt: z.string(),
|
|
163
|
+
claudeThoughts: z.string().optional(),
|
|
164
|
+
maxRounds: z.number().optional().default(1)
|
|
165
|
+
}),
|
|
166
|
+
execute: async (args, { log }) => {
|
|
167
|
+
const systemPrompt = `You are a creative brainstorming partner. Generate innovative ideas and solutions.
|
|
168
|
+
${args.claudeThoughts ? `\nBuilding on these initial thoughts: ${args.claudeThoughts}` : ''}
|
|
169
|
+
|
|
170
|
+
IMPORTANT: Output a detailed written response with:
|
|
171
|
+
1. Multiple creative approaches (at least 3)
|
|
172
|
+
2. Unconventional or "out of the box" ideas
|
|
173
|
+
3. Potential challenges for each approach
|
|
174
|
+
4. Quick feasibility assessment
|
|
175
|
+
|
|
176
|
+
Provide your complete analysis as visible text output.`;
|
|
177
|
+
const response = await callGemini(args.prompt, GeminiModel.PRO, systemPrompt, 0.9);
|
|
178
|
+
// If multiple rounds requested, we could iterate here
|
|
179
|
+
// For now, return the single response
|
|
180
|
+
return response;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Gemini Analyze Code Tool
|
|
185
|
+
* Code quality and performance analysis
|
|
186
|
+
*/
|
|
187
|
+
export const geminiAnalyzeCodeTool = {
|
|
188
|
+
name: "gemini_analyze_code",
|
|
189
|
+
description: "Code analysis",
|
|
190
|
+
parameters: z.object({
|
|
191
|
+
code: z.string(),
|
|
192
|
+
language: z.string().optional(),
|
|
193
|
+
focus: z.enum(["quality", "security", "performance", "bugs", "general"]).optional().default("general")
|
|
194
|
+
}),
|
|
195
|
+
execute: async (args, { log }) => {
|
|
196
|
+
const focusPrompts = {
|
|
197
|
+
quality: "Focus on code quality, readability, and best practices",
|
|
198
|
+
security: "Focus on security vulnerabilities and potential exploits",
|
|
199
|
+
performance: "Focus on performance bottlenecks and optimization opportunities",
|
|
200
|
+
bugs: "Focus on finding bugs, logic errors, and edge cases",
|
|
201
|
+
general: "Provide a comprehensive analysis covering all aspects"
|
|
202
|
+
};
|
|
203
|
+
const systemPrompt = `You are an expert code reviewer. Analyze the following ${args.language || ''} code.
|
|
204
|
+
${focusPrompts[args.focus || 'general']}.
|
|
205
|
+
|
|
206
|
+
Provide:
|
|
207
|
+
1. Summary of what the code does
|
|
208
|
+
2. ${args.focus === 'security' ? 'Security vulnerabilities' : 'Issues found'}
|
|
209
|
+
3. Specific recommendations for improvement
|
|
210
|
+
4. Code quality score (1-10) with justification`;
|
|
211
|
+
return await callGemini(`Analyze this code:\n\n\`\`\`${args.language || ''}\n${args.code}\n\`\`\``, GeminiModel.PRO, systemPrompt, 0.3);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Gemini Analyze Text Tool
|
|
216
|
+
* Text analysis and sentiment detection
|
|
217
|
+
*/
|
|
218
|
+
export const geminiAnalyzeTextTool = {
|
|
219
|
+
name: "gemini_analyze_text",
|
|
220
|
+
description: "Text analysis",
|
|
221
|
+
parameters: z.object({
|
|
222
|
+
text: z.string(),
|
|
223
|
+
type: z.enum(["sentiment", "summary", "entities", "key-points", "general"]).optional().default("general")
|
|
224
|
+
}),
|
|
225
|
+
execute: async (args, { log }) => {
|
|
226
|
+
const analysisPrompts = {
|
|
227
|
+
sentiment: "Analyze the sentiment (positive, negative, neutral) with confidence scores",
|
|
228
|
+
summary: "Provide a concise summary of the main points",
|
|
229
|
+
entities: "Extract all named entities (people, places, organizations, etc.)",
|
|
230
|
+
"key-points": "Identify and list the key points and main arguments",
|
|
231
|
+
general: "Provide comprehensive text analysis including sentiment, key points, and entities"
|
|
232
|
+
};
|
|
233
|
+
const systemPrompt = `You are a text analysis expert. ${analysisPrompts[args.type || 'general']}.
|
|
234
|
+
|
|
235
|
+
Format your response clearly with:
|
|
236
|
+
${args.type === 'sentiment' ? '- Overall sentiment\n- Confidence score\n- Emotional indicators' : ''}
|
|
237
|
+
${args.type === 'entities' ? '- People\n- Organizations\n- Locations\n- Other entities' : ''}
|
|
238
|
+
${args.type === 'key-points' ? '- Main arguments\n- Supporting points\n- Conclusions' : ''}`;
|
|
239
|
+
return await callGemini(`Analyze this text:\n\n${args.text}`, GeminiModel.PRO, systemPrompt, 0.3);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Gemini Summarize Tool
|
|
244
|
+
* Content summarization at different levels
|
|
245
|
+
*/
|
|
246
|
+
export const geminiSummarizeTool = {
|
|
247
|
+
name: "gemini_summarize",
|
|
248
|
+
description: "Summarization",
|
|
249
|
+
parameters: z.object({
|
|
250
|
+
content: z.string(),
|
|
251
|
+
length: z.enum(["brief", "moderate", "detailed"]).optional().default("moderate"),
|
|
252
|
+
format: z.enum(["paragraph", "bullet-points", "outline"]).optional().default("paragraph")
|
|
253
|
+
}),
|
|
254
|
+
execute: async (args, { log }) => {
|
|
255
|
+
const lengthGuides = {
|
|
256
|
+
brief: "1-2 sentences capturing the essence",
|
|
257
|
+
moderate: "1-2 paragraphs with main points",
|
|
258
|
+
detailed: "Comprehensive summary preserving important details"
|
|
259
|
+
};
|
|
260
|
+
const formatGuides = {
|
|
261
|
+
paragraph: "Write in paragraph form",
|
|
262
|
+
"bullet-points": "Use bullet points for each main idea",
|
|
263
|
+
outline: "Create a hierarchical outline structure"
|
|
264
|
+
};
|
|
265
|
+
const systemPrompt = `Create a ${args.length} summary. ${lengthGuides[args.length || 'moderate']}.
|
|
266
|
+
${formatGuides[args.format || 'paragraph']}.
|
|
267
|
+
|
|
268
|
+
Focus on:
|
|
269
|
+
- Main ideas and key arguments
|
|
270
|
+
- Important facts and figures
|
|
271
|
+
- Conclusions and implications`;
|
|
272
|
+
return await callGemini(`Summarize this content:\n\n${args.content}`, GeminiModel.PRO, systemPrompt, 0.3);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Gemini Image Prompt Tool
|
|
277
|
+
* Create detailed prompts for image generation
|
|
278
|
+
*/
|
|
279
|
+
export const geminiImagePromptTool = {
|
|
280
|
+
name: "gemini_image_prompt",
|
|
281
|
+
description: "Image prompt generation",
|
|
282
|
+
parameters: z.object({
|
|
283
|
+
description: z.string(),
|
|
284
|
+
style: z.string().optional(),
|
|
285
|
+
mood: z.string().optional(),
|
|
286
|
+
details: z.string().optional()
|
|
287
|
+
}),
|
|
288
|
+
execute: async (args, { log }) => {
|
|
289
|
+
const systemPrompt = `You are an expert at creating detailed image generation prompts.
|
|
290
|
+
Transform the user's description into a detailed, effective prompt for image generation.
|
|
291
|
+
|
|
292
|
+
Include:
|
|
293
|
+
1. Clear subject description
|
|
294
|
+
2. Artistic style and technique
|
|
295
|
+
3. Lighting and atmosphere
|
|
296
|
+
4. Composition and perspective
|
|
297
|
+
5. Color palette
|
|
298
|
+
6. Additional details for richness
|
|
299
|
+
|
|
300
|
+
Make it specific and visually descriptive.`;
|
|
301
|
+
const userPrompt = `Create an image prompt for: ${args.description}
|
|
302
|
+
${args.style ? `Style: ${args.style}` : ''}
|
|
303
|
+
${args.mood ? `Mood: ${args.mood}` : ''}
|
|
304
|
+
${args.details ? `Additional details: ${args.details}` : ''}`;
|
|
305
|
+
return await callGemini(userPrompt, GeminiModel.PRO, systemPrompt, 0.7);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Check if Gemini is available
|
|
310
|
+
*/
|
|
311
|
+
export function isGeminiAvailable() {
|
|
312
|
+
return !!GEMINI_API_KEY;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Get all Gemini tools
|
|
316
|
+
*/
|
|
317
|
+
export function getAllGeminiTools() {
|
|
318
|
+
if (!isGeminiAvailable()) {
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
return [
|
|
322
|
+
geminiQueryTool,
|
|
323
|
+
geminiBrainstormTool,
|
|
324
|
+
geminiAnalyzeCodeTool,
|
|
325
|
+
geminiAnalyzeTextTool,
|
|
326
|
+
geminiSummarizeTool,
|
|
327
|
+
geminiImagePromptTool
|
|
328
|
+
];
|
|
329
|
+
}
|