/** * Bridge OAuth Device Flow → GitHub adapter config. * * When a user completes "Continue with GitHub" in the dashboard, the * OAuth access token they granted Cortex is the SAME credential * `adapter-github` needs to pull repos. Re-asking them for a personal * access token in the adapter wizard is friction we should eliminate. * * On successful Device Flow auth (post-allowlist check), this module: * 1. Writes `GITHUB_TOKEN=` to the workspace `.env` * so adapter-github's `requiredSecrets` lookup finds it. * 2. Marks the token source as `oauth` via * `PRZM_CORTEX_GITHUB_TOKEN_SOURCE` so the wizard renderer + * Connectors page can show "Connected via OAuth" instead of * pretending the user pasted a PAT. * 3. Adds a minimal `adapters.github` block to `cortex.yaml` if one * isn't already there, with `enabled: true` and an empty * `repos: []`. The user picks repos via * `/_dashboard/integrations/github` (Slice B's table). The * adapter no-ops on empty repos at sync time. * * Idempotent. Won't clobber a manually-pasted PAT (we only write * GITHUB_TOKEN when it's absent OR previously OAuth-sourced — so a * later OAuth login refreshes a stale OAuth token but doesn't * overwrite a PAT the operator deliberately set). */ import type { Workspace } from "../cli/workspace/manager.js"; /** * Outcome the route handler can surface to the UI / logger. The * Connectors page reads `source === 'oauth'` to flip the GitHub card * to "Connected via OAuth" with the avatar of whoever last signed in. */ export interface AdapterBridgeOutcome { /** Whether GITHUB_TOKEN was written this call (i.e. wasn't already OAuth-sourced + matching). */ wroteToken: boolean; /** Whether the adapters.github YAML block was added this call. */ enabledAdapter: boolean; /** Current source of the GITHUB_TOKEN env var after this call. */ tokenSource: "oauth" | "pat" | "absent"; /** Hint for the caller — empty when nothing-to-do; populated when we skipped to preserve a PAT. */ skippedReason?: "pat_already_set"; } /** * Apply the OAuth token + minimal adapter config to the workspace. * Returns what changed so the caller can log / surface to the user. */ export declare function bridgeGithubAdapterConfig(opts: { workspace: Workspace; oauthToken: string; }): Promise; //# sourceMappingURL=github-adapter-bridge.d.ts.map