galaxy-code 0.1.6 → 0.1.8

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.
Files changed (81) hide show
  1. package/dist/cli.bundle.js +317 -0
  2. package/package.json +6 -6
  3. package/dist/app.d.ts +0 -7
  4. package/dist/app.js +0 -597
  5. package/dist/auto-updater.d.ts +0 -21
  6. package/dist/auto-updater.js +0 -144
  7. package/dist/cli.d.ts +0 -2
  8. package/dist/cli.js +0 -159
  9. package/dist/cli.min.js +0 -589
  10. package/dist/connections/claude.d.ts +0 -71
  11. package/dist/connections/claude.js +0 -303
  12. package/dist/connections/gemini.d.ts +0 -40
  13. package/dist/connections/gemini.js +0 -232
  14. package/dist/connections/index.d.ts +0 -11
  15. package/dist/connections/index.js +0 -11
  16. package/dist/connections/ollama.d.ts +0 -37
  17. package/dist/connections/ollama.js +0 -73
  18. package/dist/connections/types.d.ts +0 -22
  19. package/dist/connections/types.js +0 -7
  20. package/dist/env.d.ts +0 -1
  21. package/dist/env.js +0 -29
  22. package/dist/prompts/ba-it-analyzer.d.ts +0 -1
  23. package/dist/prompts/ba-it-analyzer.js +0 -143
  24. package/dist/prompts/index.d.ts +0 -11
  25. package/dist/prompts/index.js +0 -11
  26. package/dist/prompts/orchestrator.d.ts +0 -8
  27. package/dist/prompts/orchestrator.js +0 -88
  28. package/dist/prompts/planning-agent.d.ts +0 -8
  29. package/dist/prompts/planning-agent.js +0 -195
  30. package/dist/prompts/universal-agent.d.ts +0 -7
  31. package/dist/prompts/universal-agent.js +0 -111
  32. package/dist/providers/agent-selector.d.ts +0 -29
  33. package/dist/providers/agent-selector.js +0 -84
  34. package/dist/providers/claude-agent.d.ts +0 -29
  35. package/dist/providers/claude-agent.js +0 -121
  36. package/dist/providers/gemini-agent.d.ts +0 -36
  37. package/dist/providers/gemini-agent.js +0 -168
  38. package/dist/providers/index.d.ts +0 -12
  39. package/dist/providers/index.js +0 -12
  40. package/dist/providers/ollama-agent.d.ts +0 -53
  41. package/dist/providers/ollama-agent.js +0 -276
  42. package/dist/providers/orchestrator.d.ts +0 -16
  43. package/dist/providers/orchestrator.js +0 -76
  44. package/dist/tools/ba-it-analyzer.d.ts +0 -66
  45. package/dist/tools/ba-it-analyzer.js +0 -90
  46. package/dist/tools/code-generate-agent.d.ts +0 -51
  47. package/dist/tools/code-generate-agent.js +0 -159
  48. package/dist/tools/command-runner.d.ts +0 -14
  49. package/dist/tools/command-runner.js +0 -120
  50. package/dist/tools/document-parser.d.ts +0 -11
  51. package/dist/tools/document-parser.js +0 -83
  52. package/dist/tools/file-operations.d.ts +0 -17
  53. package/dist/tools/file-operations.js +0 -127
  54. package/dist/tools/galaxy-ui-integration.d.ts +0 -94
  55. package/dist/tools/galaxy-ui-integration.js +0 -244
  56. package/dist/tools/git-operations.d.ts +0 -11
  57. package/dist/tools/git-operations.js +0 -114
  58. package/dist/tools/index.d.ts +0 -10
  59. package/dist/tools/index.js +0 -10
  60. package/dist/tools/planning-agent.d.ts +0 -29
  61. package/dist/tools/planning-agent.js +0 -134
  62. package/dist/tools/progress-reporter.d.ts +0 -19
  63. package/dist/tools/progress-reporter.js +0 -52
  64. package/dist/tools/registry.d.ts +0 -21
  65. package/dist/tools/registry.js +0 -695
  66. package/dist/tools/tool-event-emitter.d.ts +0 -24
  67. package/dist/tools/tool-event-emitter.js +0 -25
  68. package/dist/tools/types.d.ts +0 -31
  69. package/dist/tools/types.js +0 -1
  70. package/dist/types.d.ts +0 -39
  71. package/dist/types.js +0 -8
  72. package/dist/update-checker.d.ts +0 -22
  73. package/dist/update-checker.js +0 -85
  74. package/dist/utils/config-manager.d.ts +0 -102
  75. package/dist/utils/config-manager.js +0 -326
  76. package/dist/utils/devtools.d.ts +0 -21
  77. package/dist/utils/devtools.js +0 -61
  78. package/dist/utils/message-formatters.d.ts +0 -32
  79. package/dist/utils/message-formatters.js +0 -590
  80. package/dist/utils/progress-tracker.d.ts +0 -59
  81. package/dist/utils/progress-tracker.js +0 -213
