import { type MemberIntegrationSetup } from "@opengeni/contracts/personal-integration-setup"; import type { AccessContext, CapabilityCatalogItem, Permission } from "@opengeni/sdk"; import type { AuthNeededItem } from "../timeline/types.js"; /** What the conversation reads to decide whether this person can connect in the chat. */ export type InChatConnectSource = { getAccessContext: () => Promise; listCapabilities: (workspaceId: string) => Promise<{ items: CapabilityCatalogItem[]; memberIntegrationSetup?: MemberIntegrationSetup | undefined; }>; }; export type InChatConnectSupport = { status: "idle" | "loading"; } /** The grant or the catalog could not be read; `retry` reads them again. */ | { status: "failed"; retry: () => void; } | { status: "ready"; permissions: ReadonlySet; permissionMode?: "legacy" | "explicit" | undefined; catalog: ReadonlyMap; /** Who the organization lets turn integrations on (omitted: members). */ memberIntegrationSetup?: MemberIntegrationSetup | undefined; }; export type InChatConnectDecision = /** * The shared connect card: sign in, enable, add to this chat, continue. * `personalOnly`: the person can connect only their own account. */ { kind: "card"; item: CapabilityCatalogItem; personalOnly: boolean; } /** * A deployment's reviewed integration (Outlook Mail, OneDrive, ...): the * person signs in with their own account, which installs its reviewed tools * for that account alone, adds them to this chat and continues. */ | { kind: "integration"; capabilityId: string; name: string; } /** An agent's card this person cannot act on here. */ | { kind: "unavailable"; } /** Not an in-chat connection: the default recovery row decides. */ | { kind: "default"; }; /** Whether an auth notice is an agent's request to set up a capability in this chat. */ export declare function isAgentCapabilityRequest(item: AuthNeededItem): boolean; /** * Decide how a stock conversation shows an agent's capability card. The * shared card handles OAuth MCP capabilities; it is offered only when this * person's own grant can finish every step it takes and the session proxy * lets the browser set chat tools: add it to this chat (`sessions:control`), * and either use the workspace's shared account (`connections:read`) or * connect an account as personal integration setup allows (with only * `connections:personal`, their own account, enabling a reviewed OAuth * integration for personal accounts if it is not on yet). Anything else keeps * the default row. Host-managed connections (`authoritySource: "host"`) * never come here. The rule is `inChatCapabilitySetup`, which the agent's * setup tool also applies, so the agent's reply matches this card. */ export declare function inChatConnectDecision(item: AuthNeededItem, support: InChatConnectSupport, chatConnections: boolean): InChatConnectDecision; /** * Read the person's grant and the capability catalog once, and only when the * conversation shows an agent's capability card. */ export declare function useInChatConnectSupport(client: Partial, workspaceId: string, needed: boolean): InChatConnectSupport;