matex-cli 1.2.41 → 1.2.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/bro.d.ts +4 -0
- package/dist/commands/bro.d.ts.map +1 -0
- package/dist/commands/bro.js +304 -0
- package/dist/commands/bro.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/agent-orchestrator.d.ts +1 -1
- package/dist/utils/agent-orchestrator.d.ts.map +1 -1
- package/dist/utils/agent-orchestrator.js +14 -2
- package/dist/utils/agent-orchestrator.js.map +1 -1
- package/dist/utils/command-executor.d.ts.map +1 -1
- package/dist/utils/command-executor.js +38 -4
- package/dist/utils/command-executor.js.map +1 -1
- package/dist/utils/tui.d.ts.map +1 -1
- package/dist/utils/tui.js +51 -17
- package/dist/utils/tui.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/bro.ts +336 -0
- package/src/index.ts +12 -1
- package/src/utils/agent-orchestrator.ts +15 -3
- package/src/utils/command-executor.ts +44 -4
- package/src/utils/tui.ts +54 -18
- package/vertex_ai_agent.py +52 -0
|
@@ -267,6 +267,47 @@ export async function executeWithPermission(response: string, currentSessionCwd?
|
|
|
267
267
|
// 2. Handle Shell Commands
|
|
268
268
|
for (let i = 0; i < commands.length; i++) {
|
|
269
269
|
const command = commands[i];
|
|
270
|
+
|
|
271
|
+
// 🛡️ PRE-EXECUTION HALLUCINATION GUARD: Check for fake directories
|
|
272
|
+
const commandLines = command.code.split('\n');
|
|
273
|
+
let skipThisCommand = false;
|
|
274
|
+
let sanitizedCode = command.code;
|
|
275
|
+
|
|
276
|
+
for (const line of commandLines) {
|
|
277
|
+
const trimmed = line.trim();
|
|
278
|
+
// Check standalone cd commands
|
|
279
|
+
if (trimmed.startsWith('cd ')) {
|
|
280
|
+
let targetDir = trimmed.substring(3).replace(/['"]/g, '').trim();
|
|
281
|
+
const potentialCwd = path.isAbsolute(targetDir) ? targetDir : path.resolve(activeCwd, targetDir);
|
|
282
|
+
|
|
283
|
+
if (!fs.existsSync(potentialCwd) || !fs.statSync(potentialCwd).isDirectory()) {
|
|
284
|
+
console.log(chalk.yellow(`\n ⚠️ Skipped hallucinated directory: "${targetDir}"`));
|
|
285
|
+
console.log(chalk.gray(` (Does not exist at: ${potentialCwd})`));
|
|
286
|
+
console.log(chalk.gray(` Current CWD stays: ${activeCwd}\n`));
|
|
287
|
+
skipThisCommand = true;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// Check cd inside combined commands like: cd "fake" && npm install
|
|
292
|
+
const cdChainMatch = trimmed.match(/^cd\s+["']?([^"'&]+)["']?\s*&&/);
|
|
293
|
+
if (cdChainMatch) {
|
|
294
|
+
let targetDir = cdChainMatch[1].trim();
|
|
295
|
+
const potentialCwd = path.isAbsolute(targetDir) ? targetDir : path.resolve(activeCwd, targetDir);
|
|
296
|
+
|
|
297
|
+
if (!fs.existsSync(potentialCwd) || !fs.statSync(potentialCwd).isDirectory()) {
|
|
298
|
+
console.log(chalk.yellow(`\n ⚠️ Stripping hallucinated cd from command: "${targetDir}"`));
|
|
299
|
+
// Remove the cd part and execute the rest
|
|
300
|
+
sanitizedCode = trimmed.replace(/^cd\s+["']?[^"'&]+["']?\s*&&\s*/, '');
|
|
301
|
+
console.log(chalk.gray(` Running remaining: ${sanitizedCode}\n`));
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (skipThisCommand) continue;
|
|
307
|
+
|
|
308
|
+
// Update command code with sanitized version
|
|
309
|
+
command.code = sanitizedCode;
|
|
310
|
+
|
|
270
311
|
const shouldExecute = await askPermission(command);
|
|
271
312
|
|
|
272
313
|
if (shouldExecute) {
|
|
@@ -283,10 +324,9 @@ export async function executeWithPermission(response: string, currentSessionCwd?
|
|
|
283
324
|
if (fs.existsSync(potentialCwd) && fs.statSync(potentialCwd).isDirectory()) {
|
|
284
325
|
activeCwd = potentialCwd;
|
|
285
326
|
} else {
|
|
286
|
-
// Directory doesn't exist -
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
return { success: false, executed: true, error: errorMsg, newCwd: activeCwd };
|
|
327
|
+
// Directory doesn't exist - skip silently instead of crashing
|
|
328
|
+
console.log(chalk.yellow(` ⚠️ Directory not found: ${targetDir} — staying in ${activeCwd}`));
|
|
329
|
+
continue;
|
|
290
330
|
}
|
|
291
331
|
}
|
|
292
332
|
}
|
package/src/utils/tui.ts
CHANGED
|
@@ -134,26 +134,62 @@ export class TUI {
|
|
|
134
134
|
* Draw a beautiful, compact internal dialogue container for the Swarm
|
|
135
135
|
*/
|
|
136
136
|
static drawSwarmDialogue(agent: string, message: string) {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
137
|
+
const isBigBro = agent.includes('Big Bro');
|
|
138
|
+
const color = isBigBro ? chalk.hex('#FF6B00') :
|
|
139
|
+
agent.includes('Ajay') ? chalk.magenta :
|
|
140
|
+
agent.includes('Sunil') ? chalk.blue :
|
|
141
|
+
agent.includes('Sandip') ? chalk.hex('#FF69B4') :
|
|
142
|
+
agent.includes('Bishal') ? chalk.yellow :
|
|
143
|
+
agent.includes('Hype') ? chalk.hex('#fbbf24') :
|
|
144
|
+
agent.includes('Nerd') ? chalk.hex('#06b6d4') :
|
|
145
|
+
agent.includes('Chill') ? chalk.hex('#22c55e') :
|
|
146
|
+
agent.includes('Lil') ? chalk.hex('#888888') :
|
|
147
|
+
chalk.green;
|
|
148
|
+
|
|
149
|
+
const icon = isBigBro ? '🔥' :
|
|
150
|
+
agent.includes('Ajay') ? '🚀' :
|
|
151
|
+
agent.includes('Sunil') ? '🧬' :
|
|
152
|
+
agent.includes('Sandip') ? '🎨' :
|
|
153
|
+
agent.includes('Bishal') ? '🛠️' :
|
|
154
|
+
agent.includes('Hype') ? '🎉' :
|
|
155
|
+
agent.includes('Nerd') ? '🤓' :
|
|
156
|
+
agent.includes('Chill') ? '😎' :
|
|
157
|
+
agent.includes('Lil') ? '😰' : '🛡️';
|
|
158
|
+
|
|
159
|
+
const width = Math.min(process.stdout.columns || 80, 76);
|
|
160
|
+
const innerWidth = width - 6;
|
|
161
|
+
|
|
162
|
+
// Top border
|
|
163
|
+
console.log(color(` ┌${'─'.repeat(width - 4)}┐`));
|
|
164
|
+
// Header
|
|
165
|
+
const headerText = `${icon} ${agent}`;
|
|
166
|
+
const pad = Math.max(0, innerWidth - headerText.length);
|
|
167
|
+
console.log(color(' │ ') + color.bold(headerText) + ' '.repeat(pad) + color(' │'));
|
|
168
|
+
// Separator
|
|
169
|
+
console.log(color(` ├${'─'.repeat(width - 4)}┤`));
|
|
170
|
+
|
|
171
|
+
// Content lines with word wrap
|
|
172
|
+
const words = message.split(' ');
|
|
173
|
+
let currentLine = '';
|
|
174
|
+
const wrappedLines: string[] = [];
|
|
175
|
+
|
|
176
|
+
words.forEach(word => {
|
|
177
|
+
if ((currentLine + ' ' + word).trim().length <= innerWidth) {
|
|
178
|
+
currentLine = currentLine ? currentLine + ' ' + word : word;
|
|
179
|
+
} else {
|
|
180
|
+
if (currentLine) wrappedLines.push(currentLine);
|
|
181
|
+
currentLine = word.length > innerWidth ? word.substring(0, innerWidth) : word;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
if (currentLine) wrappedLines.push(currentLine);
|
|
150
185
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
console.log(` ${chalk.gray(line.trim())}`);
|
|
186
|
+
wrappedLines.forEach(line => {
|
|
187
|
+
const linePad = Math.max(0, innerWidth - line.length);
|
|
188
|
+
console.log(color(' │ ') + chalk.gray(line) + ' '.repeat(linePad) + color(' │'));
|
|
155
189
|
});
|
|
156
|
-
|
|
190
|
+
|
|
191
|
+
// Bottom border
|
|
192
|
+
console.log(color(` └${'─'.repeat(width - 4)}┘`));
|
|
157
193
|
}
|
|
158
194
|
|
|
159
195
|
/**
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Big Bro Swarm Leader — Vertex AI Agent Definition
|
|
3
|
+
==================================================
|
|
4
|
+
This is the Google ADK (Agent Development Kit) agent configuration
|
|
5
|
+
for the Big Bro Vertex AI agent deployed on Google Cloud.
|
|
6
|
+
|
|
7
|
+
Deploy via: Vertex AI Agent Builder > Import from Python
|
|
8
|
+
Project: matexai-472318
|
|
9
|
+
Model: gemini-2.5-flash
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from google.adk.agents import LlmAgent
|
|
13
|
+
from google.adk.tools import agent_tool
|
|
14
|
+
from google.adk.tools.google_search_tool import GoogleSearchTool
|
|
15
|
+
from google.adk.tools import url_context
|
|
16
|
+
|
|
17
|
+
# Sub-agent: Google Search
|
|
18
|
+
big_bro_swarm_leader_google_search_agent = LlmAgent(
|
|
19
|
+
name='Big_Bro_Swarm_Leader_google_search_agent',
|
|
20
|
+
model='gemini-2.5-flash',
|
|
21
|
+
description='Agent specialized in performing Google searches.',
|
|
22
|
+
sub_agents=[],
|
|
23
|
+
instruction='Use the GoogleSearchTool to find information on the web.',
|
|
24
|
+
tools=[GoogleSearchTool()],
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# Sub-agent: URL Context
|
|
28
|
+
big_bro_swarm_leader_url_context_agent = LlmAgent(
|
|
29
|
+
name='Big_Bro_Swarm_Leader_url_context_agent',
|
|
30
|
+
model='gemini-2.5-flash',
|
|
31
|
+
description='Agent specialized in fetching content from URLs.',
|
|
32
|
+
sub_agents=[],
|
|
33
|
+
instruction='Use the UrlContextTool to retrieve content from provided URLs.',
|
|
34
|
+
tools=[url_context],
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Root Agent: Big Bro
|
|
38
|
+
root_agent = LlmAgent(
|
|
39
|
+
name='Big_Bro_Swarm_Leader',
|
|
40
|
+
model='gemini-2.5-flash',
|
|
41
|
+
description=(
|
|
42
|
+
'The ultimate alpha orchestrator of the Bro Swarm. '
|
|
43
|
+
'He commands Lil Bro, brings the chaos, and dominates tasks '
|
|
44
|
+
'with pure swagger and zero apologies.'
|
|
45
|
+
),
|
|
46
|
+
sub_agents=[],
|
|
47
|
+
instruction=open('vertex_ai_big_bro_ULTIMATE.md', 'r').read(),
|
|
48
|
+
tools=[
|
|
49
|
+
agent_tool.AgentTool(agent=big_bro_swarm_leader_google_search_agent),
|
|
50
|
+
agent_tool.AgentTool(agent=big_bro_swarm_leader_url_context_agent),
|
|
51
|
+
],
|
|
52
|
+
)
|