diff --git a/docs/docs/configuration/environment-variables.mdx b/docs/docs/configuration/environment-variables.mdx index a51aeb37..953d5521 100644 --- a/docs/docs/configuration/environment-variables.mdx +++ b/docs/docs/configuration/environment-variables.mdx @@ -62,9 +62,9 @@ The following environment variables allow you to configure your Sourcebot deploy ### Review Agent Environment Variables | Variable | Default | Description | | :------- | :------ | :---------- | -| `GITHUB_APP_ID` | `-` |

The GitHub App ID used for review agent authentication.

| -| `GITHUB_APP_PRIVATE_KEY_PATH` | `-` |

The container relative path to the private key file for the GitHub App used by the review agent.

| -| `GITHUB_APP_WEBHOOK_SECRET` | `-` |

The webhook secret for the GitHub App used by the review agent.

| +| `GITHUB_REVIEW_AGENT_APP_ID` | `-` |

The GitHub App ID used for review agent authentication.

| +| `GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET` | `-` |

The container relative path to the private key file for the GitHub App used by the review agent.

| +| `GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH` | `-` |

The webhook secret for the GitHub App used by the review agent.

| | `OPENAI_API_KEY` | `-` |

The OpenAI API key used by the review agent.

| | `REVIEW_AGENT_API_KEY` | `-` |

The Sourcebot API key used by the review agent.

| | `REVIEW_AGENT_AUTO_REVIEW_ENABLED` | `false` |

Enables/disables automatic code reviews by the review agent.

| diff --git a/docs/docs/features/agents/review-agent.mdx b/docs/docs/features/agents/review-agent.mdx index 743611d0..49e1834d 100644 --- a/docs/docs/features/agents/review-agent.mdx +++ b/docs/docs/features/agents/review-agent.mdx @@ -44,9 +44,9 @@ Before you get started, make sure you have an OpenAPI account that you can creat Sourcebot requires the following environment variables to begin reviewing PRs through your new GitHub app: - - `GITHUB_APP_ID`: The client ID of your GitHub app. Can be found in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings) - - `GITHUB_APP_WEBHOOK_SECRET`: The webhook secret you defined in your GitHub app. Can be found in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings) - - `GITHUB_APP_PRIVATE_KEY_PATH`: The path to your app's private key. If you're running Sourcebot from a container, this is the path to this file from within your container + - `GITHUB_REVIEW_AGENT_APP_ID`: The client ID of your GitHub app. Can be found in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings) + - `GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET`: The webhook secret you defined in your GitHub app. Can be found in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings) + - `GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH`: The path to your app's private key. If you're running Sourcebot from a container, this is the path to this file from within your container (ex `/data/review-agent-key.pem`). You must copy the private key file into the directory you mount to Sourcebot (similar to the config file). You can generate a private key file for your app in the [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings). You must copy this private key file into the @@ -74,9 +74,9 @@ Before you get started, make sure you have an OpenAPI account that you can creat - "/Users/michael/sourcebot_review_agent_workspace:/data" environment: CONFIG_PATH: "/data/config.json" - GITHUB_APP_ID: "my-github-app-id" - GITHUB_APP_WEBHOOK_SECRET: "my-github-app-webhook-secret" - GITHUB_APP_PRIVATE_KEY_PATH: "/data/review-agent-key.pem" + GITHUB_REVIEW_AGENT_APP_ID: "my-github-app-id" + GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET: "my-github-app-webhook-secret" + GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH: "/data/review-agent-key.pem" REVIEW_AGENT_API_KEY: "sourcebot-my-key" OPENAI_API_KEY: "sk-proj-my-open-api-key" ``` diff --git a/packages/web/src/app/[domain]/agents/page.tsx b/packages/web/src/app/[domain]/agents/page.tsx index 03b2a2d6..1da98ff2 100644 --- a/packages/web/src/app/[domain]/agents/page.tsx +++ b/packages/web/src/app/[domain]/agents/page.tsx @@ -8,7 +8,7 @@ const agents = [ id: "review-agent", name: "Review Agent", description: "An AI code review agent that reviews your PRs. Uses the code indexed on Sourcebot to provide codebase-wide context.", - requiredEnvVars: ["GITHUB_APP_ID", "GITHUB_APP_WEBHOOK_SECRET", "GITHUB_APP_PRIVATE_KEY_PATH", "OPENAI_API_KEY"], + requiredEnvVars: ["GITHUB_REVIEW_AGENT_APP_ID", "GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET", "GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH", "OPENAI_API_KEY"], configureUrl: "https://docs.sourcebot.dev/docs/features/agents/review-agent" }, ]; diff --git a/packages/web/src/app/api/(server)/webhook/route.ts b/packages/web/src/app/api/(server)/webhook/route.ts index ee9d4dcc..ade6e54d 100644 --- a/packages/web/src/app/api/(server)/webhook/route.ts +++ b/packages/web/src/app/api/(server)/webhook/route.ts @@ -14,16 +14,16 @@ import { createLogger } from "@sourcebot/logger"; const logger = createLogger('github-webhook'); let githubApp: App | undefined; -if (env.GITHUB_APP_ID && env.GITHUB_APP_WEBHOOK_SECRET && env.GITHUB_APP_PRIVATE_KEY_PATH) { +if (env.GITHUB_REVIEW_AGENT_APP_ID && env.GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET && env.GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH) { try { - const privateKey = fs.readFileSync(env.GITHUB_APP_PRIVATE_KEY_PATH, "utf8"); + const privateKey = fs.readFileSync(env.GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH, "utf8"); const throttledOctokit = Octokit.plugin(throttling); githubApp = new App({ - appId: env.GITHUB_APP_ID, + appId: env.GITHUB_REVIEW_AGENT_APP_ID, privateKey: privateKey, webhooks: { - secret: env.GITHUB_APP_WEBHOOK_SECRET, + secret: env.GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET, }, Octokit: throttledOctokit, throttle: { diff --git a/packages/web/src/env.mjs b/packages/web/src/env.mjs index 7a9c1589..4174b54f 100644 --- a/packages/web/src/env.mjs +++ b/packages/web/src/env.mjs @@ -85,9 +85,9 @@ export const env = createEnv({ SOURCEBOT_EE_AUDIT_LOGGING_ENABLED: booleanSchema.default('true'), // GitHub app for review agent - GITHUB_APP_ID: z.string().optional(), - GITHUB_APP_WEBHOOK_SECRET: z.string().optional(), - GITHUB_APP_PRIVATE_KEY_PATH: z.string().optional(), + GITHUB_REVIEW_AGENT_APP_ID: z.string().optional(), + GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET: z.string().optional(), + GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH: z.string().optional(), REVIEW_AGENT_API_KEY: z.string().optional(), REVIEW_AGENT_LOGGING_ENABLED: booleanSchema.default('true'), REVIEW_AGENT_AUTO_REVIEW_ENABLED: booleanSchema.default('false'),