import type { ChangedFile, EgressMode, EgressSettingsInfo, ExecTarget, ExternalFile, IndexInfo, IntelKind, IntelQuery, IntelResult, ProjectInfo, FileView, MarkdownBlock, RemoteImage, BranchStat, GitRef, RecentRepo, RepoInfo, RepoSource, Subject, SandboxEvent, SandboxInfo, TreeEntry } from '../shared/types' import type { ReviewApi, ReviewChange } from '../shared/reviews' import type { GithubAuthSource, GithubAuthStatus } from '../shared/github' import type { OpenedDestination } from '../shared/systems' import type { ConfigValue, SettingsSaveResult, SettingsSnapshot } from '../shared/settings' export interface Api extends ReviewApi { // Reviews (docs/REVIEW-FORMAT.md): the ReviewApi methods, stored locally in the main process. /** The store changed (from any window, a fetch or an export); returns an unsubscribe function. */ onReviewsChanged(cb: (change: ReviewChange) => void): () => void /** Opens a destination's URL (a pull request, a merge request) for review: its repository, head and merge base (integrations §3). */ openDestination(url: string): Promise<{ repo: RepoInfo; subject: Subject; opened: OpenedDestination }> // GitHub. The token stays in the main process. githubStatus(host: string): Promise githubSetSource(host: string, source: GithubAuthSource): Promise /** Checks the token with GitHub, then saves it in the OS keychain. */ githubSaveToken(host: string, token: string): Promise githubRemoveToken(host: string): Promise pickFolder(): Promise openRepo(source: RepoSource): Promise /** Repositories opened lately, newest first. */ recentRepos(): Promise /** Opens a repository without contacting a remote: fails for a clone that isn't cached. */ openRepoOffline(source: RepoSource): Promise forgetRepo(source: RepoSource): Promise /** With a pull request subject, fetches it again too: that subject at its new head, when it moved. */ fetchRepo(id: string, subject?: Subject | null): Promise<{ info: RepoInfo; subject: Subject | null }> refs(id: string): Promise /** Commits ahead of `base` and files changed since the merge-base, per branch (short names). */ branchStats(id: string, base: string, branches: string[]): Promise> openSubject(id: string, head: string, base?: string): Promise tree(subject: Subject): Promise changes(subject: Subject): Promise file(subject: Subject, path: string, withBase: boolean): Promise /** An image at head as a data: URL (null if missing, too large or not an image). */ image(subject: Subject, path: string): Promise /** Parses a Markdown file at head (or at base) in the review's sandbox; the HTML is untrusted. */ /** `dark`: diagrams are drawn for the dark theme. */ markdownRender(sandboxId: string, subject: Subject, path: string, side?: 'head' | 'base', opts?: { dark?: boolean }): Promise /** A remote image, fetched in the sandbox through the egress proxy; hosts off the allow-list are not asked. */ markdownRemoteImage(sandboxId: string, url: string): Promise sandboxStatus(): Promise<{ id: string; ok: boolean; reason?: string }[]> createSandbox(subject: Subject): Promise disposeSandbox(id: string): Promise exec(sandboxId: string, command: string, target: ExecTarget): Promise /** Run `devcontainer up` inside the sandbox VM; returns the exec id of the build. */ devcontainerUp(sandboxId: string): Promise kill(execId: string): Promise /** SCIP indexes cached on the host for the review's head commit. */ intelStatus(subject: Subject): Promise /** Fetch dependencies and build SCIP indexes in the sandbox (default: projects with changes, then a few more); returns the exec id. */ intelIndex(sandboxId: string, subject: Subject, projectIds?: string[]): Promise /** The review's projects: ecosystem, root, resolved version and where it came from. */ intelProjects(subject: Subject): Promise /** Force a project's toolchain version for this repository (null: detect again). */ intelSetVersion(subject: Subject, projectId: string, version: string | null): Promise /** Definition / references / hover: SCIP first, then a language server in the sandbox. */ intelQuery(kind: IntelKind, q: IntelQuery): Promise /** Start the file's language server early (no-op when a SCIP index covers it). */ intelWarm(q: Omit): Promise /** A dependency's file (from a definition outside the repo), read from the sandbox. */ intelExternal(ext: ExternalFile): Promise /** Egress policy (app-wide): mode and the user's allow-list additions. Changes apply to running sandboxes. */ egressGet(): Promise egressSetMode(mode: EgressMode): Promise /** Add hostnames or `*.domain` patterns to the allow-list. */ egressAllow(patterns: string[]): Promise egressRemove(pattern: string): Promise onEgressChange(cb: (info: EgressSettingsInfo) => void): () => void /** Subscribe to exec output; returns an unsubscribe function. */ onSandboxEvent(cb: (e: SandboxEvent) => void): () => void /** The settings page's rows; with a repo id, its per-clone and repository layers too. */ settingsGet(repoId?: string): Promise /** Save to the user's config (null removes a key). All or nothing: any refused key writes nothing. */ settingsSave(changes: Record, repoId?: string): Promise /** The value in effect for one key. */ settingsEffective(key: string, repoId?: string): Promise /** Open the user's config file in the default editor (creating it if needed). */ settingsOpenUserFile(): Promise /** The repository's config file at its trusted tip, or null. */ settingsRepoFile(repoId: string): Promise /** The user's config changed (a save, or an edit to the file). */ onSettingsChange(cb: () => void): () => void /** Settings… was chosen from the menu (⌘,). */ onMenuSettings(cb: () => void): () => void /** Back or Forward from the Go menu (⌘[ / ⌘]) or a trackpad swipe. */ onMenuNav(cb: (dir: 'back' | 'forward') => void): () => void /** A menu item with a key was used, by that key or by clicking the menu: `id` names it in the renderer's shortcuts.ts. */ onMenuShortcut(cb: (id: string, via: 'key' | 'menu') => void): () => void } declare global { interface Window { api: Api } }