26 lines
569 B
Plaintext
26 lines
569 B
Plaintext
useEffect(() => {
|
|
// Don't execute for pending or empty responses.
|
|
if (isPending || !text) {
|
|
return;
|
|
}
|
|
|
|
// The command to run.
|
|
const commandToRun = 'gemini --output';
|
|
|
|
// 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) {
|
|
console.error(`exec error: ${error.message}`);
|
|
return;
|
|
}
|
|
});
|
|
}, [text, isPending]);
|