Initial commit: Discord-Claude Gateway with event-driven agent runtime

This commit is contained in:
2026-02-22 00:42:56 -05:00
parent 77d7c74909
commit bbcc9014f5
5 changed files with 120 additions and 136 deletions

View File

@@ -8,7 +8,6 @@ describe("loadConfig", () => {
process.env = { ...originalEnv };
// Set required vars by default
process.env.DISCORD_BOT_TOKEN = "test-discord-token";
process.env.ANTHROPIC_API_KEY = "test-anthropic-key";
});
afterEach(() => {
@@ -18,11 +17,11 @@ describe("loadConfig", () => {
it("should load required environment variables", () => {
const config = loadConfig();
expect(config.discordBotToken).toBe("test-discord-token");
expect(config.anthropicApiKey).toBe("test-anthropic-key");
});
it("should apply default values for optional config", () => {
const config = loadConfig();
expect(config.claudeCliPath).toBe("claude");
expect(config.allowedTools).toEqual(["Read", "Write", "Edit", "Glob", "Grep", "WebSearch", "WebFetch"]);
expect(config.permissionMode).toBe("bypassPermissions");
expect(config.queryTimeoutMs).toBe(120_000);
@@ -51,6 +50,7 @@ describe("loadConfig", () => {
process.env.CONFIG_DIR = "/custom/config";
process.env.MAX_QUEUE_DEPTH = "200";
process.env.OUTPUT_CHANNEL_ID = "123456789";
process.env.CLAUDE_CLI_PATH = "/usr/local/bin/claude";
const config = loadConfig();
expect(config.permissionMode).toBe("default");
@@ -59,6 +59,7 @@ describe("loadConfig", () => {
expect(config.configDir).toBe("/custom/config");
expect(config.maxQueueDepth).toBe(200);
expect(config.outputChannelId).toBe("123456789");
expect(config.claudeCliPath).toBe("/usr/local/bin/claude");
});
it("should throw when DISCORD_BOT_TOKEN is missing", () => {
@@ -66,16 +67,10 @@ describe("loadConfig", () => {
expect(() => loadConfig()).toThrow("DISCORD_BOT_TOKEN");
});
it("should throw when ANTHROPIC_API_KEY is missing", () => {
delete process.env.ANTHROPIC_API_KEY;
expect(() => loadConfig()).toThrow("ANTHROPIC_API_KEY");
});
it("should list all missing required variables in error message", () => {
delete process.env.DISCORD_BOT_TOKEN;
delete process.env.ANTHROPIC_API_KEY;
expect(() => loadConfig()).toThrow(
"Missing required environment variables: DISCORD_BOT_TOKEN, ANTHROPIC_API_KEY"
"Missing required environment variables: DISCORD_BOT_TOKEN"
);
});
});