Adds shell command allowlist (#68)

* Wire through passthrough commands

* Add default passthrough commands

* Clean up config passing to useGeminiStream
This commit is contained in:
Juliette Love
2025-04-20 21:06:22 +01:00
committed by GitHub
parent f480ef4bbc
commit a76d9b4dcf
4 changed files with 64 additions and 12 deletions

View File

@@ -9,22 +9,28 @@ import * as fs from 'node:fs';
import * as path from 'node:path';
import process from 'node:process';
const DEFAULT_PASSTHROUGH_COMMANDS = ['ls', 'git', 'npm'];
export class Config {
private apiKey: string;
private model: string;
private targetDir: string;
private debugMode: boolean;
private passthroughCommands: string[];
constructor(
apiKey: string,
model: string,
targetDir: string,
debugMode: boolean,
passthroughCommands?: string[],
) {
this.apiKey = apiKey;
this.model = model;
this.targetDir = targetDir;
this.debugMode = debugMode;
this.passthroughCommands =
passthroughCommands || DEFAULT_PASSTHROUGH_COMMANDS;
}
getApiKey(): string {
@@ -42,6 +48,10 @@ export class Config {
getDebugMode(): boolean {
return this.debugMode;
}
getPassthroughCommands(): string[] {
return this.passthroughCommands;
}
}
function findEnvFile(startDir: string): string | null {
@@ -72,6 +82,13 @@ export function createServerConfig(
model: string,
targetDir: string,
debugMode: boolean,
passthroughCommands?: string[],
): Config {
return new Config(apiKey, model, path.resolve(targetDir), debugMode);
return new Config(
apiKey,
model,
path.resolve(targetDir),
debugMode,
passthroughCommands,
);
}