mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 06:50:43 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - GitHub Code Review Bot connects an agent to a dedicated GitHub App so it reviews pull requests and responds to GitHub mentions > - The feature was gated behind the default-off `enableGitHubReviewBots` experimental instance setting, hiding the catalog card, setup routes, identity links, and channel creation > - People had to find and flip an instance-level experimental switch before they could connect a GitHub review agent > - This pull request graduates GitHub review bots to a normal always-on feature, keeping `enableGitHubReviewBots` only as a deprecated compatibility key that always resolves to `true` > - The benefit is that every Paperclip instance exposes GitHub Code Review Bot setup, discovery, and management by default without requiring feature flags ## Linked Issues or Issue Description **What existing behavior does this improve?** GitHub Code Review Bot discovery, catalog visibility, setup/management routes, identity-link endpoints, and Agent Channels visibility (`enableGitHubReviewBots`). **Subsystem affected** Cross-cutting (`packages/shared`, `server/`, `ui/`, Storybook, E2E specs, docs). **Current behavior** GitHub Code Review Bot is hidden from Connectors, `connections_search`, chat-endpoint creation, identity-link confirmation, and UI setup/settings routes until an instance admin turns on **Settings → Experimental → GitHub review bots** (`enableGitHubReviewBots`). **Proposed behavior** GitHub Code Review Bot is always available as a standard feature on every instance (self-hosted and Cloud), matching AgentMail and graduated features such as Assistant connections (`enablePublicMcp`) and the AWS connector (`enableAwsConnector`). `enableGitHubReviewBots` stays in schemas and the feature catalog only as a deprecated compatibility key that always normalizes to `true`, ignores stored or Cloud-managed `false` values, and does not reject legacy `false` patches. Experimental chat providers (Slack, Discord, Microsoft Teams, Telegram, iMessage Photon, Speko) remain gated by `enableChatConnectors`. **Reason and benefit** Users can connect and manage GitHub review agents directly from Connectors without an admin enabling an experimental flag first, and Cloud stacks no longer require managed feature-flag overrides to expose GitHub review bots. **Breaking changes** No schema migration or breaking API change. Existing rows, API patches, and Cloud managed configs that still carry `enableGitHubReviewBots` continue to parse cleanly, while the effective value is always `true`. Instances that previously kept `enableGitHubReviewBots` off now display GitHub Code Review Bot in Connectors and allow authorized managers (`tools:manage_connections`) to create GitHub review bot endpoints. ## What Changed - `packages/shared`: marked `enableGitHubReviewBots` as a deprecated compatibility key in types, Zod defaults (`true`), and `INSTANCE_FEATURE_CATALOG` (`cloudDefault: true`, `selfHostedDefault: true`); updated `channelMethodEnabled` in `connector-availability.ts` so `github` is always enabled alongside `agentmail`. - `server` instance settings and Cloud staging: `normalizeExperimentalSettings` always returns `enableGitHubReviewBots: true`; `applyManagedExperimentalOverlay` and `updateExperimental` ignore retired `enableGitHubReviewBots` entries so Cloud managed configs cannot turn it off and legacy `false` patches are not rejected; removed `enableGitHubReviewBots` from `CLOUD_STAGING_EXPERIMENTAL_KEYS`. - `server` chat channels, discovery, and OpenAPI: allowed `github` in `assertChatProviderEnabledForCreate`, `assertIdentityProviderEnabled`, `assertIdentityLinkAccess`, and `connection-intents` discovery without experimental flags while keeping `enableChatConnectors` enforcement for experimental chat providers; updated the OpenAPI endpoint description. - `ui` and Storybook: removed the **GitHub review bots** Experimental settings toggle card; simplified `useChatConnectorsEnabled` and `chatProviderVisible` so `github` and `github-code-review-bot` are always visible; bypassed experimental loading wait for `provider=github` in `ChatConnectorsExperimentalGate`; made the classic Agent Detail Channels tab and `AgentChannelsPanel` empty-state copy always reflect available agent identities; updated `canEnterAppsConnect`, `Browse`, `ConnectionSetupFlow`, and `github-connections.stories.tsx`. - Tests, E2E, runner-e2e, docs, and maps: updated unit, integration, managed-overlay, runner-e2e, and Playwright E2E specs; refreshed `tests/runner-e2e/source-sdk-public-inputs.json`; updated `doc/connections/GITHUB.md`, `doc/connections/GITHUB-REVIEW-BOT.md`, and `maps/feature-map/chat-channels.md`. ## Verification - `pnpm --filter @paperclipai/shared build && pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/server typecheck && pnpm --filter @paperclipai/ui typecheck` — passed. - `node scripts/check-maps.mjs && node scripts/storybook-catalog.mjs` — passed. - `pnpm vitest run packages/shared/src/validators/instance.test.ts packages/shared/src/connector-availability.test.ts packages/shared/src/feature-catalog.test.ts server/src/__tests__/instance-settings-service.test.ts server/src/__tests__/instance-settings-managed-overlay.test.ts server/src/__tests__/instance-settings-cloud-defaults.test.ts server/src/routes/chat-channels.identity.test.ts server/src/__tests__/connection-intents-service.test.ts server/src/__tests__/chat-channels/slack-ingress-and-threads.integration.test.ts server/src/__tests__/chat-channels/github-setup-and-access.integration.test.ts` — all passed. - `pnpm vitest run ui/src/pages/apps/app-connect-policy.test.ts ui/src/components/chat/ExternallyConnectedTaskBanner.test.tsx ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx` — 3 files, 62 tests passed. - `pnpm --dir tests/runner-e2e vitest run github-review-journey.test.ts` — 56 tests passed. - `pnpm verify --explain` — confirmed `tests/runner-e2e/source-sdk-public-inputs.json` is current; exited 2 for broad CI coverage (handled by required GitHub CI gates on this PR). ## Risks - Behavioral shift: instances that had `enableGitHubReviewBots` off now show GitHub Code Review Bot in Connectors and allow authorized users with `tools:manage_connections` to configure GitHub review bots. Existing permission boundaries (`tools:manage_connections`, company scoping, GitHub App OAuth/installation consent) are unchanged. - `useIssueChatBinding` now queries `/api/issues/:issueId/chat-binding` for normal tasks even when `enableChatConnectors` is off so GitHub-bound task banners remain visible; experimental chat bindings remain filtered out by `chatProviderVisible` while `enableChatConnectors` is off. - No database migration is required; stored `enableGitHubReviewBots` JSON values become inert. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Google Gemini (high reasoning) in Antigravity, with tool use (shell, file edits, test execution). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge
119 lines
4.1 KiB
TypeScript
119 lines
4.1 KiB
TypeScript
import { createHash } from "node:crypto";
|
|
import type { ManagedExperimentalFeatureKey } from "@paperclipai/shared";
|
|
|
|
const CLOUD_STAGING_EXPERIMENTAL_KEYS: ReadonlySet<string> = new Set([
|
|
"autoRestartDevServerWhenIdle",
|
|
"enableAgentChat",
|
|
"enableBetaSkills",
|
|
"enableBuiltInAgents",
|
|
"enableCases",
|
|
"enableArtifactsV1",
|
|
"enableChatConnectors",
|
|
"enableClassicTaskInterface",
|
|
"enableCombinedInboxTasks",
|
|
"enableConferenceRoomChat",
|
|
"enableDecisions",
|
|
"enableEnvironments",
|
|
"enableExperimentalFileViewer",
|
|
"enableExternalObjects",
|
|
"enableFastResponses",
|
|
"enableFirstTaskPlanProposal",
|
|
"enableCloudTrialInference",
|
|
"enableGoogleWorkspaceConnector",
|
|
"enableAwsConnector",
|
|
"enableGoalsSidebarLink",
|
|
"enableGrokBot",
|
|
"enableIsolatedWorkspaces",
|
|
"enableIsolatedWorkspacesByDefault",
|
|
"enableIssuePlanDecompositions",
|
|
"enableMemoryConnectors",
|
|
"enableMuse",
|
|
"enableNativeRunner",
|
|
"enableOpenAiDot",
|
|
"enablePaperclipDeveloperMode",
|
|
"enableResponsibilities",
|
|
"enableServerInfoDebugView",
|
|
"enableSimplifiedEnglishInteractions",
|
|
"enableSmokeLab",
|
|
"enableStatusCards",
|
|
"enableStreamlinedUi",
|
|
"enableSummaries",
|
|
"enableWorktreeRunExecution",
|
|
] satisfies ManagedExperimentalFeatureKey[]);
|
|
|
|
export function isCloudStagingExperimentalSetting(key: string): boolean {
|
|
return CLOUD_STAGING_EXPERIMENTAL_KEYS.has(key);
|
|
}
|
|
|
|
export type CloudInstanceEnv = Record<string, string | undefined>;
|
|
|
|
export type CloudStackContext = {
|
|
stackId: string | null;
|
|
stackSlug: string | null;
|
|
accountGroupId: string | null;
|
|
primaryHost: string | null;
|
|
cloudOrigin: string | null;
|
|
};
|
|
|
|
function normalizeOptionalEnvValue(value: string | undefined): string | null {
|
|
const normalized = value?.trim();
|
|
return normalized ? normalized : null;
|
|
}
|
|
|
|
/**
|
|
* The canonical Paperclip Cloud instance predicate.
|
|
*
|
|
* The tenant token is the signal injected on live cloud stacks. The managed
|
|
* config document is the legacy/bootstrap signal used by managed feature and
|
|
* plugin floors. Their union is intentionally monotonic: either prior signal
|
|
* keeps every restrictive cloud floor enabled.
|
|
*/
|
|
export function isCloudManagedInstance(
|
|
env: CloudInstanceEnv = process.env,
|
|
): boolean {
|
|
return (
|
|
normalizeOptionalEnvValue(env.PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN) !== null ||
|
|
env.PAPERCLIP_MANAGED_CONFIG !== undefined
|
|
);
|
|
}
|
|
|
|
export function isCloudStagingInstance(env: CloudInstanceEnv = process.env): boolean {
|
|
const host = normalizeOptionalEnvValue(env.PAPERCLIP_PRIMARY_HOST);
|
|
return isCloudManagedInstance(env) && host !== null && /^[a-z0-9-]+\.staging\.paperclip\.app$/i.test(host);
|
|
}
|
|
|
|
/**
|
|
* Public stack metadata injected by the Paperclip Cloud provisioner.
|
|
*
|
|
* A managed signal can exist briefly before every metadata value is available,
|
|
* so absent or blank values are represented as null rather than making health
|
|
* checks fail. Self-hosted instances never expose a stack context.
|
|
*/
|
|
export function getCloudStackContext(
|
|
env: CloudInstanceEnv = process.env,
|
|
): CloudStackContext | null {
|
|
if (!isCloudManagedInstance(env)) return null;
|
|
|
|
return {
|
|
stackId: normalizeOptionalEnvValue(env.PAPERCLIP_CLOUD_STACK_ID),
|
|
stackSlug: normalizeOptionalEnvValue(env.PAPERCLIP_STACK_SLUG),
|
|
accountGroupId: normalizeOptionalEnvValue(env.PAPERCLIP_CLOUD_ACCOUNT_GROUP_ID),
|
|
primaryHost: normalizeOptionalEnvValue(env.PAPERCLIP_PRIMARY_HOST),
|
|
cloudOrigin: normalizeOptionalEnvValue(env.PAPERCLIP_CLOUD_API_ORIGIN),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* The Cloud-pinned primary company id for a stack: the deterministic
|
|
* v5-style UUID the trusted-header lane seeds and every Cloud surface pins.
|
|
* The derivation is frozen — seeded companies fleet-wide already carry
|
|
* these ids. middleware/auth.ts delegates here; this is the one definition.
|
|
*/
|
|
export function cloudTenantPrimaryCompanyId(stackId: string): string {
|
|
const bytes = createHash("sha256").update(`paperclip-cloud-tenant-company:${stackId}`).digest();
|
|
bytes[6] = (bytes[6]! & 0x0f) | 0x50;
|
|
bytes[8] = (bytes[8]! & 0x3f) | 0x80;
|
|
const hex = bytes.subarray(0, 16).toString("hex");
|
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
|
|
}
|