galaxy-code 0.1.5 → 0.1.7

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 (222) hide show
  1. package/README.md +149 -600
  2. package/dist/cli.bundle.js +588 -0
  3. package/package.json +14 -12
  4. package/dist/app.d.ts +0 -7
  5. package/dist/app.js +0 -597
  6. package/dist/auto-updater.d.ts +0 -21
  7. package/dist/auto-updater.js +0 -144
  8. package/dist/cli.d.ts +0 -2
  9. package/dist/cli.js +0 -159
  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/node_modules/@workspace/agent-core/connections/claude.d.ts +0 -72
  23. package/dist/node_modules/@workspace/agent-core/connections/claude.d.ts.map +0 -1
  24. package/dist/node_modules/@workspace/agent-core/connections/claude.js +0 -270
  25. package/dist/node_modules/@workspace/agent-core/connections/claude.js.map +0 -1
  26. package/dist/node_modules/@workspace/agent-core/connections/gemini.d.ts +0 -41
  27. package/dist/node_modules/@workspace/agent-core/connections/gemini.d.ts.map +0 -1
  28. package/dist/node_modules/@workspace/agent-core/connections/gemini.js +0 -203
  29. package/dist/node_modules/@workspace/agent-core/connections/gemini.js.map +0 -1
  30. package/dist/node_modules/@workspace/agent-core/connections/index.d.ts +0 -12
  31. package/dist/node_modules/@workspace/agent-core/connections/index.d.ts.map +0 -1
  32. package/dist/node_modules/@workspace/agent-core/connections/index.js +0 -12
  33. package/dist/node_modules/@workspace/agent-core/connections/index.js.map +0 -1
  34. package/dist/node_modules/@workspace/agent-core/connections/ollama.d.ts +0 -38
  35. package/dist/node_modules/@workspace/agent-core/connections/ollama.d.ts.map +0 -1
  36. package/dist/node_modules/@workspace/agent-core/connections/ollama.js +0 -64
  37. package/dist/node_modules/@workspace/agent-core/connections/ollama.js.map +0 -1
  38. package/dist/node_modules/@workspace/agent-core/connections/types.d.ts +0 -23
  39. package/dist/node_modules/@workspace/agent-core/connections/types.d.ts.map +0 -1
  40. package/dist/node_modules/@workspace/agent-core/connections/types.js +0 -8
  41. package/dist/node_modules/@workspace/agent-core/connections/types.js.map +0 -1
  42. package/dist/node_modules/@workspace/agent-core/index.d.ts +0 -13
  43. package/dist/node_modules/@workspace/agent-core/index.d.ts.map +0 -1
  44. package/dist/node_modules/@workspace/agent-core/index.js +0 -22
  45. package/dist/node_modules/@workspace/agent-core/index.js.map +0 -1
  46. package/dist/node_modules/@workspace/agent-core/package.json +0 -53
  47. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.d.ts +0 -2
  48. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.d.ts.map +0 -1
  49. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.js +0 -144
  50. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.js.map +0 -1
  51. package/dist/node_modules/@workspace/agent-core/prompts/index.d.ts +0 -12
  52. package/dist/node_modules/@workspace/agent-core/prompts/index.d.ts.map +0 -1
  53. package/dist/node_modules/@workspace/agent-core/prompts/index.js +0 -12
  54. package/dist/node_modules/@workspace/agent-core/prompts/index.js.map +0 -1
  55. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.d.ts +0 -9
  56. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.d.ts.map +0 -1
  57. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.js +0 -89
  58. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.js.map +0 -1
  59. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.d.ts +0 -9
  60. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.d.ts.map +0 -1
  61. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.js +0 -196
  62. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.js.map +0 -1
  63. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.d.ts +0 -8
  64. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.d.ts.map +0 -1
  65. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.js +0 -112
  66. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.js.map +0 -1
  67. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.d.ts +0 -30
  68. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.d.ts.map +0 -1
  69. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.js +0 -76
  70. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.js.map +0 -1
  71. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.d.ts +0 -30
  72. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.d.ts.map +0 -1
  73. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.js +0 -107
  74. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.js.map +0 -1
  75. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.d.ts +0 -37
  76. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.d.ts.map +0 -1
  77. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.js +0 -144
  78. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.js.map +0 -1
  79. package/dist/node_modules/@workspace/agent-core/providers/index.d.ts +0 -13
  80. package/dist/node_modules/@workspace/agent-core/providers/index.d.ts.map +0 -1
  81. package/dist/node_modules/@workspace/agent-core/providers/index.js +0 -13
  82. package/dist/node_modules/@workspace/agent-core/providers/index.js.map +0 -1
  83. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.d.ts +0 -54
  84. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.d.ts.map +0 -1
  85. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.js +0 -247
  86. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.js.map +0 -1
  87. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.d.ts +0 -17
  88. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.d.ts.map +0 -1
  89. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.js +0 -62
  90. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.js.map +0 -1
  91. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.d.ts +0 -67
  92. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.d.ts.map +0 -1
  93. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.js +0 -81
  94. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.js.map +0 -1
  95. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.d.ts +0 -52
  96. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.d.ts.map +0 -1
  97. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.js +0 -150
  98. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.js.map +0 -1
  99. package/dist/node_modules/@workspace/agent-core/tools/command-runner.d.ts +0 -15
  100. package/dist/node_modules/@workspace/agent-core/tools/command-runner.d.ts.map +0 -1
  101. package/dist/node_modules/@workspace/agent-core/tools/command-runner.js +0 -121
  102. package/dist/node_modules/@workspace/agent-core/tools/command-runner.js.map +0 -1
  103. package/dist/node_modules/@workspace/agent-core/tools/document-parser.d.ts +0 -12
  104. package/dist/node_modules/@workspace/agent-core/tools/document-parser.d.ts.map +0 -1
  105. package/dist/node_modules/@workspace/agent-core/tools/document-parser.js +0 -84
  106. package/dist/node_modules/@workspace/agent-core/tools/document-parser.js.map +0 -1
  107. package/dist/node_modules/@workspace/agent-core/tools/file-operations.d.ts +0 -18
  108. package/dist/node_modules/@workspace/agent-core/tools/file-operations.d.ts.map +0 -1
  109. package/dist/node_modules/@workspace/agent-core/tools/file-operations.js +0 -126
  110. package/dist/node_modules/@workspace/agent-core/tools/file-operations.js.map +0 -1
  111. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.d.ts +0 -95
  112. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.d.ts.map +0 -1
  113. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.js +0 -245
  114. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.js.map +0 -1
  115. package/dist/node_modules/@workspace/agent-core/tools/git-operations.d.ts +0 -12
  116. package/dist/node_modules/@workspace/agent-core/tools/git-operations.d.ts.map +0 -1
  117. package/dist/node_modules/@workspace/agent-core/tools/git-operations.js +0 -115
  118. package/dist/node_modules/@workspace/agent-core/tools/git-operations.js.map +0 -1
  119. package/dist/node_modules/@workspace/agent-core/tools/index.d.ts +0 -11
  120. package/dist/node_modules/@workspace/agent-core/tools/index.d.ts.map +0 -1
  121. package/dist/node_modules/@workspace/agent-core/tools/index.js +0 -11
  122. package/dist/node_modules/@workspace/agent-core/tools/index.js.map +0 -1
  123. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.d.ts +0 -30
  124. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.d.ts.map +0 -1
  125. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.js +0 -125
  126. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.js.map +0 -1
  127. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.d.ts +0 -20
  128. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.d.ts.map +0 -1
  129. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.js +0 -46
  130. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.js.map +0 -1
  131. package/dist/node_modules/@workspace/agent-core/tools/registry.d.ts +0 -22
  132. package/dist/node_modules/@workspace/agent-core/tools/registry.d.ts.map +0 -1
  133. package/dist/node_modules/@workspace/agent-core/tools/registry.js +0 -651
  134. package/dist/node_modules/@workspace/agent-core/tools/registry.js.map +0 -1
  135. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.d.ts +0 -25
  136. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.d.ts.map +0 -1
  137. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.js +0 -26
  138. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.js.map +0 -1
  139. package/dist/node_modules/@workspace/agent-core/tools/types.d.ts +0 -32
  140. package/dist/node_modules/@workspace/agent-core/tools/types.d.ts.map +0 -1
  141. package/dist/node_modules/@workspace/agent-core/tools/types.js +0 -2
  142. package/dist/node_modules/@workspace/agent-core/tools/types.js.map +0 -1
  143. package/dist/node_modules/@workspace/agent-core/types.d.ts +0 -40
  144. package/dist/node_modules/@workspace/agent-core/types.d.ts.map +0 -1
  145. package/dist/node_modules/@workspace/agent-core/types.js +0 -9
  146. package/dist/node_modules/@workspace/agent-core/types.js.map +0 -1
  147. package/dist/node_modules/@workspace/agent-core/utils/config-manager.d.ts +0 -103
  148. package/dist/node_modules/@workspace/agent-core/utils/config-manager.d.ts.map +0 -1
  149. package/dist/node_modules/@workspace/agent-core/utils/config-manager.js +0 -307
  150. package/dist/node_modules/@workspace/agent-core/utils/config-manager.js.map +0 -1
  151. package/dist/node_modules/@workspace/agent-core/utils/devtools.d.ts +0 -22
  152. package/dist/node_modules/@workspace/agent-core/utils/devtools.d.ts.map +0 -1
  153. package/dist/node_modules/@workspace/agent-core/utils/devtools.js +0 -62
  154. package/dist/node_modules/@workspace/agent-core/utils/devtools.js.map +0 -1
  155. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.d.ts +0 -33
  156. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.d.ts.map +0 -1
  157. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.js +0 -591
  158. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.js.map +0 -1
  159. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.d.ts +0 -60
  160. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.d.ts.map +0 -1
  161. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.js +0 -204
  162. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.js.map +0 -1
  163. package/dist/prompts/ba-it-analyzer.d.ts +0 -1
  164. package/dist/prompts/ba-it-analyzer.js +0 -143
  165. package/dist/prompts/index.d.ts +0 -11
  166. package/dist/prompts/index.js +0 -11
  167. package/dist/prompts/orchestrator.d.ts +0 -8
  168. package/dist/prompts/orchestrator.js +0 -88
  169. package/dist/prompts/planning-agent.d.ts +0 -8
  170. package/dist/prompts/planning-agent.js +0 -195
  171. package/dist/prompts/universal-agent.d.ts +0 -7
  172. package/dist/prompts/universal-agent.js +0 -111
  173. package/dist/providers/agent-selector.d.ts +0 -29
  174. package/dist/providers/agent-selector.js +0 -84
  175. package/dist/providers/claude-agent.d.ts +0 -29
  176. package/dist/providers/claude-agent.js +0 -121
  177. package/dist/providers/gemini-agent.d.ts +0 -36
  178. package/dist/providers/gemini-agent.js +0 -168
  179. package/dist/providers/index.d.ts +0 -12
  180. package/dist/providers/index.js +0 -12
  181. package/dist/providers/ollama-agent.d.ts +0 -53
  182. package/dist/providers/ollama-agent.js +0 -276
  183. package/dist/providers/orchestrator.d.ts +0 -16
  184. package/dist/providers/orchestrator.js +0 -76
  185. package/dist/tools/ba-it-analyzer.d.ts +0 -66
  186. package/dist/tools/ba-it-analyzer.js +0 -90
  187. package/dist/tools/code-generate-agent.d.ts +0 -51
  188. package/dist/tools/code-generate-agent.js +0 -159
  189. package/dist/tools/command-runner.d.ts +0 -14
  190. package/dist/tools/command-runner.js +0 -120
  191. package/dist/tools/document-parser.d.ts +0 -11
  192. package/dist/tools/document-parser.js +0 -83
  193. package/dist/tools/file-operations.d.ts +0 -17
  194. package/dist/tools/file-operations.js +0 -127
  195. package/dist/tools/galaxy-ui-integration.d.ts +0 -94
  196. package/dist/tools/galaxy-ui-integration.js +0 -244
  197. package/dist/tools/git-operations.d.ts +0 -11
  198. package/dist/tools/git-operations.js +0 -114
  199. package/dist/tools/index.d.ts +0 -10
  200. package/dist/tools/index.js +0 -10
  201. package/dist/tools/planning-agent.d.ts +0 -29
  202. package/dist/tools/planning-agent.js +0 -134
  203. package/dist/tools/progress-reporter.d.ts +0 -19
  204. package/dist/tools/progress-reporter.js +0 -52
  205. package/dist/tools/registry.d.ts +0 -21
  206. package/dist/tools/registry.js +0 -695
  207. package/dist/tools/tool-event-emitter.d.ts +0 -24
  208. package/dist/tools/tool-event-emitter.js +0 -25
  209. package/dist/tools/types.d.ts +0 -31
  210. package/dist/tools/types.js +0 -1
  211. package/dist/types.d.ts +0 -39
  212. package/dist/types.js +0 -8
  213. package/dist/update-checker.d.ts +0 -22
  214. package/dist/update-checker.js +0 -85
  215. package/dist/utils/config-manager.d.ts +0 -102
  216. package/dist/utils/config-manager.js +0 -326
  217. package/dist/utils/devtools.d.ts +0 -21
  218. package/dist/utils/devtools.js +0 -61
  219. package/dist/utils/message-formatters.d.ts +0 -32
  220. package/dist/utils/message-formatters.js +0 -590
  221. package/dist/utils/progress-tracker.d.ts +0 -59
  222. package/dist/utils/progress-tracker.js +0 -213
