@assistant-ui/react
Version:
Open-source TypeScript/React library for building production-grade AI chat experiences
95 lines • 4.28 kB
TypeScript
import { type FC } from "react";
import type { Unstable_DirectiveFormatter, Unstable_TriggerAdapter, Unstable_TriggerItem } from "@assistant-ui/core";
import type { ReadonlyJSONObject } from "assistant-stream/utils";
/**
* Icon component shape consumed by `ComposerTriggerPopover`'s `iconMap`.
*
* @deprecated Experimental since 2026-04-15. Not scheduled for removal; the API may change in any release.
*/
export type Unstable_IconComponent = FC<{
className?: string;
}>;
/** @deprecated Experimental since 2026-04-15. Not scheduled for removal; the API may change in any release. */
export type Unstable_Mention = {
readonly id: string;
readonly type: string;
readonly label: string;
readonly description?: string | undefined;
/** Shortcut for `metadata.icon`; merged with `metadata` if both are given. */
readonly icon?: string | undefined;
readonly metadata?: ReadonlyJSONObject | undefined;
};
/** @deprecated Experimental since 2026-03-16. Not scheduled for removal; the API may change in any release. */
export type Unstable_MentionCategory = {
readonly id: string;
readonly label: string;
readonly items: readonly Unstable_Mention[];
};
/** @deprecated Experimental since 2026-04-15. Not scheduled for removal; the API may change in any release. */
export type Unstable_ModelContextToolsOptions = {
/**
* Wrap tools in a dedicated category. Selects drill-down mode on its own
* when `categories` is unset and `items` is omitted.
*/
readonly category?: {
readonly id: string;
readonly label: string;
};
/** Format tool name for display. */
readonly formatLabel?: (toolName: string) => string;
/** Default icon key for each tool. */
readonly icon?: string;
};
/** @deprecated Experimental since 2026-04-15. Not scheduled for removal; the API may change in any release. */
export type Unstable_UseMentionAdapterOptions = {
/**
* Flat mention list. Ignored when `categories` is set, and keeps the
* adapter flat when a tool `category` is configured.
*/
readonly items?: readonly Unstable_Mention[];
/** Categorized mentions for drill-down navigation. */
readonly categories?: readonly Unstable_MentionCategory[];
/**
* How tools registered in model context integrate.
* - `false`: exclude.
* - `true`: include (default when no `items`/`categories`; as a category
* if `categories` is set, flat otherwise).
* - object: explicit config; `category` also selects drill-down mode.
*
* Omitted → defaults to `true` iff neither `items` nor `categories`.
*/
readonly includeModelContextTools?: boolean | Unstable_ModelContextToolsOptions;
/** Directive formatter. @default unstable_defaultDirectiveFormatter */
readonly formatter?: Unstable_DirectiveFormatter;
/** Fires after an item is inserted into the composer. */
readonly onInserted?: (item: Unstable_TriggerItem) => void;
/** Maps `metadata.icon` / `category.id` string keys to React components. */
readonly iconMap?: Record<string, Unstable_IconComponent>;
/** Fallback icon when no entry in `iconMap` matches. */
readonly fallbackIcon?: Unstable_IconComponent;
};
/** @deprecated Experimental since 2026-04-15. Not scheduled for removal; the API may change in any release. */
export type Unstable_MentionDirective = {
readonly formatter: Unstable_DirectiveFormatter;
readonly onInserted?: ((item: Unstable_TriggerItem) => void) | undefined;
};
/**
* Creates a spreadable `{ adapter, directive }` bundle for `@` mentions.
* Supports tools registered in model context, explicit items, or both —
* flat or categorized.
*
* @deprecated Experimental since 2026-04-15. Not scheduled for removal; the API may change in any release.
*
* @example
* ```tsx
* const mention = unstable_useMentionAdapter();
* <ComposerTriggerPopover char="@" {...mention} />
* ```
*/
export declare function unstable_useMentionAdapter(options?: Unstable_UseMentionAdapterOptions): {
adapter: Unstable_TriggerAdapter;
directive: Unstable_MentionDirective;
iconMap?: Record<string, Unstable_IconComponent>;
fallbackIcon?: Unstable_IconComponent;
};
//# sourceMappingURL=useMentionAdapter.d.ts.map