galaxy-code 0.1.0 → 0.1.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.
Files changed (143) hide show
  1. package/dist/app.js +4 -3
  2. package/dist/node_modules/@workspace/agent-core/connections/claude.d.ts +72 -0
  3. package/dist/node_modules/@workspace/agent-core/connections/claude.d.ts.map +1 -0
  4. package/dist/node_modules/@workspace/agent-core/connections/claude.js +270 -0
  5. package/dist/node_modules/@workspace/agent-core/connections/claude.js.map +1 -0
  6. package/dist/node_modules/@workspace/agent-core/connections/gemini.d.ts +41 -0
  7. package/dist/node_modules/@workspace/agent-core/connections/gemini.d.ts.map +1 -0
  8. package/dist/node_modules/@workspace/agent-core/connections/gemini.js +203 -0
  9. package/dist/node_modules/@workspace/agent-core/connections/gemini.js.map +1 -0
  10. package/dist/node_modules/@workspace/agent-core/connections/index.d.ts +12 -0
  11. package/dist/node_modules/@workspace/agent-core/connections/index.d.ts.map +1 -0
  12. package/dist/node_modules/@workspace/agent-core/connections/index.js +12 -0
  13. package/dist/node_modules/@workspace/agent-core/connections/index.js.map +1 -0
  14. package/dist/node_modules/@workspace/agent-core/connections/ollama.d.ts +38 -0
  15. package/dist/node_modules/@workspace/agent-core/connections/ollama.d.ts.map +1 -0
  16. package/dist/node_modules/@workspace/agent-core/connections/ollama.js +64 -0
  17. package/dist/node_modules/@workspace/agent-core/connections/ollama.js.map +1 -0
  18. package/dist/node_modules/@workspace/agent-core/connections/types.d.ts +23 -0
  19. package/dist/node_modules/@workspace/agent-core/connections/types.d.ts.map +1 -0
  20. package/dist/node_modules/@workspace/agent-core/connections/types.js +8 -0
  21. package/dist/node_modules/@workspace/agent-core/connections/types.js.map +1 -0
  22. package/dist/node_modules/@workspace/agent-core/index.d.ts +13 -0
  23. package/dist/node_modules/@workspace/agent-core/index.d.ts.map +1 -0
  24. package/dist/node_modules/@workspace/agent-core/index.js +22 -0
  25. package/dist/node_modules/@workspace/agent-core/index.js.map +1 -0
  26. package/dist/node_modules/@workspace/agent-core/package.json +53 -0
  27. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.d.ts +2 -0
  28. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.d.ts.map +1 -0
  29. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.js +144 -0
  30. package/dist/node_modules/@workspace/agent-core/prompts/ba-it-analyzer.js.map +1 -0
  31. package/dist/node_modules/@workspace/agent-core/prompts/index.d.ts +12 -0
  32. package/dist/node_modules/@workspace/agent-core/prompts/index.d.ts.map +1 -0
  33. package/dist/node_modules/@workspace/agent-core/prompts/index.js +12 -0
  34. package/dist/node_modules/@workspace/agent-core/prompts/index.js.map +1 -0
  35. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.d.ts +9 -0
  36. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.d.ts.map +1 -0
  37. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.js +89 -0
  38. package/dist/node_modules/@workspace/agent-core/prompts/orchestrator.js.map +1 -0
  39. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.d.ts +9 -0
  40. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.d.ts.map +1 -0
  41. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.js +196 -0
  42. package/dist/node_modules/@workspace/agent-core/prompts/planning-agent.js.map +1 -0
  43. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.d.ts +8 -0
  44. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.d.ts.map +1 -0
  45. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.js +112 -0
  46. package/dist/node_modules/@workspace/agent-core/prompts/universal-agent.js.map +1 -0
  47. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.d.ts +30 -0
  48. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.d.ts.map +1 -0
  49. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.js +76 -0
  50. package/dist/node_modules/@workspace/agent-core/providers/agent-selector.js.map +1 -0
  51. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.d.ts +30 -0
  52. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.d.ts.map +1 -0
  53. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.js +107 -0
  54. package/dist/node_modules/@workspace/agent-core/providers/claude-agent.js.map +1 -0
  55. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.d.ts +37 -0
  56. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.d.ts.map +1 -0
  57. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.js +144 -0
  58. package/dist/node_modules/@workspace/agent-core/providers/gemini-agent.js.map +1 -0
  59. package/dist/node_modules/@workspace/agent-core/providers/index.d.ts +13 -0
  60. package/dist/node_modules/@workspace/agent-core/providers/index.d.ts.map +1 -0
  61. package/dist/node_modules/@workspace/agent-core/providers/index.js +13 -0
  62. package/dist/node_modules/@workspace/agent-core/providers/index.js.map +1 -0
  63. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.d.ts +54 -0
  64. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.d.ts.map +1 -0
  65. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.js +247 -0
  66. package/dist/node_modules/@workspace/agent-core/providers/ollama-agent.js.map +1 -0
  67. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.d.ts +17 -0
  68. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.d.ts.map +1 -0
  69. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.js +62 -0
  70. package/dist/node_modules/@workspace/agent-core/providers/orchestrator.js.map +1 -0
  71. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.d.ts +67 -0
  72. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.d.ts.map +1 -0
  73. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.js +81 -0
  74. package/dist/node_modules/@workspace/agent-core/tools/ba-it-analyzer.js.map +1 -0
  75. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.d.ts +52 -0
  76. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.d.ts.map +1 -0
  77. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.js +150 -0
  78. package/dist/node_modules/@workspace/agent-core/tools/code-generate-agent.js.map +1 -0
  79. package/dist/node_modules/@workspace/agent-core/tools/command-runner.d.ts +15 -0
  80. package/dist/node_modules/@workspace/agent-core/tools/command-runner.d.ts.map +1 -0
  81. package/dist/node_modules/@workspace/agent-core/tools/command-runner.js +121 -0
  82. package/dist/node_modules/@workspace/agent-core/tools/command-runner.js.map +1 -0
  83. package/dist/node_modules/@workspace/agent-core/tools/document-parser.d.ts +12 -0
  84. package/dist/node_modules/@workspace/agent-core/tools/document-parser.d.ts.map +1 -0
  85. package/dist/node_modules/@workspace/agent-core/tools/document-parser.js +84 -0
  86. package/dist/node_modules/@workspace/agent-core/tools/document-parser.js.map +1 -0
  87. package/dist/node_modules/@workspace/agent-core/tools/file-operations.d.ts +18 -0
  88. package/dist/node_modules/@workspace/agent-core/tools/file-operations.d.ts.map +1 -0
  89. package/dist/node_modules/@workspace/agent-core/tools/file-operations.js +126 -0
  90. package/dist/node_modules/@workspace/agent-core/tools/file-operations.js.map +1 -0
  91. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.d.ts +95 -0
  92. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.d.ts.map +1 -0
  93. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.js +245 -0
  94. package/dist/node_modules/@workspace/agent-core/tools/galaxy-ui-integration.js.map +1 -0
  95. package/dist/node_modules/@workspace/agent-core/tools/git-operations.d.ts +12 -0
  96. package/dist/node_modules/@workspace/agent-core/tools/git-operations.d.ts.map +1 -0
  97. package/dist/node_modules/@workspace/agent-core/tools/git-operations.js +115 -0
  98. package/dist/node_modules/@workspace/agent-core/tools/git-operations.js.map +1 -0
  99. package/dist/node_modules/@workspace/agent-core/tools/index.d.ts +11 -0
  100. package/dist/node_modules/@workspace/agent-core/tools/index.d.ts.map +1 -0
  101. package/dist/node_modules/@workspace/agent-core/tools/index.js +11 -0
  102. package/dist/node_modules/@workspace/agent-core/tools/index.js.map +1 -0
  103. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.d.ts +30 -0
  104. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.d.ts.map +1 -0
  105. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.js +125 -0
  106. package/dist/node_modules/@workspace/agent-core/tools/planning-agent.js.map +1 -0
  107. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.d.ts +20 -0
  108. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.d.ts.map +1 -0
  109. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.js +46 -0
  110. package/dist/node_modules/@workspace/agent-core/tools/progress-reporter.js.map +1 -0
  111. package/dist/node_modules/@workspace/agent-core/tools/registry.d.ts +22 -0
  112. package/dist/node_modules/@workspace/agent-core/tools/registry.d.ts.map +1 -0
  113. package/dist/node_modules/@workspace/agent-core/tools/registry.js +651 -0
  114. package/dist/node_modules/@workspace/agent-core/tools/registry.js.map +1 -0
  115. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.d.ts +25 -0
  116. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.d.ts.map +1 -0
  117. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.js +26 -0
  118. package/dist/node_modules/@workspace/agent-core/tools/tool-event-emitter.js.map +1 -0
  119. package/dist/node_modules/@workspace/agent-core/tools/types.d.ts +32 -0
  120. package/dist/node_modules/@workspace/agent-core/tools/types.d.ts.map +1 -0
  121. package/dist/node_modules/@workspace/agent-core/tools/types.js +2 -0
  122. package/dist/node_modules/@workspace/agent-core/tools/types.js.map +1 -0
  123. package/dist/node_modules/@workspace/agent-core/types.d.ts +40 -0
  124. package/dist/node_modules/@workspace/agent-core/types.d.ts.map +1 -0
  125. package/dist/node_modules/@workspace/agent-core/types.js +9 -0
  126. package/dist/node_modules/@workspace/agent-core/types.js.map +1 -0
  127. package/dist/node_modules/@workspace/agent-core/utils/config-manager.d.ts +103 -0
  128. package/dist/node_modules/@workspace/agent-core/utils/config-manager.d.ts.map +1 -0
  129. package/dist/node_modules/@workspace/agent-core/utils/config-manager.js +307 -0
  130. package/dist/node_modules/@workspace/agent-core/utils/config-manager.js.map +1 -0
  131. package/dist/node_modules/@workspace/agent-core/utils/devtools.d.ts +22 -0
  132. package/dist/node_modules/@workspace/agent-core/utils/devtools.d.ts.map +1 -0
  133. package/dist/node_modules/@workspace/agent-core/utils/devtools.js +62 -0
  134. package/dist/node_modules/@workspace/agent-core/utils/devtools.js.map +1 -0
  135. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.d.ts +33 -0
  136. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.d.ts.map +1 -0
  137. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.js +591 -0
  138. package/dist/node_modules/@workspace/agent-core/utils/message-formatters.js.map +1 -0
  139. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.d.ts +60 -0
  140. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.d.ts.map +1 -0
  141. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.js +204 -0
  142. package/dist/node_modules/@workspace/agent-core/utils/progress-tracker.js.map +1 -0
  143. package/package.json +4 -2
