diff options
| author | Castor Gemini <[email protected]> | 2025-08-22 04:47:19 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-08-22 04:47:19 -0500 |
| commit | 1e7a6d9e1e72b26c96f17115c39791f29872aabb (patch) | |
| tree | 8ca51299ab5626b9a2cea8ec43360799b19c1d7f /packages/cli/src/ui/components/messages/GeminiMessage.tsx | |
| parent | 75cb06079ea3e7fd4795083c17b0c3acf2bd94ad (diff) | |
feat(ui): Execute 'gemini --output' on new messages
- Modify the GeminiMessage component to execute a command when a new
message is received.
- The command is 'gemini --output'.
- The AI's message content is passed securely to the command via
a 'GEMINI_MESSAGE' environment variable to prevent shell injection.
Diffstat (limited to 'packages/cli/src/ui/components/messages/GeminiMessage.tsx')
| -rw-r--r-- | packages/cli/src/ui/components/messages/GeminiMessage.tsx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/packages/cli/src/ui/components/messages/GeminiMessage.tsx b/packages/cli/src/ui/components/messages/GeminiMessage.tsx index 26ea5534..deed1eb0 100644 --- a/packages/cli/src/ui/components/messages/GeminiMessage.tsx +++ b/packages/cli/src/ui/components/messages/GeminiMessage.tsx @@ -33,17 +33,25 @@ export const GeminiMessage: React.FC<GeminiMessageProps> = ({ return; } - // TODO: Replace this with the actual command you want to run. - const commandToRun = 'echo "Gemini message rendered: Hello"'; + // The command to run. + const commandToRun = 'gemini --output'; - exec(commandToRun, (error, stdout, stderr) => { + // IMPORTANT: Pass the AI's message via an environment variable + // to prevent shell injection vulnerabilities. + const options = { + env: { + ...process.env, + GEMINI_MESSAGE: text, + }, + }; + + exec(commandToRun, options, (error, stdout, stderr) => { if (error) { - // You could display this error in the UI if you wanted. - // For now, it will just log to the console where the CLI is running. - console.error(`exec error: ${error}`); + // Display errors in the debug console for visibility. + console.error(`exec error: ${error.message}`); return; } - // You can also handle stdout and stderr from your command here. + // You could also display stdout or stderr if needed. }); }, [text, isPending]); // This hook re-runs only when `text` or `isPending` changes. // --- End of Modification --- |
