import type { ApiIntegrationInstallationSummary, CapabilityCatalogItem, ClientConfig, GitHubRepository, PersonalGitHubRepositoryCatalogItem, ReasoningEffort, ResourceRef, Session, ToolRef } from "../types.js"; import { type FirstPartyMcpToolName } from "@opengeni/contracts"; export type RepoDraft = { id: number; url: string; ref: string; expectedCommitSha?: string | undefined; attached?: boolean | undefined; /** * Workspace GitHub App identity retained from a restored resource that the * catalog could not confirm yet (still loading or unavailable). The row keeps * producing the same bound resource until catalog reconciliation selects it, * so restoring a draft never silently turns a bound repository into a bare * URL with a different mount path. */ github?: { repositoryId: number; installationId: number; } | undefined; /** * An attached row open in the editor with unsaved local changes. Catalog * reconciliation leaves it alone until the edit is attached or cancelled, so * the catalog finishing loading never discards the edit. */ editing?: true | undefined; }; export type IntelligenceEffort = ReasoningEffort; export type McpServerOption = { id: string; name: string; logoSrc?: string | null | undefined; detail?: string | undefined; connectionStatus?: "ready" | "connect" | "reconnect" | "unavailable" | "unknown" | undefined; }; /** Composer connector menus omit builtins managed by workspace tool settings. */ export declare function isComposerConnector(server: Pick): boolean; /** * Runtime infrastructure is not user policy: * - `opengeni` is the mandatory carrier for the individually selected * first-party tools. * - `files` is a real user-facing capability. It is selected by default, but * workspace admins and individual sessions may narrow it like other tools. */ export declare function isSelectableSessionMcpServerId(id: string): boolean; export declare function selectableSessionMcpServerIds(ids: Iterable): Set; /** Compare a retained draft with the current executable catalog, not saved defaults. */ export declare function unavailableSessionMcpServerIds(selectedIds: Iterable, servers: readonly McpServerOption[], catalogLoadedSuccessfully: boolean): string[]; export declare function clientFirstPartyMcpToolPolicy(config: Pick): { default: FirstPartyMcpToolName[]; allowed: FirstPartyMcpToolName[]; }; export declare function firstPartySessionToolOptionsFor(allowed: readonly FirstPartyMcpToolName[] | undefined): Array<{ id: FirstPartyMcpToolName; name: string; }>; export declare const reasoningEffortOrder: IntelligenceEffort[]; export declare function isIntelligenceEffort(value: unknown): value is IntelligenceEffort; export declare function labelEffort(value: IntelligenceEffort): string; export declare function effortOptionsFor(config: Pick | null): IntelligenceEffort[]; export declare function initialReasoningEffort(config: Pick): IntelligenceEffort; export declare function buildTools(existing: ToolRef[] | undefined, mcpServerIds?: string[]): ToolRef[]; /** * Materialize the exact user-facing MCP selection. The mandatory internal * `opengeni` carrier is attached server-side and never appears here. */ export declare function buildOpenGeniUiTools(existing: ToolRef[] | undefined, selectedMcpServerIds: Iterable): ToolRef[]; /** * Materialize the picker's selection only when it narrows/pins the inherited * baseline. `undefined` is the wire-level omitted-tools contract. */ export declare function toolsForPolicySelection(input: { existing?: ToolRef[] | undefined; selectedMcpServerIds: Iterable; baselineMcpServerIds: Iterable; forceExplicit?: boolean | undefined; }): ToolRef[] | undefined; /** Canonical persisted new-session policy, including the omitted/explicit bit. */ export declare function newSessionDraftToolPolicy(input: { selectedMcpServerIds: Iterable; workspaceDefaultMcpServerIds: Iterable; catalogReady: boolean; explicit: boolean; /** Header switch. Distinct from `explicit`, which pins the tool id list. */ customizing?: boolean | undefined; excludedMcpServerIds?: Iterable | undefined; }): { tools: ToolRef[]; toolsProvided: boolean; excludedMcpServerIds?: string[] | undefined; }; /** * Project the server-authoritative session policy into currently selectable * picker IDs. Workspace-default sessions follow the live capability baseline; * fixed policies use their effective IDs (or their persisted refs for rolling * compatibility). Unavailable IDs remain visible in policy truth/inspector but * cannot be selected by a picker that cannot execute them. */ export declare function sessionPolicyPickerIds(session: Pick, selectableIds: Iterable, workspaceDefaultIds: Iterable): Set; export declare function buildResources(manualRepos: RepoDraft[], repos: GitHubRepository[], selected: Set, selectedRefs: Record, personalRepositories?: PersonalGitHubRepositoryCatalogItem[], selectedPersonalRepositoryIds?: Set, selectedPersonalRepositoryRefs?: Record, personalCredentialBindingId?: string | null): ResourceRef[]; /** * Build only the repository refs pending on an existing session and prove they * can be additively merged with its already-mounted resources. Existing * resources are immutable through follow-up messages, so ref/path conflicts * fail in the composer before the turn is submitted. */ export declare function buildAdditionalRepositoryResources(input: { mountedResources: ResourceRef[]; manualRepos: RepoDraft[]; repositories: GitHubRepository[]; selectedRepoIds: Set; selectedRepoRefs: Record; personalRepositories?: PersonalGitHubRepositoryCatalogItem[] | undefined; selectedPersonalRepositoryIds?: Set | undefined; selectedPersonalRepositoryRefs?: Record | undefined; personalCredentialBindingId?: string | null | undefined; }): ResourceRef[]; export declare function gitHubRepositoryResource(repo: GitHubRepository, ref: string): Extract; export declare function isRepositoryResourceForGitHubRepo(resource: Extract, repo: GitHubRepository): boolean; export declare function sameRepositoryUri(resource: ResourceRef, uri: string): boolean; /** * Revalidate repository resources against the browser's authoritative GitHub * catalog. Private selections must retain both stable GitHub identities; * public/manual selections are URI-based and remain usable as manual refs when * the catalog no longer contains a matching public repository. */ export declare function rehydrateRepositoryResources(resources: ResourceRef[], repositories: GitHubRepository[], options?: { catalogReady?: boolean | undefined; personalRepositories?: PersonalGitHubRepositoryCatalogItem[] | undefined; personalCatalogReady?: boolean | undefined; }): ResourceRef[]; /** Project hydrated repository resources into the existing picker state. */ export declare function repositorySelectionFromResources(resources: ResourceRef[], repositories: GitHubRepository[]): { manualRepos: RepoDraft[]; selectedRepoIds: Set; selectedRepoRefs: Record; selectedPersonalRepoIds: Set; selectedPersonalRepoRefs: Record; }; /** * The workspace catalog repository an attached manual row stands for, if any. * A retained identity matches only that exact installation and repository. A * bare row matches the same way attaching a typed URL does: an exact * https://github.com URL naming the catalog repository. Other hosts never * match, so custom remotes keep their own attachment. */ export declare function manualRepositoryCatalogMatch(repo: RepoDraft, repositories: readonly GitHubRepository[]): GitHubRepository | null; export type RepositorySelectionState = { manualRepos: RepoDraft[]; selectedRepoIds: Set; selectedRepoRefs: Record; }; /** The composer's personal GitHub selection, read-only to catalog reconciliation. */ export type PersonalRepositorySelection = { repositories: readonly PersonalGitHubRepositoryCatalogItem[]; selectedRepoIds: ReadonlySet; selectedRepoRefs: Readonly>; }; /** * Fold attached manual rows that stand for a workspace catalog repository into * the catalog selection, so one repository is attached once and the picker * shows it checked. Returns null when nothing changes. * * - An unselected match becomes selected at the row's ref. * - A match already selected at the same ref is an exact duplicate and is dropped. * - A match selected at a different ref keeps its row: two refs are never * collapsed silently. * - A repository selected through personal GitHub keeps that authority: the * workspace App copy is never selected for it. A row at the ref of an * attached personal selection is an exact duplicate and is dropped; any * other row stays, including while the personal selection cannot attach yet. * This holds for repositories outside the workspace catalog too. * - A row open in the editor is left alone until the edit ends. * - A retained identity that a ready catalog no longer contains is dropped, * exactly like draft hydration drops it when the catalog is already loaded. * - An unknown catalog changes nothing. */ export declare function reconcileManualRepositoriesWithCatalog(state: RepositorySelectionState, repositories: readonly GitHubRepository[], catalogReady: boolean, personal?: PersonalRepositorySelection): RepositorySelectionState | null; export declare function repositoryDisplayName(resource: Extract): string; export declare function normalizeRepositoryUrl(value: string): { host: string; repo: string; }; export type RepositoryGroup = { installationId: number; label: string; detail: string; repositories: GitHubRepository[]; }; export declare function groupRepositories(repositories: GitHubRepository[]): RepositoryGroup[]; export declare function selectableMcpServers(config: ClientConfig | null): McpServerOption[]; export declare function enabledWorkspaceCapabilityMcpServers(items: CapabilityCatalogItem[]): McpServerOption[]; /** One selectable local MCP surface per installed OpenAPI/GraphQL instance. */ export declare function installedApiIntegrationMcpServers(integrations: ReadonlyArray>): McpServerOption[]; export declare function mergeMcpServerOptions(...groups: McpServerOption[][]): McpServerOption[]; export declare function selectedAvailableCapabilityToolIds(current: Set, availableIds: string[], previouslyAvailableIds?: Set, defaultIds?: string[]): Set; export declare function isAbortError(error: unknown): boolean;