import type { OpenGeniClient, OpenGeniLinkTarget } from "@opengeni/sdk"; import { type ReactNode } from "react"; import { type OpenGeniText } from "../messages/runtime.js"; export type { OpenGeniLinkTarget }; /** * How the host opens one Opengeni object an agent linked in chat Markdown. * * - `{ href }` renders a real link (new tab) — use it for a host page URL. * - `{ open }` renders a button that runs the action (download, open a panel, * client-side navigation) with loading and retry states. * - `null` / `undefined` means "not handled here": the next resolver is asked, * and when none handles it the text renders as an unavailable reference — * never as a navigation that would 404 inside the host. */ export type OpenGeniLinkResolution = { href: string; open?: undefined; } | { open: () => void | Promise; href?: undefined; }; export type OpenGeniLinkResolver = (target: OpenGeniLinkTarget) => OpenGeniLinkResolution | null | undefined; /** * One ordinary link in an agent's Markdown that the host may draw itself: * its own scheme (`myapp:order/42`), an in-app path, or a web URL. */ export type OpenGeniHostLink = { /** The destination exactly as the agent wrote it. It is not sanitized: check it before use. */ href: string; /** The rendered link text. */ children: ReactNode; /** * The link is the only content of its paragraph or list item, so the host * can draw it as a block (a card or preview) instead of inline text. */ standalone: boolean; }; /** * Draw a host-owned link in agent Markdown. Return `undefined` to keep the * default rendering (web links open in a new tab; other schemes are shown as * unavailable). Opengeni object links (`artifact:`, `sandbox:`) never reach * it; use {@link OpenGeniLinkResolver} for those. */ export type OpenGeniLinkRenderer = (link: OpenGeniHostLink) => ReactNode | undefined; /** First renderer that draws a link wins. */ export declare function chainLinkRenderers(...renderers: ReadonlyArray): OpenGeniLinkRenderer | null; /** First resolver that handles a target wins. */ export declare function chainLinkResolvers(...resolvers: ReadonlyArray): OpenGeniLinkResolver | null; /** * Resolve Opengeni object links (`artifact:`, `sandbox:`, editable artifacts, * Sites) for every {@link Markdown} body below. An inner provider is asked * before an outer one, so a host can override a single kind and keep defaults. * `renderLink` draws the host's own links (its scheme, in-app paths, web * URLs) in the same bodies, inner provider first. */ export declare function OpenGeniLinkProvider({ resolveLink, renderLink, children, }: { resolveLink?: OpenGeniLinkResolver | null | undefined; renderLink?: OpenGeniLinkRenderer | null | undefined; children: ReactNode; }): import("react").JSX.Element; /** The effective resolver from the nearest {@link OpenGeniLinkProvider}. */ export declare function useOpenGeniLinkResolver(): OpenGeniLinkResolver | null; /** The effective host link renderer from the nearest {@link OpenGeniLinkProvider}. */ export declare function useOpenGeniLinkRenderer(): OpenGeniLinkRenderer | null; type SessionLinkClient = Partial>; /** * Default resolver for a session conversation that talks to Opengeni through * the normal SDK client (for example behind `createSessionProxyHandler`): * * - `artifact:` downloads the retained file through a short-lived URL. * - `sandbox:` downloads when enabled by the host proxy capability. * * Editable artifacts and Sites have no default: they need a host surface * (see `@opengeni/react/artifacts/*` and `@opengeni/react/sites`), so they stay * unavailable until the host resolves them. */ export declare function sessionLinkResolver(t: OpenGeniText, input: { client: SessionLinkClient; workspaceId: string; sessionId: string; sandboxFiles?: boolean; }): OpenGeniLinkResolver; /** An editable artifact or Site to open in a host-mounted viewer. */ export type OpenGeniViewerTarget = Readonly<{ kind: "editable-artifact" | "site"; artifactId: string; /** The link text the agent wrote, until the viewer loads the real title. */ title?: string | undefined; }>; /** * "Open in host viewer": resolve agent links to editable artifacts and Sites * in this workspace to `open(target)`, for example to mount * `SessionArtifactViewer` beside the conversation. Other targets fall through. */ export declare function viewerLinkResolver(input: { workspaceId: string; open: (target: OpenGeniViewerTarget) => void; }): OpenGeniLinkResolver;