@@ -1,168 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2025-10-22
5
- * @modify 2025-10-22
6
- * @desc Gemini Agent - Self-contained AI orchestrator
7
- */
8
- import { GeminiConnection } from '../connections/gemini.js';
9
- import { ToolRegistry } from '../tools/index.js';
10
- import { buildUniversalAgentPrompt } from '../prompts/index.js';
11
- export class GeminiAgent {
12
- constructor(config) {
13
- Object.defineProperty(this, "connection", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- Object.defineProperty(this, "toolsRegistry", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: new ToolRegistry()
24
- });
25
- Object.defineProperty(this, "conversationHistory", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: []
30
- });
31
- Object.defineProperty(this, "systemPrompt", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: void 0
36
- });
37
- // Low-level tools for Gemini to build software
38
- Object.defineProperty(this, "toolNames", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: [
43
- 'file_read',
44
- 'file_write',
45
- 'file_tree',
46
- 'file_list',
47
- 'file_search',
48
- 'git_status',
49
- 'git_commit',
50
- 'git_push',
51
- 'git_pull',
52
- 'git_diff',
53
- 'git_log',
54
- 'git_branches',
55
- 'command_run',
56
- 'install_dependencies',
57
- 'test_run',
58
- 'document_parse',
59
- 'plan_task',
60
- 'progress_reporter',
61
- // Galaxy UI Integration
62
- 'galaxy_ui_list',
63
- 'galaxy_ui_search',
64
- 'galaxy_ui_get_component',
65
- 'galaxy_ui_categories',
66
- 'galaxy_ui_add',
67
- 'galaxy_ui_init',
68
- 'galaxy_ui_docs',
69
- ]
70
- });
71
- // Build system prompt using shared universal prompt
72
- const toolsContext = this.toolsRegistry.getToolsContext(this.toolNames);
73
- this.systemPrompt = buildUniversalAgentPrompt(toolsContext);
74
- this.connection = new GeminiConnection(config, this.systemPrompt);
75
- }
76
- /**
77
- * Handle user input and orchestrate tool calls
78
- */
79
- async handleUserInput(input, options, onMessage, retryCount = 0) {
80
- const MAX_RETRIES = 3;
81
- try {
82
- // Add system context to input
83
- const contextMessage = options
84
- ? `[System Context: Git=${options.gitEnabled ? 'ON' : 'OFF'}, Test Planning=${options.testEnabled ? 'ON' : 'OFF'}]\n\n${input}`
85
- : input;
86
- // Add user message to history
87
- this.conversationHistory.push({
88
- role: 'user',
89
- content: contextMessage,
90
- });
91
- // Notify user message
92
- if (onMessage) {
93
- onMessage('user', contextMessage);
94
- }
95
- // Create callback wrapper for tool execution notifications
96
- const geminiCallback = (author, content, toolName, toolInfo) => {
97
- if (onMessage && author === 'tool' && toolName) {
98
- // Special handling for plan_task and progress_reporter
99
- if (toolName === 'plan_task' || toolName === 'progress_reporter') {
100
- // Don't notify - event already emitted by tool
101
- return;
102
- }
103
- // Regular tool handling - notify result only
104
- const success = !content.startsWith('❌');
105
- onMessage('tool', content, toolName, {
106
- success,
107
- output: toolInfo?.result || content,
108
- });
109
- }
110
- };
111
- // Start conversation with Gemini
112
- const response = await this.connection.chat(contextMessage, geminiCallback);
113
- // Add assistant response to history
114
- this.conversationHistory.push({
115
- role: 'assistant',
116
- content: response,
117
- });
118
- // Notify final response
119
- if (onMessage) {
120
- onMessage('assistant', response);
121
- }
122
- return { content: response || '(No response)' };
123
- }
124
- catch (error) {
125
- // Silent auto-retry with exponential backoff
126
- if (retryCount < MAX_RETRIES) {
127
- // Remove last user message from history to avoid duplication
128
- if (this.conversationHistory.length > 0 &&
129
- this.conversationHistory[this.conversationHistory.length - 1]?.role === 'user') {
130
- this.conversationHistory.pop();
131
- }
132
- // Wait before retry (exponential backoff: 1s, 2s, 4s)
133
- const delayMs = Math.pow(2, retryCount) * 1000;
134
- await new Promise(resolve => setTimeout(resolve, delayMs));
135
- // Silent retry - continue with "Continued" message
136
- return await this.handleUserInput('Continued', options, onMessage, retryCount + 1);
137
- }
138
- // Max retries exceeded - throw error to app.tsx
139
- throw new Error(`Agent failed after ${MAX_RETRIES} retries: ${error instanceof Error ? error.message : String(error)}`);
140
- }
141
- }
142
- /**
143
- * Clear conversation history
144
- */
145
- clearHistory() {
146
- this.conversationHistory = [];
147
- // Call clearHistory on connection if available
148
- if ('clearHistory' in this.connection && typeof this.connection.clearHistory === 'function') {
149
- this.connection.clearHistory();
150
- }
151
- }
152
- /**
153
- * Get conversation history
154
- */
155
- getHistory() {
156
- return [...this.conversationHistory];
157
- }
158
- }
159
- // Singleton instance with lazy initialization
160
- let _geminiAgent = null;
161
- export const geminiAgent = {
162
- get instance() {
163
- if (!_geminiAgent) {
164
- _geminiAgent = new GeminiAgent();
165
- }
166
- return _geminiAgent;
167
- },
168
- };
@@ -1,12 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2025-10-21
5
- * @modify 2025-10-22
6
- * @desc AI module exports - orchestrator, agents, and selector
7
- */
8
- export { OrchestratorAgent } from './orchestrator.js';
9
- export { ClaudeAgent } from './claude-agent.js';
10
- export { OllamaAgent } from './ollama-agent.js';
11
- export { GeminiAgent } from './gemini-agent.js';
12
- export { selectAgent, getAgentDescription, agentSupportsTools, type AgentInterface, } from './agent-selector.js';
@@ -1,12 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2025-10-21
5
- * @modify 2025-10-22
6
- * @desc AI module exports - orchestrator, agents, and selector
7
- */
8
- export { OrchestratorAgent } from './orchestrator.js';
9
- export { ClaudeAgent } from './claude-agent.js';
10
- export { OllamaAgent } from './ollama-agent.js';
11
- export { GeminiAgent } from './gemini-agent.js';
12
- export { selectAgent, getAgentDescription, agentSupportsTools, } from './agent-selector.js';
@@ -1,53 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2025-10-22
5
- * @modify 2025-10-22
6
- * @desc Ollama Agent - Self-contained AI orchestrator
7
- */
8
- import { type OllamaModelId } from '../connections/ollama.js';
9
- import type { Message } from 'ollama';
10
- import type { AgentConfig } from '../utils/config-manager.js';
11
- export interface OllamaAgentOptions {
12
- gitEnabled: boolean;
13
- testEnabled: boolean;
14
- }
15
- export type MessageCallback = (author: 'user' | 'assistant' | 'system' | 'tool', content: string, toolName?: string, toolInfo?: any) => void;
16
- export declare class OllamaAgent {
17
- private connection;
18
- private model;
19
- private toolsRegistry;
20
- private conversationHistory;
21
- private systemPrompt;
22
- private readonly toolNames;
23
- constructor(config?: AgentConfig);
24
- /**
25
- * Convert tool registry format to Ollama tool format
26
- */
27
- private getOllamaTools;
28
- /**
29
- * Handle user input and orchestrate tool calls
30
- */
31
- handleUserInput(input: string, options?: OllamaAgentOptions, onMessage?: MessageCallback, retryCount?: number): Promise<{
32
- content: string;
33
- }>;
34
- /**
35
- * Clear conversation history
36
- */
37
- clearHistory(): void;
38
- /**
39
- * Get conversation history
40
- */
41
- getHistory(): Message[];
42
- /**
43
- * Change model
44
- */
45
- setModel(model: OllamaModelId): void;
46
- /**
47
- * Get current model
48
- */
49
- getModel(): OllamaModelId;
50
- }
51
- export declare const ollamaAgent: {
52
- readonly instance: OllamaAgent;
53
- };
@@ -1,276 +0,0 @@
1
- /**
2
- * @author Bùi Trọng Hiếu
3
- * @email kevinbui210191@gmail.com
4
- * @create 2025-10-22
5
- * @modify 2025-10-22
6
- * @desc Ollama Agent - Self-contained AI orchestrator
7
- */
8
- import { OllamaConnection } from '../connections/ollama.js';
9
- import { ToolRegistry } from '../tools/index.js';
10
- import { buildUniversalAgentPrompt } from '../prompts/index.js';
11
- export class OllamaAgent {
12
- constructor(config) {
13
- Object.defineProperty(this, "connection", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- Object.defineProperty(this, "model", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: void 0
24
- });
25
- Object.defineProperty(this, "toolsRegistry", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: new ToolRegistry()
30
- });
31
- Object.defineProperty(this, "conversationHistory", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: []
36
- });
37
- Object.defineProperty(this, "systemPrompt", {
38
- enumerable: true,
39
- configurable: true,
40
- writable: true,
41
- value: void 0
42
- });
43
- // Low-level tools for Ollama to build software
44
- Object.defineProperty(this, "toolNames", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: [
49
- 'file_read',
50
- 'file_write',
51
- 'file_tree',
52
- 'file_list',
53
- 'file_search',
54
- 'git_status',
55
- 'git_commit',
56
- 'git_push',
57
- 'git_pull',
58
- 'git_diff',
59
- 'git_log',
60
- 'git_branches',
61
- 'command_run',
62
- 'install_dependencies',
63
- 'test_run',
64
- 'plan_task',
65
- 'progress_reporter',
66
- // Galaxy UI Integration
67
- 'galaxy_ui_list',
68
- 'galaxy_ui_search',
69
- 'galaxy_ui_get_component',
70
- 'galaxy_ui_categories',
71
- 'galaxy_ui_add',
72
- 'galaxy_ui_init',
73
- 'galaxy_ui_docs',
74
- ]
75
- });
76
- this.model = config?.model || 'deepseek-v3.1:671b-cloud';
77
- this.connection = new OllamaConnection(config);
78
- // Build system prompt using shared universal prompt
79
- const toolsContext = this.toolsRegistry.getToolsContext(this.toolNames);
80
- this.systemPrompt = buildUniversalAgentPrompt(toolsContext);
81
- }
82
- /**
83
- * Convert tool registry format to Ollama tool format
84
- */
85
- getOllamaTools() {
86
- const tools = this.toolsRegistry.getToolsByNames(this.toolNames);
87
- return tools.map(tool => ({
88
- type: 'function',
89
- function: {
90
- name: tool.name,
91
- description: tool.description,
92
- parameters: tool.inputSchema,
93
- },
94
- }));
95
- }
96
- /**
97
- * Handle user input and orchestrate tool calls
98
- */
99
- async handleUserInput(input, options, onMessage, retryCount = 0) {
100
- const MAX_RETRIES = 3;
101
- try {
102
- // Add system context to input
103
- const contextMessage = options
104
- ? `[System Context: Git=${options.gitEnabled ? 'ON' : 'OFF'}, Test Planning=${options.testEnabled ? 'ON' : 'OFF'}]\n\n${input}`
105
- : input;
106
- // Add user message to history
107
- this.conversationHistory.push({
108
- role: 'user',
109
- content: contextMessage,
110
- });
111
- // Start conversation loop
112
- let response = await this.connection.chatWithTools({
113
- model: this.model,
114
- messages: [{ role: 'system', content: this.systemPrompt }, ...this.conversationHistory],
115
- tools: this.getOllamaTools(),
116
- stream: false,
117
- });
118
- // Handle tool use loop until completion
119
- // Using a high safety limit to prevent infinite loops while allowing full plan execution
120
- const SAFETY_LIMIT = 100;
121
- let iteration = 0;
122
- while (response.message.tool_calls && iteration < SAFETY_LIMIT) {
123
- iteration++;
124
- const toolCalls = response.message.tool_calls;
125
- // Add assistant response to history
126
- this.conversationHistory.push({
127
- role: 'assistant',
128
- content: response.message.content || '',
129
- tool_calls: toolCalls,
130
- });
131
- // Execute tools and collect results
132
- for (const toolCall of toolCalls) {
133
- const toolName = toolCall.function.name;
134
- const toolInput = toolCall.function.arguments;
135
- // Special handling for plan_task and progress_reporter
136
- if (toolName === 'plan_task' || toolName === 'progress_reporter') {
137
- try {
138
- // Execute tool (it will emit event internally)
139
- const result = await this.toolsRegistry.executeTool(toolName, toolInput);
140
- // Convert result to string if needed
141
- const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
142
- // Add tool result to history (but don't notify - event already emitted)
143
- this.conversationHistory.push({
144
- role: 'tool',
145
- content: resultStr,
146
- });
147
- // After plan_task, remind AI to start executing with progress reporting
148
- if (toolName === 'plan_task') {
149
- this.conversationHistory.push({
150
- role: 'user',
151
- content: '⚠️ CRITICAL: Now execute EACH step in the plan. After completing EACH step, you MUST call progress_reporter({step: N, status: "success"|"error"}). Start with step 1.',
152
- });
153
- }
154
- }
155
- catch (error) {
156
- const errorMsg = error instanceof Error ? error.message : String(error);
157
- // Add error result to history
158
- this.conversationHistory.push({
159
- role: 'tool',
160
- content: `Error: ${errorMsg}`,
161
- });
162
- }
163
- }
164
- else {
165
- // Regular tool handling
166
- try {
167
- // Execute tool
168
- const result = await this.toolsRegistry.executeTool(toolName, toolInput);
169
- // Convert result to string if needed
170
- const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
171
- // Add tool result to history
172
- this.conversationHistory.push({
173
- role: 'tool',
174
- content: resultStr,
175
- });
176
- // CRITICAL: Force reminder for progress reporting after each tool execution
177
- // This ensures AI calls progress_reporter after completing each step
178
- this.conversationHistory.push({
179
- role: 'user',
180
- content: '⚠️ MANDATORY: If the tool you just executed was part of a plan step, you MUST immediately call progress_reporter with the step number and status (success/error). Do NOT skip this step.',
181
- });
182
- }
183
- catch (error) {
184
- const errorMsg = error instanceof Error ? error.message : String(error);
185
- // Add error result to history
186
- this.conversationHistory.push({
187
- role: 'tool',
188
- content: `Error: ${errorMsg}`,
189
- });
190
- // Force reminder even on error
191
- this.conversationHistory.push({
192
- role: 'user',
193
- content: '⚠️ MANDATORY: The tool execution failed. You MUST call progress_reporter with status="error" for this step.',
194
- });
195
- }
196
- }
197
- }
198
- // Continue conversation
199
- response = await this.connection.chatWithTools({
200
- model: this.model,
201
- messages: [{ role: 'system', content: this.systemPrompt }, ...this.conversationHistory],
202
- tools: this.getOllamaTools(),
203
- stream: false,
204
- });
205
- }
206
- // Check if we hit the safety limit (likely an issue)
207
- if (iteration >= SAFETY_LIMIT) {
208
- // Safety limit reached - agent should complete naturally
209
- }
210
- // Extract final text response
211
- const finalResponse = response.message.content || '';
212
- // Add final response to history
213
- this.conversationHistory.push({
214
- role: 'assistant',
215
- content: finalResponse,
216
- });
217
- // Notify final response
218
- // if (onMessage) {
219
- // onMessage('assistant', finalResponse);
220
- // }
221
- return { content: finalResponse };
222
- }
223
- catch (error) {
224
- // Silent auto-retry with exponential backoff
225
- if (retryCount < MAX_RETRIES) {
226
- // Remove last user message from history to avoid duplication
227
- if (this.conversationHistory.length > 0 &&
228
- this.conversationHistory[this.conversationHistory.length - 1]?.role === 'user') {
229
- this.conversationHistory.pop();
230
- }
231
- // Wait before retry (exponential backoff: 1s, 2s, 4s)
232
- // const delayMs = Math.pow(2, retryCount) * 1000;
233
- await new Promise(resolve => setTimeout(resolve, 100000));
234
- // Silent retry - continue with "Continued" message
235
- return await this.handleUserInput('Continued', options, onMessage, retryCount + 1);
236
- }
237
- // Max retries exceeded - throw error to app.tsx
238
- throw new Error(`Đang bị lỗi. Hãy thử lại sau: `);
239
- }
240
- }
241
- /**
242
- * Clear conversation history
243
- */
244
- clearHistory() {
245
- this.conversationHistory = [];
246
- }
247
- /**
248
- * Get conversation history
249
- */
250
- getHistory() {
251
- return [...this.conversationHistory];
252
- }
253
- /**
254
- * Change model
255
- */
256
- setModel(model) {
257
- this.model = model;
258
- this.connection = new OllamaConnection({ model });
259
- }
260
- /**
261
- * Get current model
262
- */
263
- getModel() {
264
- return this.model;
265
- }
266
- }
267
- // Singleton instance with lazy initialization
268
- let _ollamaAgent = null;
269
- export const ollamaAgent = {
270
- get instance() {
271
- if (!_ollamaAgent) {
272
- _ollamaAgent = new OllamaAgent();
273
- }
274
- return _ollamaAgent;
275
- },
276
- };
@@ -1,16 +0,0 @@
1
- import type { ToolExecutionInfo } from '../connections/types.js';
2
- export interface OrchestratorOptions {
3
- gitEnabled: boolean;
4
- testEnabled: boolean;
5
- }
6
- export type MessageCallback = (author: 'user' | 'assistant' | 'system' | 'tool', content: string, toolName?: string, toolInfo?: ToolExecutionInfo) => void;
7
- export declare class OrchestratorAgent {
8
- private toolsRegistry;
9
- private connection;
10
- private tools;
11
- constructor();
12
- private getConnection;
13
- handleUserInput(input: string, options?: OrchestratorOptions, onMessage?: MessageCallback): Promise<{
14
- content: string;
15
- }>;
16
- }
@@ -1,76 +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 Orchestrator agent leveraging Gemini and registered tools.
7
- */
8
- import { GeminiConnection } from '../connections/gemini.js';
9
- import { ToolRegistry } from '../tools/index.js';
10
- import { orchestratorSystemPrompt } from '../prompts/orchestrator.js';
11
- export class OrchestratorAgent {
12
- constructor() {
13
- Object.defineProperty(this, "toolsRegistry", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: new ToolRegistry()
18
- });
19
- Object.defineProperty(this, "connection", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: null
24
- });
25
- Object.defineProperty(this, "tools", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: [
30
- 'ba_it_analyze',
31
- 'code_generate',
32
- 'file_list',
33
- 'file_search',
34
- 'file_tree',
35
- 'command_run',
36
- 'file_read',
37
- 'file_write',
38
- 'plan_task',
39
- 'git_status',
40
- 'git_commit',
41
- 'git_push',
42
- ]
43
- });
44
- // Lazy initialization - only create connection when needed
45
- }
46
- getConnection() {
47
- if (!this.connection) {
48
- // Special case: OrchestratorAgent gets apiKey directly from process.env
49
- const apiKey = process.env['GOOGLE_AI_API_KEY'] || process.env['GEMINI_API_KEY'];
50
- if (!apiKey) {
51
- throw new Error('OrchestratorAgent requires GOOGLE_AI_API_KEY or GEMINI_API_KEY in environment variables');
52
- }
53
- const systemPrompt = orchestratorSystemPrompt(this.toolsRegistry.getToolsContext(this.tools));
54
- this.connection = new GeminiConnection({
55
- type: 'gemini',
56
- model: 'gemini-2.5-flash',
57
- apiKey: apiKey,
58
- }, systemPrompt);
59
- }
60
- return this.connection;
61
- }
62
- async handleUserInput(input, options, onMessage) {
63
- try {
64
- // Pass options to plan_task via context
65
- const contextMessage = options
66
- ? `[System Context: Git=${options.gitEnabled ? 'ON' : 'OFF'}, Test Planning=${options.testEnabled ? 'ON' : 'OFF'}]\n\n${input}`
67
- : input;
68
- const result = await this.getConnection().chat(contextMessage, onMessage);
69
- const content = result?.trim() || '(No response)';
70
- return { content };
71
- }
72
- catch (error) {
73
- }
74
- return { content: '(Error occurred)' }; // Fallback in case of error
75
- }
76
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * BA IT Analyzer - Business Analyst for IT Projects
3
- * Analyzes user requirements and creates detailed functional specifications
4
- * NOW WITH DEEP THINK INTEGRATION for complex technical decisions!
5
- */
6
- export interface ProjectRequirement {
7
- type: 'create_project' | 'update_project';
8
- projectName: string;
9
- projectType: string;
10
- description: string;
11
- coreFeatures: Feature[];
12
- technicalStack: TechnicalStack;
13
- userStories: UserStory[];
14
- dataModel: DataEntity[];
15
- apiEndpoints?: APIEndpoint[];
16
- estimatedComplexity: 'simple' | 'medium' | 'complex';
17
- estimatedTime: string;
18
- recommendations: string[];
19
- questionsForUser: string[];
20
- deepAnalysis?: {
21
- question: string;
22
- insights: string;
23
- considerations: string[];
24
- }[];
25
- }
26
- export interface Feature {
27
- name: string;
28
- description: string;
29
- priority: 'must-have' | 'should-have' | 'nice-to-have';
30
- userStory: string;
31
- acceptanceCriteria: string[];
32
- }
33
- export interface TechnicalStack {
34
- frontend?: string[];
35
- backend?: string[];
36
- database?: string[];
37
- infrastructure?: string[];
38
- thirdParty?: string[];
39
- }
40
- export interface UserStory {
41
- as: string;
42
- iWant: string;
43
- soThat: string;
44
- acceptanceCriteria: string[];
45
- }
46
- export interface DataEntity {
47
- name: string;
48
- description: string;
49
- attributes: string[];
50
- relationships: string[];
51
- }
52
- export interface APIEndpoint {
53
- method: string;
54
- path: string;
55
- description: string;
56
- requestBody?: string;
57
- response: string;
58
- }
59
- export declare class BAITAnalyzer {
60
- private ollama;
61
- private model;
62
- constructor();
63
- private getConnection;
64
- analyze(userRequest: string, context?: string): Promise<ProjectRequirement>;
65
- private extractJSON;
66
- }