mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 20:09:33 +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
182 lines
8.8 KiB
TypeScript
182 lines
8.8 KiB
TypeScript
import { z } from "zod";
|
|
import { DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE } from "../types/feedback.js";
|
|
import {
|
|
DAILY_RETENTION_PRESETS,
|
|
WEEKLY_RETENTION_PRESETS,
|
|
MONTHLY_RETENTION_PRESETS,
|
|
DEFAULT_BACKUP_RETENTION,
|
|
} from "../types/instance.js";
|
|
import { feedbackDataSharingPreferenceSchema } from "./feedback.js";
|
|
import { shapeWithoutDefaults } from "./partial.js";
|
|
|
|
function presetSchema<T extends readonly number[]>(presets: T, label: string) {
|
|
return z.number().refine(
|
|
(v): v is T[number] => (presets as readonly number[]).includes(v),
|
|
{ message: `${label} must be one of: ${presets.join(", ")}` },
|
|
);
|
|
}
|
|
|
|
export const backupRetentionPolicySchema = z.object({
|
|
dailyDays: presetSchema(DAILY_RETENTION_PRESETS, "dailyDays").default(DEFAULT_BACKUP_RETENTION.dailyDays),
|
|
weeklyWeeks: presetSchema(WEEKLY_RETENTION_PRESETS, "weeklyWeeks").default(DEFAULT_BACKUP_RETENTION.weeklyWeeks),
|
|
monthlyMonths: presetSchema(MONTHLY_RETENTION_PRESETS, "monthlyMonths").default(DEFAULT_BACKUP_RETENTION.monthlyMonths),
|
|
});
|
|
|
|
export const instanceGeneralSettingsSchema = z.object({
|
|
censorUsernameInLogs: z.boolean().default(false),
|
|
feedbackDataSharingPreference: feedbackDataSharingPreferenceSchema.default(
|
|
DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE,
|
|
),
|
|
backupRetention: backupRetentionPolicySchema.default(DEFAULT_BACKUP_RETENTION),
|
|
// Execution policy. Absent/"any" = unrestricted; "kubernetes" forces the
|
|
// Kubernetes sandbox provider and denies local/ssh execution (cloud_tenant).
|
|
executionMode: z.enum(["kubernetes", "any"]).optional(),
|
|
}).strict();
|
|
|
|
export const patchInstanceGeneralSettingsSchema = z
|
|
.object(shapeWithoutDefaults(instanceGeneralSettingsSchema.shape))
|
|
.partial()
|
|
.strict();
|
|
|
|
export const instanceExperimentalSettingsSchema = z.object({
|
|
enableEnvironments: z.boolean().default(false),
|
|
enableNativeRunner: z.boolean().default(true),
|
|
enableAiConnectionRouters: z.boolean().default(false),
|
|
enableManagedSandboxOnly: z.boolean().default(false),
|
|
enableIsolatedWorkspaces: z.boolean().default(false),
|
|
remoteWorkspaceStorageEnabled: z.boolean().default(true),
|
|
enableIsolatedWorkspacesByDefault: z.boolean().default(false),
|
|
enableStreamlinedLeftNavigation: z.boolean().default(true),
|
|
enableStreamlinedUi: z.boolean().default(true),
|
|
// Deprecated compatibility key. Apps is a standard product surface and is
|
|
// always enabled; this remains accepted so older stored rows and managed
|
|
// configs continue to load during upgrades.
|
|
enableApps: z.boolean().default(true),
|
|
// Deprecated compatibility key. Assistant connections (MCP) graduated from
|
|
// Experimental and are always enabled; older stored rows, managed configs
|
|
// and clients may still send it.
|
|
enablePublicMcp: z.boolean().default(true),
|
|
enableOpenAiDot: z.boolean().default(false),
|
|
enableGrokBot: z.boolean().default(false),
|
|
enableMuse: z.boolean().default(false),
|
|
enableChatConnectors: z.boolean().default(false),
|
|
// Deprecated compatibility key. GitHub review bots graduated from
|
|
// Experimental and are always enabled; older stored rows, managed configs
|
|
// and clients may still send it.
|
|
enableGitHubReviewBots: z.boolean().default(true),
|
|
// Compatibility only: old stored and managed values must still parse.
|
|
enableMcpAggregators: z.boolean().default(true),
|
|
enableMemoryConnectors: z.boolean().default(false),
|
|
enablePaperclipNotebook: z.boolean().default(false),
|
|
enableGoogleWorkspaceConnector: z.boolean().default(false),
|
|
enableAwsConnector: z.boolean().default(true),
|
|
enableCases: z.boolean().default(false),
|
|
enableAgentChat: z.boolean().default(true),
|
|
enableCombinedInboxTasks: z.boolean().default(false),
|
|
enableArtifactsV1: z.boolean().default(true),
|
|
enableConferenceRoomChat: z.boolean().default(false),
|
|
enableClassicTaskInterface: z.boolean().default(false),
|
|
enableLegacyComposerSubmit: z.boolean().default(false),
|
|
enableIssuePlanDecompositions: z.boolean().default(false),
|
|
enableExperimentalFileViewer: z.boolean().default(false),
|
|
enableExternalObjects: z.boolean().default(false),
|
|
enableSmokeLab: z.boolean().default(false),
|
|
enableBuiltInAgents: z.boolean().default(false),
|
|
enableBetaSkills: z.boolean().default(false),
|
|
enableSummaries: z.boolean().default(false),
|
|
enableStatusCards: z.boolean().default(false),
|
|
enableResponsibilities: z.boolean().default(false),
|
|
enableDecisions: z.boolean().default(false),
|
|
enableFastResponses: z.boolean().default(false),
|
|
enableGoalsSidebarLink: z.boolean().default(false),
|
|
enableServerInfoDebugView: z.boolean().default(false),
|
|
enablePaperclipDeveloperMode: z.boolean().default(false),
|
|
enableSimplifiedEnglishInteractions: z.boolean().default(false),
|
|
enableFirstTaskPlanProposal: z.boolean().default(false),
|
|
enableCloudTrialInference: z.boolean().default(false),
|
|
autoRestartDevServerWhenIdle: z.boolean().default(false),
|
|
enableWorkspaceBranchReconcileForward: z.boolean().default(true),
|
|
enableWorkspaceDirtyQuarantineRepair: z.boolean().default(true),
|
|
enableOwnerInstanceAdmin: z.boolean().default(false),
|
|
// Kill switch for the sandbox duplex command-stream bridge. Default off. When
|
|
// off the host keeps the file bridge for every run with no manifest change and
|
|
// no redeploy. The host reads this per run before it selects the transport.
|
|
enableSandboxDuplexBridge: z.boolean().default(false),
|
|
// MCP Tasks (io.modelcontextprotocol/tasks): durable long provider calls.
|
|
// Off: Paperclip never declares the extension, so servers never return tasks.
|
|
enableMcpTasks: z.boolean().default(false),
|
|
// Trusted /swarm for Google Antigravity agents (Antigravity CLI route). Default off.
|
|
enableAntigravitySwarm: z.boolean().default(false),
|
|
// Deprecated compatibility key. Runner ingress follows enableNativeRunner;
|
|
// this remains accepted so older stored rows and managed configs keep loading.
|
|
enableRunnerPreviewIngress: z.boolean().default(false),
|
|
enableWorktreeRunExecution: z.boolean().default(false),
|
|
worktreeRunExecutionActivatedAt: z.string().datetime().nullable().default(null),
|
|
worktreeRunExecutionActivationInstanceId: z.string().min(1).nullable().default(null),
|
|
}).strict();
|
|
|
|
export const patchInstanceExperimentalSettingsSchema = z
|
|
.object(
|
|
shapeWithoutDefaults(
|
|
instanceExperimentalSettingsSchema
|
|
.omit({
|
|
worktreeRunExecutionActivatedAt: true,
|
|
worktreeRunExecutionActivationInstanceId: true,
|
|
})
|
|
.shape,
|
|
),
|
|
)
|
|
.partial()
|
|
.strip();
|
|
|
|
export const managedSettingMetadataSchema = z.object({
|
|
managed: z.literal(true),
|
|
managedBy: z.literal("paperclip-cloud"),
|
|
}).strict();
|
|
|
|
// Response shape of the experimental settings endpoints: on cloud-managed
|
|
// instances every overlaid key is listed in `managedKeys`; self-hosted
|
|
// responses omit the field entirely.
|
|
export const instanceExperimentalSettingsWithManagedSchema = instanceExperimentalSettingsSchema.extend({
|
|
managedKeys: z.record(z.string(), managedSettingMetadataSchema).optional(),
|
|
}).strict();
|
|
|
|
export const patchInstanceSettingsSchema = z.object({
|
|
defaultEnvironmentId: z.string().guid().nullable().optional(),
|
|
}).strict();
|
|
|
|
// The longest time a task drain can run before it expires on its own. A
|
|
// caller can send a shorter `ttlMs`, but not a longer one — the request must
|
|
// fail instead of the server silently clamping the value.
|
|
export const MAX_TASK_DRAIN_TTL_MS = 24 * 60 * 60 * 1000;
|
|
|
|
export const startTaskDrainRequestSchema = z.object({
|
|
purpose: z.literal("idle").optional(),
|
|
ttlMs: z.number().int().positive().max(MAX_TASK_DRAIN_TTL_MS).nullable().optional(),
|
|
}).strict().refine(value => value.purpose !== "idle" ||
|
|
(typeof value.ttlMs === "number" && value.ttlMs >= 5_000 && value.ttlMs <= 300_000),
|
|
{ message: "Idle holds require ttlMs between 5000 and 300000", path: ["ttlMs"] });
|
|
|
|
export type InstanceGeneralSettings = z.infer<typeof instanceGeneralSettingsSchema>;
|
|
// The patch schema removes each default so an absent key stays absent. Declare
|
|
// the type from the full settings type, so every field keeps its precise type.
|
|
export type PatchInstanceGeneralSettings = Partial<InstanceGeneralSettings>;
|
|
export type InstanceExperimentalSettings = z.infer<typeof instanceExperimentalSettingsSchema>;
|
|
export type PatchInstanceExperimentalSettings = Partial<
|
|
Omit<
|
|
InstanceExperimentalSettings,
|
|
"worktreeRunExecutionActivatedAt" | "worktreeRunExecutionActivationInstanceId"
|
|
>
|
|
>;
|
|
export type PatchInstanceSettings = z.infer<typeof patchInstanceSettingsSchema>;
|
|
export type StartTaskDrainRequest = z.infer<typeof startTaskDrainRequestSchema>;
|
|
|
|
export const instanceSettingsSchema = z.object({
|
|
id: z.string().guid(),
|
|
defaultEnvironmentId: z.string().guid().nullable(),
|
|
general: instanceGeneralSettingsSchema,
|
|
experimental: instanceExperimentalSettingsWithManagedSchema,
|
|
createdAt: z.union([z.date(), z.string().datetime()]),
|
|
updatedAt: z.union([z.date(), z.string().datetime()]),
|
|
}).strict();
|