@@ -1,71 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-13
5
- * @modify 2024-10-13
6
- * @desc Claude API connection using Anthropic SDK
7
- */
8
- import Anthropic from '@anthropic-ai/sdk';
9
- import type { AgentConfig } from '../utils/config-manager.js';
10
- import type { MessageCallback } from './types.js';
11
- export type ClaudeModelId = 'claude-3-5-sonnet-20241022' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-20240229' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4.5-20250929';
12
- export interface ClaudeMessage {
13
- role: 'user' | 'assistant';
14
- content: string;
15
- }
16
- export interface ClaudeStreamChunk {
17
- type: 'content_block_delta' | 'message_delta' | 'message_stop';
18
- delta?: {
19
- text?: string;
20
- type?: string;
21
- };
22
- }
23
- export declare class ClaudeConnection {
24
- private client;
25
- private model;
26
- private conversationHistory;
27
- private conversationHistoryWithTools;
28
- private systemPrompt?;
29
- private toolsRegistry;
30
- constructor(config?: AgentConfig, systemPrompt?: string);
31
- /**
32
- * Send a message and get response
33
- */
34
- chat(userMessage: string): Promise<string>;
35
- /**
36
- * Stream response (for future implementation)
37
- */
38
- chatStream(userMessage: string): AsyncGenerator<string, void, unknown>;
39
- /**
40
- * Generate single response without conversation history
41
- */
42
- generate(prompt: string, systemPrompt?: string): Promise<string>;
43
- /**
44
- * Clear conversation history
45
- */
46
- clearHistory(): void;
47
- /**
48
- * Get conversation history
49
- */
50
- getHistory(): ClaudeMessage[];
51
- /**
52
- * Set system prompt
53
- */
54
- setSystemPrompt(prompt: string): void;
55
- /**
56
- * Get current model
57
- */
58
- getModel(): ClaudeModelId;
59
- /**
60
- * Change model
61
- */
62
- setModel(model: ClaudeModelId): void;
63
- /**
64
- * Chat with tools support - handles full tool loop
65
- */
66
- chatWithTools(userMessage: string, tools: Anthropic.Tool[], onMessage?: MessageCallback): Promise<string>;
67
- /**
68
- * Clear tool conversation history
69
- */
70
- clearToolHistory(): void;
71
- }
@@ -1,303 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-13
5
- * @modify 2024-10-13
6
- * @desc Claude API connection using Anthropic SDK
7
- */
8
- import Anthropic from '@anthropic-ai/sdk';
9
- import { ToolRegistry } from '../tools/index.js';
10
- export class ClaudeConnection {
11
- constructor(config, systemPrompt) {
12
- Object.defineProperty(this, "client", {
13
- enumerable: true,
14
- configurable: true,
15
- writable: true,
16
- value: void 0
17
- });
18
- Object.defineProperty(this, "model", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: void 0
23
- });
24
- Object.defineProperty(this, "conversationHistory", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: []
29
- });
30
- Object.defineProperty(this, "conversationHistoryWithTools", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: []
35
- });
36
- Object.defineProperty(this, "systemPrompt", {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- Object.defineProperty(this, "toolsRegistry", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: new ToolRegistry()
47
- });
48
- // Only get apiKey from config - no fallback to env
49
- const apiKey = config?.apiKey;
50
- // if (!apiKey) {
51
- // throw new Error(
52
- // 'Hiện tại bạn chưa thêm apikey cho model claude. Vui lòng thêm để dùng phần mềm'
53
- // );
54
- // }
55
- this.client = new Anthropic({
56
- apiKey,
57
- });
58
- this.model =
59
- config?.model || 'claude-sonnet-4.5-20250929';
60
- this.systemPrompt = systemPrompt;
61
- }
62
- /**
63
- * Send a message and get response
64
- */
65
- async chat(userMessage) {
66
- // Add user message to history
67
- this.conversationHistory.push({
68
- role: 'user',
69
- content: userMessage,
70
- });
71
- try {
72
- const response = await this.client.messages.create({
73
- model: this.model,
74
- max_tokens: 8192,
75
- system: this.systemPrompt,
76
- messages: this.conversationHistory,
77
- });
78
- // Extract assistant response
79
- const assistantMessage = response.content[0]?.type === 'text' ? response.content[0].text : '';
80
- // Add to history
81
- this.conversationHistory.push({
82
- role: 'assistant',
83
- content: assistantMessage,
84
- });
85
- return assistantMessage;
86
- }
87
- catch (error) {
88
- console.error('Claude API Error:', error);
89
- throw error;
90
- }
91
- }
92
- /**
93
- * Stream response (for future implementation)
94
- */
95
- async *chatStream(userMessage) {
96
- this.conversationHistory.push({
97
- role: 'user',
98
- content: userMessage,
99
- });
100
- try {
101
- const stream = await this.client.messages.create({
102
- model: this.model,
103
- max_tokens: 8192,
104
- system: this.systemPrompt,
105
- messages: this.conversationHistory,
106
- stream: true,
107
- });
108
- let fullResponse = '';
109
- for await (const chunk of stream) {
110
- if (chunk.type === 'content_block_delta' &&
111
- chunk.delta.type === 'text_delta') {
112
- const text = chunk.delta.text || '';
113
- fullResponse += text;
114
- yield text;
115
- }
116
- }
117
- // Add complete response to history
118
- this.conversationHistory.push({
119
- role: 'assistant',
120
- content: fullResponse,
121
- });
122
- }
123
- catch (error) {
124
- console.error('Claude Stream Error:', error);
125
- throw error;
126
- }
127
- }
128
- /**
129
- * Generate single response without conversation history
130
- */
131
- async generate(prompt, systemPrompt) {
132
- try {
133
- const response = await this.client.messages.create({
134
- model: this.model,
135
- max_tokens: 8192,
136
- system: systemPrompt || this.systemPrompt,
137
- messages: [
138
- {
139
- role: 'user',
140
- content: prompt,
141
- },
142
- ],
143
- });
144
- return response.content[0]?.type === 'text'
145
- ? response.content[0].text
146
- : '';
147
- }
148
- catch (error) {
149
- console.error('Claude Generate Error:', error);
150
- throw error;
151
- }
152
- }
153
- /**
154
- * Clear conversation history
155
- */
156
- clearHistory() {
157
- this.conversationHistory = [];
158
- }
159
- /**
160
- * Get conversation history
161
- */
162
- getHistory() {
163
- return [...this.conversationHistory];
164
- }
165
- /**
166
- * Set system prompt
167
- */
168
- setSystemPrompt(prompt) {
169
- this.systemPrompt = prompt;
170
- }
171
- /**
172
- * Get current model
173
- */
174
- getModel() {
175
- return this.model;
176
- }
177
- /**
178
- * Change model
179
- */
180
- setModel(model) {
181
- this.model = model;
182
- }
183
- /**
184
- * Chat with tools support - handles full tool loop
185
- */
186
- async chatWithTools(userMessage, tools, onMessage) {
187
- // Add user message to history
188
- this.conversationHistoryWithTools.push({
189
- role: 'user',
190
- content: userMessage,
191
- });
192
- let iteration = 0;
193
- const MAX_ITERATIONS = 100; // Safety limit
194
- while (iteration < MAX_ITERATIONS) {
195
- iteration++;
196
- // Call Claude API
197
- const response = await this.client.messages.create({
198
- model: this.model,
199
- max_tokens: 8192,
200
- system: this.systemPrompt,
201
- messages: this.conversationHistoryWithTools,
202
- tools: tools,
203
- });
204
- // Check stop reason
205
- if (response.stop_reason !== 'tool_use') {
206
- // No more tools to execute - add final response to history
207
- this.conversationHistoryWithTools.push({
208
- role: 'assistant',
209
- content: response.content,
210
- });
211
- // Extract text from response
212
- const textBlock = response.content.find((block) => block.type === 'text');
213
- return textBlock?.text || '';
214
- }
215
- // Add assistant response with tool_use to history
216
- this.conversationHistoryWithTools.push({
217
- role: 'assistant',
218
- content: response.content,
219
- });
220
- // Execute tools and collect results
221
- const toolResults = [];
222
- for (const block of response.content) {
223
- if (block.type === 'tool_use') {
224
- const toolUseBlock = block;
225
- const toolName = toolUseBlock.name;
226
- const toolInput = toolUseBlock.input;
227
- // Special handling for plan_task and progress_reporter
228
- if (toolName === 'plan_task' || toolName === 'progress_reporter') {
229
- try {
230
- const result = await this.toolsRegistry.executeTool(toolName, toolInput);
231
- const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
232
- toolResults.push({
233
- type: 'tool_result',
234
- tool_use_id: toolUseBlock.id,
235
- content: resultStr,
236
- });
237
- }
238
- catch (error) {
239
- const errorMsg = error instanceof Error ? error.message : String(error);
240
- toolResults.push({
241
- type: 'tool_result',
242
- tool_use_id: toolUseBlock.id,
243
- content: `Error: ${errorMsg}`,
244
- is_error: true,
245
- });
246
- }
247
- }
248
- else {
249
- // Regular tool handling with notification
250
- try {
251
- const result = await this.toolsRegistry.executeTool(toolName, toolInput);
252
- const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
253
- // Notify tool execution
254
- if (onMessage) {
255
- const success = !resultStr.startsWith('❌');
256
- onMessage('tool', resultStr, toolName, {
257
- success,
258
- output: resultStr,
259
- });
260
- }
261
- toolResults.push({
262
- type: 'tool_result',
263
- tool_use_id: toolUseBlock.id,
264
- content: resultStr,
265
- });
266
- }
267
- catch (error) {
268
- const errorMsg = error instanceof Error ? error.message : String(error);
269
- // Notify error
270
- if (onMessage) {
271
- onMessage('tool', `❌ Error: ${errorMsg}`, toolName, {
272
- success: false,
273
- error: errorMsg,
274
- });
275
- }
276
- toolResults.push({
277
- type: 'tool_result',
278
- tool_use_id: toolUseBlock.id,
279
- content: `Error: ${errorMsg}`,
280
- is_error: true,
281
- });
282
- }
283
- }
284
- }
285
- }
286
- // Add tool results to history
287
- this.conversationHistoryWithTools.push({
288
- role: 'user',
289
- content: toolResults,
290
- });
291
- // Loop continues to call API again with tool results
292
- }
293
- // Safety limit reached
294
- console.warn(`⚠️ Safety limit (${MAX_ITERATIONS}) reached in Claude tool loop.`);
295
- return 'Maximum iteration limit reached. Please try again.';
296
- }
297
- /**
298
- * Clear tool conversation history
299
- */
300
- clearToolHistory() {
301
- this.conversationHistoryWithTools = [];
302
- }
303
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-08
5
- * @modify 2024-10-13
6
- * @desc Gemini connection helper using @google/genai with improved function call handling.
7
- */
8
- import { FunctionDeclaration, type GenerateContentConfig } from '@google/genai';
9
- import type { AgentConfig } from '../utils/config-manager.js';
10
- import type { ToolExecutionInfo } from './types.js';
11
- export type GeminiGenerateParameters = {
12
- readonly prompt: string;
13
- readonly config?: GenerateContentConfig;
14
- };
15
- export type GeminiChatParameters = {
16
- readonly prompt: string;
17
- readonly tools?: FunctionDeclaration[];
18
- readonly message: string;
19
- };
20
- export type GeminiGenerateResult<T = unknown> = {
21
- readonly text: string;
22
- readonly raw: T;
23
- };
24
- export declare class GeminiConnection {
25
- private client;
26
- private readonly apiKey;
27
- private chatSession;
28
- private readonly systemInstruction?;
29
- private readonly model;
30
- private toolsRegistry;
31
- constructor(config?: AgentConfig, systemPrompt?: string);
32
- initChat(): void;
33
- generate(parameters: GeminiGenerateParameters): Promise<GeminiGenerateResult>;
34
- chat(message: string, onMessage?: (author: 'tool' | 'assistant', content: string, toolName?: string, toolInfo?: ToolExecutionInfo) => void): Promise<string>;
35
- private getToolDeclarations;
36
- private convertToFunctionDeclaration;
37
- private convertSchemaToGeminiSchema;
38
- private convertPropertyToGeminiSchema;
39
- private mapTypeToGemini;
40
- }
@@ -1,232 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-08
5
- * @modify 2024-10-13
6
- * @desc Gemini connection helper using @google/genai with improved function call handling.
7
- */
8
- import { GoogleGenAI, Type, } from '@google/genai';
9
- import { globalToolRegistry } from '../tools/registry.js';
10
- const geminiModel = 'gemini-2.5-flash';
11
- export class GeminiConnection {
12
- constructor(config, systemPrompt) {
13
- Object.defineProperty(this, "client", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- Object.defineProperty(this, "apiKey", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: void 0
24
- });
25
- Object.defineProperty(this, "chatSession", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: void 0
30
- });
31
- Object.defineProperty(this, "systemInstruction", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: void 0
36
- });
37
- Object.defineProperty(this, "model", {
38
- enumerable: true,
39
- configurable: true,
40
- writable: true,
41
- value: void 0
42
- });
43
- Object.defineProperty(this, "toolsRegistry", {
44
- enumerable: true,
45
- configurable: true,
46
- writable: true,
47
- value: globalToolRegistry
48
- });
49
- // Only get apiKey from config - no fallback to env
50
- this.apiKey = config?.apiKey;
51
- this.model = config?.model ?? 'gemini-2.5-flash';
52
- this.client = new GoogleGenAI({ apiKey: this.apiKey });
53
- this.systemInstruction = systemPrompt;
54
- this.initChat();
55
- }
56
- initChat() {
57
- this.chatSession = this.client.chats.create({
58
- model: this.model,
59
- config: {
60
- systemInstruction: this.systemInstruction,
61
- tools: [{ functionDeclarations: this.getToolDeclarations() }],
62
- temperature: 0.7,
63
- thinkingConfig: {
64
- thinkingBudget: 0,
65
- },
66
- },
67
- });
68
- }
69
- async generate(parameters) {
70
- const response = await this.client.models.generateContent({
71
- model: geminiModel,
72
- contents: parameters.prompt,
73
- });
74
- const text = response.text ?? '';
75
- return { text, raw: response };
76
- }
77
- async chat(message, onMessage) {
78
- if (!this.chatSession) {
79
- throw new Error('Chat session is not initialized.');
80
- }
81
- let currentMessage = message;
82
- let response;
83
- let iteration = 0;
84
- const MAX_ITERATIONS = 15; // Tăng lên vì xử lý từng tool một
85
- while (currentMessage && iteration < MAX_ITERATIONS) {
86
- iteration++;
87
- response = await this.chatSession.sendMessage({
88
- message: currentMessage,
89
- });
90
- if (response.functionCalls && response.functionCalls.length > 0) {
91
- const functionResponses = [];
92
- // **IMPROVED: Sequential execution với early feedback**
93
- for (const functionCall of response.functionCalls) {
94
- try {
95
- const toolName = functionCall.name || 'unknown';
96
- const args = functionCall.args || {};
97
- const toolResult = await this.toolsRegistry.executeTool(toolName, args);
98
- const resultStr = typeof toolResult === 'string' ? toolResult : JSON.stringify(toolResult);
99
- if (onMessage) {
100
- // Pass tool execution info for better formatting
101
- const toolInfo = {
102
- toolName,
103
- args,
104
- result: toolResult,
105
- };
106
- onMessage('tool', resultStr, toolName, toolInfo);
107
- }
108
- functionResponses.push({
109
- functionResponse: {
110
- name: functionCall.name,
111
- response: { result: resultStr },
112
- },
113
- });
114
- // **NEW: Cho phép xử lý từng tool một nếu cần**
115
- // Nếu có nhiều function calls, có thể break ở đây để feedback sớm
116
- // Nhưng hiện tại vẫn xử lý hết để tương thích
117
- }
118
- catch (error) {
119
- const errorMsg = error instanceof Error ? error.message : String(error);
120
- // Log error
121
- if (onMessage) {
122
- const toolInfo = {
123
- toolName: functionCall.name || 'unknown',
124
- args: functionCall.args || {},
125
- result: `❌ Error: ${errorMsg}`,
126
- };
127
- onMessage('tool', `❌ Error: ${errorMsg}`, functionCall.name, toolInfo);
128
- }
129
- functionResponses.push({
130
- functionResponse: {
131
- name: functionCall.name,
132
- response: {
133
- error: errorMsg,
134
- },
135
- },
136
- });
137
- // **NEW: Stop on critical errors**
138
- // Nếu là lỗi nghiêm trọng, có thể break để không lãng phí
139
- // nhưng hiện tại vẫn tiếp tục để AI có đầy đủ context
140
- }
141
- }
142
- // Gửi tất cả function responses
143
- currentMessage = functionResponses;
144
- }
145
- else {
146
- // Không có function calls → trả về text response
147
- return response.text ?? '';
148
- }
149
- }
150
- if (iteration >= MAX_ITERATIONS) {
151
- console.warn(`⚠️ Max iterations (${MAX_ITERATIONS}) reached. This may indicate:`);
152
- console.warn(' - Too many sequential tool calls');
153
- console.warn(' - AI stuck in a reasoning loop');
154
- console.warn(' - Consider reviewing system prompt or tool definitions');
155
- throw new Error(`Max iterations (${MAX_ITERATIONS}) reached`);
156
- }
157
- return '';
158
- }
159
- getToolDeclarations() {
160
- const tools = this.toolsRegistry.list();
161
- return tools.map(tool => this.convertToFunctionDeclaration(tool));
162
- }
163
- convertToFunctionDeclaration(tool) {
164
- return {
165
- name: tool.name,
166
- description: tool.description,
167
- parameters: this.convertSchemaToGeminiSchema(tool.inputSchema),
168
- };
169
- }
170
- convertSchemaToGeminiSchema(schema) {
171
- if (!schema) {
172
- return {
173
- type: Type.OBJECT,
174
- properties: {},
175
- };
176
- }
177
- const converted = {
178
- type: Type.OBJECT,
179
- properties: {},
180
- };
181
- if (schema['properties']) {
182
- converted.properties = {};
183
- for (const [key, value] of Object.entries(schema['properties'])) {
184
- const prop = value;
185
- converted.properties[key] = this.convertPropertyToGeminiSchema(prop);
186
- }
187
- }
188
- if (schema['required']) {
189
- converted.required = schema['required'];
190
- }
191
- return converted;
192
- }
193
- convertPropertyToGeminiSchema(prop) {
194
- const propSchema = {
195
- type: this.mapTypeToGemini(prop.type),
196
- description: prop.description || '',
197
- };
198
- if (prop.type === 'object' && prop.properties) {
199
- propSchema.properties = {};
200
- for (const [key, value] of Object.entries(prop.properties)) {
201
- propSchema.properties[key] = this.convertPropertyToGeminiSchema(value);
202
- }
203
- if (prop.required) {
204
- propSchema.required = prop.required;
205
- }
206
- }
207
- if (prop.type === 'array') {
208
- if (prop.items && typeof prop.items === 'object') {
209
- propSchema.items = this.convertPropertyToGeminiSchema(prop.items);
210
- }
211
- else {
212
- // Gemini requires items field for arrays
213
- propSchema.items = {
214
- type: Type.STRING,
215
- description: '',
216
- };
217
- }
218
- }
219
- return propSchema;
220
- }
221
- mapTypeToGemini(type) {
222
- const typeMap = {
223
- string: Type.STRING,
224
- number: Type.NUMBER,
225
- integer: Type.INTEGER,
226
- boolean: Type.BOOLEAN,
227
- object: Type.OBJECT,
228
- array: Type.ARRAY,
229
- };
230
- return typeMap[type.toLowerCase()] || Type.STRING;
231
- }
232
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-08
5
- * @modify 2024-10-13
6
- * @desc Export entry for connection modules.
7
- */
8
- export * from './types.js';
9
- export * from './ollama.js';
10
- export * from './gemini.js';
11
- export * from './claude.js';
@@ -1,11 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2024-10-08
5
- * @modify 2024-10-13
6
- * @desc Export entry for connection modules.
7
- */
8
- export * from './types.js';
9
- export * from './ollama.js';
10
- export * from './gemini.js';
11
- export * from './claude.js';