@@ -0,0 +1,651 @@
1
+ /**
2
+ * @author Bùi Trọng Hiếu
3
+ * @email kevinbui210191@gmail.com
4
+ * @create 2024-10-08
5
+ * @modify 2024-10-08
6
+ * @desc In-memory registry for AI tools.
7
+ */
8
+ import { BAITAnalyzer } from './ba-it-analyzer.js';
9
+ import { CommandRunner } from './command-runner.js';
10
+ import { DocumentParser } from './document-parser.js';
11
+ import { FileOperations } from './file-operations.js';
12
+ import { GitOperations } from './git-operations.js';
13
+ import { PlanningAgent } from './planning-agent.js';
14
+ import { CodeGenerateAgent } from './code-generate-agent.js';
15
+ import { ProgressReporter } from './progress-reporter.js';
16
+ import * as GalaxyUI from './galaxy-ui-integration.js';
17
+ import { toolEventEmitter } from './tool-event-emitter.js';
18
+ export class ToolRegistry {
19
+ tools = new Map();
20
+ fileOps = new FileOperations();
21
+ gitOps = new GitOperations();
22
+ commandRunner = new CommandRunner();
23
+ baAnalyzer = new BAITAnalyzer();
24
+ documentParser = new DocumentParser();
25
+ planningAgent = new PlanningAgent();
26
+ codeGenerateAgent = new CodeGenerateAgent();
27
+ progressReporter = new ProgressReporter();
28
+ constructor() {
29
+ this.registerAllTools();
30
+ }
31
+ registerAllTools() {
32
+ // File operations
33
+ this.register({
34
+ name: 'file_read',
35
+ description: 'Read content of a file',
36
+ inputSchema: {
37
+ type: 'object',
38
+ properties: {
39
+ path: { type: 'string', description: 'File path to read' },
40
+ },
41
+ required: ['path'],
42
+ },
43
+ execute: async (args) => await this.fileOps.readFile(args.path),
44
+ });
45
+ this.register({
46
+ name: 'file_write',
47
+ description: 'Write content to a file (creates directories if needed)',
48
+ inputSchema: {
49
+ type: 'object',
50
+ properties: {
51
+ path: { type: 'string', description: 'File path to write' },
52
+ content: { type: 'string', description: 'Content to write' },
53
+ },
54
+ required: ['path', 'content'],
55
+ },
56
+ execute: async (args) => {
57
+ const result = await this.fileOps.writeFile(args.path, args.content);
58
+ // Return as JSON string for tool result
59
+ return JSON.stringify(result);
60
+ },
61
+ });
62
+ this.register({
63
+ name: 'file_list',
64
+ description: 'List files in a directory',
65
+ inputSchema: {
66
+ type: 'object',
67
+ properties: {
68
+ path: { type: 'string', description: 'Directory path' },
69
+ recursive: {
70
+ type: 'boolean',
71
+ description: 'Recursive listing',
72
+ default: false,
73
+ },
74
+ },
75
+ required: ['path'],
76
+ },
77
+ execute: async (args) => {
78
+ const files = await this.fileOps.listFiles(args.path, args.recursive);
79
+ return files.join('\n');
80
+ },
81
+ });
82
+ this.register({
83
+ name: 'file_search',
84
+ description: 'Search for pattern in files',
85
+ inputSchema: {
86
+ type: 'object',
87
+ properties: {
88
+ path: { type: 'string', description: 'Directory to search in' },
89
+ pattern: { type: 'string', description: 'Pattern to search for' },
90
+ },
91
+ required: ['path', 'pattern'],
92
+ },
93
+ execute: async (args) => {
94
+ const matches = await this.fileOps.searchFiles(args.path, args.pattern);
95
+ return matches.join('\n') || 'No matches found';
96
+ },
97
+ });
98
+ this.register({
99
+ name: 'file_tree',
100
+ description: 'Get file tree structure of a directory',
101
+ inputSchema: {
102
+ type: 'object',
103
+ properties: {
104
+ path: { type: 'string', description: 'Directory path' },
105
+ },
106
+ required: ['path'],
107
+ },
108
+ execute: async (args) => await this.fileOps.getFileTree(args.path),
109
+ });
110
+ // Git operations
111
+ this.register({
112
+ name: 'git_status',
113
+ description: 'Get git status of repository',
114
+ inputSchema: {
115
+ type: 'object',
116
+ properties: {
117
+ cwd: { type: 'string', description: 'Working directory' },
118
+ },
119
+ required: ['cwd'],
120
+ },
121
+ execute: async (args) => await this.gitOps.getStatus(args.cwd || process.cwd()),
122
+ });
123
+ this.register({
124
+ name: 'git_commit',
125
+ description: 'Commit changes with message',
126
+ inputSchema: {
127
+ type: 'object',
128
+ properties: {
129
+ cwd: { type: 'string', description: 'Working directory' },
130
+ message: { type: 'string', description: 'Commit message' },
131
+ },
132
+ required: ['cwd', 'message'],
133
+ },
134
+ execute: async (args) => await this.gitOps.commit(args.cwd || process.cwd(), args.message),
135
+ });
136
+ this.register({
137
+ name: 'git_push',
138
+ description: 'Push commits to remote',
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ cwd: { type: 'string', description: 'Working directory' },
143
+ remote: {
144
+ type: 'string',
145
+ description: 'Remote name',
146
+ default: 'origin',
147
+ },
148
+ branch: { type: 'string', description: 'Branch name (optional)' },
149
+ },
150
+ required: ['cwd'],
151
+ },
152
+ execute: async (args) => await this.gitOps.push(args.cwd || process.cwd(), args.remote || 'origin', args.branch),
153
+ });
154
+ this.register({
155
+ name: 'git_pull',
156
+ description: 'Pull changes from remote',
157
+ inputSchema: {
158
+ type: 'object',
159
+ properties: {
160
+ cwd: { type: 'string', description: 'Working directory' },
161
+ remote: {
162
+ type: 'string',
163
+ description: 'Remote name',
164
+ default: 'origin',
165
+ },
166
+ branch: { type: 'string', description: 'Branch name (optional)' },
167
+ },
168
+ required: ['cwd'],
169
+ },
170
+ execute: async (args) => await this.gitOps.pull(args.cwd || process.cwd(), args.remote || 'origin', args.branch),
171
+ });
172
+ this.register({
173
+ name: 'git_diff',
174
+ description: 'Show git diff',
175
+ inputSchema: {
176
+ type: 'object',
177
+ properties: {
178
+ cwd: { type: 'string', description: 'Working directory' },
179
+ file: { type: 'string', description: 'Specific file (optional)' },
180
+ },
181
+ required: ['cwd'],
182
+ },
183
+ execute: async (args) => await this.gitOps.getDiff(args.cwd || process.cwd(), args.file),
184
+ });
185
+ this.register({
186
+ name: 'git_log',
187
+ description: 'Show git commit history',
188
+ inputSchema: {
189
+ type: 'object',
190
+ properties: {
191
+ cwd: { type: 'string', description: 'Working directory' },
192
+ limit: {
193
+ type: 'number',
194
+ description: 'Number of commits',
195
+ default: 10,
196
+ },
197
+ },
198
+ required: ['cwd'],
199
+ },
200
+ execute: async (args) => await this.gitOps.getLog(args.cwd || process.cwd(), args.limit || 10),
201
+ });
202
+ this.register({
203
+ name: 'git_branches',
204
+ description: 'List all branches',
205
+ inputSchema: {
206
+ type: 'object',
207
+ properties: {
208
+ cwd: { type: 'string', description: 'Working directory' },
209
+ },
210
+ required: ['cwd'],
211
+ },
212
+ execute: async (args) => await this.gitOps.listBranches(args.cwd || process.cwd()),
213
+ });
214
+ // Command runner
215
+ this.register({
216
+ name: 'command_run',
217
+ description: 'Run a shell command',
218
+ inputSchema: {
219
+ type: 'object',
220
+ properties: {
221
+ command: { type: 'string', description: 'Command to execute' },
222
+ cwd: { type: 'string', description: 'Working directory' },
223
+ timeout: {
224
+ type: 'number',
225
+ description: 'Timeout in ms',
226
+ default: 60000,
227
+ },
228
+ },
229
+ required: ['command', 'cwd'],
230
+ },
231
+ execute: async (args) => {
232
+ const result = await this.commandRunner.runCommand(args.command, args.cwd || process.cwd(), args.timeout || 60000);
233
+ return `stdout:\n${result.stdout}\n\nstderr:\n${result.stderr}`;
234
+ },
235
+ });
236
+ this.register({
237
+ name: 'test_run',
238
+ description: 'Run tests in project',
239
+ inputSchema: {
240
+ type: 'object',
241
+ properties: {
242
+ cwd: { type: 'string', description: 'Project directory' },
243
+ command: {
244
+ type: 'string',
245
+ description: 'Custom test command (optional)',
246
+ },
247
+ },
248
+ required: ['cwd'],
249
+ },
250
+ execute: async (args) => {
251
+ const testCommand = args.command || (await this.commandRunner.detectTestCommand(args.cwd || process.cwd()));
252
+ if (!testCommand)
253
+ return 'No test command found';
254
+ const result = await this.commandRunner.runCommand(testCommand, args.cwd || process.cwd(), 120000);
255
+ return `Test Output:\n${result.stdout}\n\nErrors:\n${result.stderr}`;
256
+ },
257
+ });
258
+ this.register({
259
+ name: 'install_dependencies',
260
+ description: 'Install project dependencies (auto-detects package manager)',
261
+ inputSchema: {
262
+ type: 'object',
263
+ properties: {
264
+ cwd: { type: 'string', description: 'Project directory' },
265
+ },
266
+ required: ['cwd'],
267
+ },
268
+ execute: async (args) => {
269
+ const result = await this.commandRunner.installDependencies(args.cwd || process.cwd());
270
+ return `Installation Output:\n${result.stdout}\n\nErrors:\n${result.stderr}`;
271
+ },
272
+ });
273
+ // BA IT Analyzer Tool
274
+ this.register({
275
+ name: 'ba_it_analyze',
276
+ description: 'Business Analyst for IT projects. Analyzes user requirements and creates comprehensive project specifications with features, tech stack, user stories, data model, and recommendations.',
277
+ inputSchema: {
278
+ type: 'object',
279
+ properties: {
280
+ userRequest: {
281
+ type: 'string',
282
+ description: "User's project request or requirement",
283
+ },
284
+ context: {
285
+ type: 'string',
286
+ description: 'Additional context about the project (optional)',
287
+ },
288
+ },
289
+ required: ['userRequest'],
290
+ },
291
+ execute: async (args) => {
292
+ const requirement = await this.baAnalyzer.analyze(args.userRequest, args.context);
293
+ return requirement;
294
+ },
295
+ });
296
+ // Document parser
297
+ this.register({
298
+ name: 'document_parse',
299
+ description: 'Parse document and extract text. Supports: pdf, docx, xlsx (auto-detected from file extension)',
300
+ inputSchema: {
301
+ type: 'object',
302
+ properties: {
303
+ path: { type: 'string', description: 'Document file path' },
304
+ type: {
305
+ type: 'string',
306
+ description: 'Type: pdf, docx, xlsx (optional, auto-detected)',
307
+ },
308
+ },
309
+ required: ['path'],
310
+ },
311
+ execute: async (args) => {
312
+ // Auto-detect type from file extension if not provided
313
+ let docType = args.type?.toLowerCase();
314
+ if (!docType) {
315
+ const ext = args.path.split('.').pop()?.toLowerCase();
316
+ docType = (ext === 'doc' ? 'docx' : ext === 'xls' ? 'xlsx' : ext) || 'docx';
317
+ }
318
+ // Validate type
319
+ if (!['pdf', 'docx', 'xlsx'].includes(docType || '')) {
320
+ return `Error: Unsupported document type "${docType}". Supported: PDF, DOCX, XLSX`;
321
+ }
322
+ return await this.documentParser.parseDocument(args.path, docType);
323
+ },
324
+ });
325
+ // Planning Agent Tool
326
+ this.register({
327
+ name: 'plan_task',
328
+ description: 'Create step-by-step execution plan based on user context and optional BA analysis. Uses qwen3-coder:480b-cloud for intelligent planning.',
329
+ inputSchema: {
330
+ type: 'object',
331
+ properties: {
332
+ userContext: {
333
+ type: 'string',
334
+ description: 'User request/context (REQUIRED)',
335
+ },
336
+ baAnalysis: {
337
+ type: 'object',
338
+ description: 'BA IT Analysis result (OPTIONAL - if available from ba_it_analyze)',
339
+ },
340
+ },
341
+ required: ['userContext'],
342
+ },
343
+ execute: async (args) => {
344
+ const plan = await this.planningAgent.generatePlan(args.userContext, args.baAnalysis);
345
+ // Add critical reminder to plan result
346
+ const planWithReminder = {
347
+ ...plan,
348
+ reminder: '⚠️ CRITICAL: You MUST call progress_reporter({step: N, status: "success"|"error"}) after EVERY step execution. NO EXCEPTIONS.',
349
+ };
350
+ return planWithReminder;
351
+ },
352
+ });
353
+ // Progress Reporter Tool
354
+ this.register({
355
+ name: 'progress_reporter',
356
+ description: 'Report task completion status for planning steps. Emits events to update UI progress tracking.',
357
+ inputSchema: {
358
+ type: 'object',
359
+ properties: {
360
+ step: {
361
+ type: 'number',
362
+ description: 'Step number from plan',
363
+ },
364
+ status: {
365
+ type: 'string',
366
+ description: 'Step status: success, error, or in_progress',
367
+ },
368
+ message: {
369
+ type: 'string',
370
+ description: 'Optional status message',
371
+ },
372
+ filesCreated: {
373
+ type: 'array',
374
+ description: 'List of files created in this step',
375
+ items: { type: 'string' },
376
+ },
377
+ commandsRun: {
378
+ type: 'array',
379
+ description: 'List of commands executed in this step',
380
+ items: { type: 'string' },
381
+ },
382
+ },
383
+ required: ['step', 'status'],
384
+ },
385
+ execute: async (args) => {
386
+ return this.progressReporter.reportProgress(args);
387
+ },
388
+ });
389
+ // Code Generate Agent Tool - Feature executor
390
+ this.register({
391
+ name: 'code_generate',
392
+ description: 'Execute feature implementation with integrated tools. Generates code, writes files, runs commands automatically. Uses qwen3-coder:480b-cloud.',
393
+ inputSchema: {
394
+ type: 'object',
395
+ properties: {
396
+ step: {
397
+ type: 'number',
398
+ description: 'Step number from plan',
399
+ },
400
+ featureName: {
401
+ type: 'string',
402
+ description: 'Feature name from coreFeatures',
403
+ },
404
+ featureDescription: {
405
+ type: 'string',
406
+ description: 'Feature description',
407
+ },
408
+ priority: {
409
+ type: 'string',
410
+ description: 'must-have | should-have | nice-to-have',
411
+ },
412
+ technicalStack: {
413
+ type: 'object',
414
+ description: 'Tech stack from BA analysis',
415
+ },
416
+ userStories: {
417
+ type: 'array',
418
+ description: 'User stories (optional)',
419
+ },
420
+ dataModel: {
421
+ type: 'array',
422
+ description: 'Data model entities (optional)',
423
+ },
424
+ apiEndpoints: {
425
+ type: 'array',
426
+ description: 'API endpoints (optional)',
427
+ },
428
+ acceptanceCriteria: {
429
+ type: 'array',
430
+ description: 'Acceptance criteria (optional)',
431
+ },
432
+ },
433
+ required: ['step', 'featureName', 'featureDescription', 'technicalStack'],
434
+ },
435
+ execute: async (args) => {
436
+ const result = await this.codeGenerateAgent.execute({
437
+ step: args.step,
438
+ featureName: args.featureName,
439
+ featureDescription: args.featureDescription,
440
+ priority: args.priority || 'must-have',
441
+ technicalStack: args.technicalStack,
442
+ userStories: args.userStories,
443
+ dataModel: args.dataModel,
444
+ apiEndpoints: args.apiEndpoints,
445
+ acceptanceCriteria: args.acceptanceCriteria,
446
+ });
447
+ return result;
448
+ },
449
+ });
450
+ // Galaxy UI Integration Tools
451
+ this.register({
452
+ name: 'galaxy_ui_list',
453
+ description: 'List all Galaxy UI components. Optional filter by category: form, layout, navigation, interactive, overlay, data-display, utility',
454
+ inputSchema: {
455
+ type: 'object',
456
+ properties: {
457
+ category: {
458
+ type: 'string',
459
+ description: 'Filter by category: form, layout, navigation, interactive, overlay, data-display, utility, all',
460
+ },
461
+ },
462
+ },
463
+ execute: async (args) => {
464
+ const result = await GalaxyUI.galaxyUIListComponents(args);
465
+ return JSON.stringify(result, null, 2);
466
+ },
467
+ });
468
+ this.register({
469
+ name: 'galaxy_ui_search',
470
+ description: 'Search Galaxy UI components by keyword in name, description, or category',
471
+ inputSchema: {
472
+ type: 'object',
473
+ properties: {
474
+ query: { type: 'string', description: 'Search query' },
475
+ },
476
+ required: ['query'],
477
+ },
478
+ execute: async (args) => {
479
+ const result = await GalaxyUI.galaxyUISearchComponents(args);
480
+ return JSON.stringify(result, null, 2);
481
+ },
482
+ });
483
+ this.register({
484
+ name: 'galaxy_ui_get_component',
485
+ description: 'Get detailed information about a specific Galaxy UI component including dependencies, docs URL, and install command',
486
+ inputSchema: {
487
+ type: 'object',
488
+ properties: {
489
+ name: { type: 'string', description: 'Component name' },
490
+ framework: {
491
+ type: 'string',
492
+ description: 'Framework: vue, react, angular (optional)',
493
+ },
494
+ },
495
+ required: ['name'],
496
+ },
497
+ execute: async (args) => {
498
+ const result = await GalaxyUI.galaxyUIGetComponent(args);
499
+ return JSON.stringify(result, null, 2);
500
+ },
501
+ });
502
+ this.register({
503
+ name: 'galaxy_ui_categories',
504
+ description: 'Get all Galaxy UI component categories with component counts',
505
+ inputSchema: {
506
+ type: 'object',
507
+ properties: {},
508
+ },
509
+ execute: async () => {
510
+ const result = await GalaxyUI.galaxyUIGetCategories();
511
+ return JSON.stringify(result, null, 2);
512
+ },
513
+ });
514
+ this.register({
515
+ name: 'galaxy_ui_add',
516
+ description: 'Add Galaxy UI components to the project. Executes: npx galaxy-design@latest add [components...]',
517
+ inputSchema: {
518
+ type: 'object',
519
+ properties: {
520
+ components: {
521
+ type: 'array',
522
+ description: 'Array of component names to add',
523
+ items: { type: 'string' },
524
+ },
525
+ cwd: { type: 'string', description: 'Working directory (optional)' },
526
+ },
527
+ required: ['components'],
528
+ },
529
+ execute: async (args) => {
530
+ const result = await GalaxyUI.galaxyUIAddComponents(args);
531
+ return JSON.stringify(result, null, 2);
532
+ },
533
+ });
534
+ this.register({
535
+ name: 'galaxy_ui_init',
536
+ description: 'Initialize Galaxy UI in the project. Executes: npx galaxy-design@latest init',
537
+ inputSchema: {
538
+ type: 'object',
539
+ properties: {
540
+ cwd: { type: 'string', description: 'Working directory (optional)' },
541
+ skipPrompts: {
542
+ type: 'boolean',
543
+ description: 'Skip prompts and use defaults (optional)',
544
+ },
545
+ },
546
+ },
547
+ execute: async (args) => {
548
+ const result = await GalaxyUI.galaxyUIInit(args);
549
+ return JSON.stringify(result, null, 2);
550
+ },
551
+ });
552
+ this.register({
553
+ name: 'galaxy_ui_docs',
554
+ description: 'Get documentation URL for Galaxy UI components or main documentation',
555
+ inputSchema: {
556
+ type: 'object',
557
+ properties: {
558
+ component: {
559
+ type: 'string',
560
+ description: 'Component name (optional)',
561
+ },
562
+ language: {
563
+ type: 'string',
564
+ description: 'Language: en or vi (optional)',
565
+ },
566
+ },
567
+ },
568
+ execute: async (args) => {
569
+ const result = GalaxyUI.galaxyUIGetDocsUrl(args);
570
+ return JSON.stringify(result, null, 2);
571
+ },
572
+ });
573
+ }
574
+ register(tool) {
575
+ if (this.tools.has(tool.name)) {
576
+ throw new Error(`Tool with name "${tool.name}" is already registered.`);
577
+ }
578
+ this.tools.set(tool.name, tool);
579
+ }
580
+ get(name) {
581
+ return this.tools.get(name);
582
+ }
583
+ list() {
584
+ return [...this.tools.values()];
585
+ }
586
+ getToolsContext(args) {
587
+ const todoList = args
588
+ .map((name) => this.tools.get(name))
589
+ .map((tool) => {
590
+ return `- ${tool?.name}: ${tool?.description}`;
591
+ });
592
+ return `Available Tools:
593
+ ${todoList.join('\n')}
594
+ `;
595
+ }
596
+ //Lấy list tool dựa trên list args name
597
+ getToolsByNames(names) {
598
+ return (names?.map(name => this.tools.get(name)).filter((tool) => tool !== undefined) || [
599
+ ...this.tools.values(),
600
+ ]);
601
+ }
602
+ // Execute a tool by name with given arguments
603
+ async executeTool(name, args) {
604
+ const tool = this.tools.get(name);
605
+ if (!tool) {
606
+ throw new Error(`Tool "${name}" not found in registry`);
607
+ }
608
+ // Skip emit for progress_reporter (it emits internally)
609
+ const skipEmit = name === 'progress_reporter';
610
+ try {
611
+ // Create execution context (empty for now, can add abortSignal if needed)
612
+ const context = {};
613
+ // Execute the tool with args and context
614
+ const result = await tool.execute(args, context);
615
+ // Emit success event
616
+ if (!skipEmit) {
617
+ const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
618
+ toolEventEmitter.emitToolExecution({
619
+ toolName: name,
620
+ content: resultStr,
621
+ status: 'success',
622
+ toolInfo: {
623
+ toolName: name,
624
+ args,
625
+ result,
626
+ },
627
+ });
628
+ }
629
+ return result;
630
+ }
631
+ catch (error) {
632
+ // Emit error event
633
+ if (!skipEmit) {
634
+ const errorMsg = error instanceof Error ? error.message : String(error);
635
+ toolEventEmitter.emitToolExecution({
636
+ toolName: name,
637
+ content: `Error: ${errorMsg}`,
638
+ status: 'error',
639
+ error: errorMsg,
640
+ toolInfo: {
641
+ toolName: name,
642
+ args,
643
+ },
644
+ });
645
+ }
646
+ throw error;
647
+ }
648
+ }
649
+ }
650
+ export const globalToolRegistry = new ToolRegistry();
651
+ //# sourceMappingURL=registry.js.map