Registry for AI context providers.

The AIContextRegistry manages context providers that contribute information to the AI chat. Components register providers to share their state, and the AI chat gathers context from all providers when needed.

Example

Gathering context for an AI request

const registry = platform.get(PlatformServiceName.AIContextRegistry);
const contributions = registry.gatherContext();

See

Hierarchy

  • AIContextRegistry

Methods

  • Gather context from all registered providers.

    Calls getContext() on each provider and collects the results. Providers that return null (indicating no context available) and providers that throw errors are skipped (errors log a warning).

    Each contribution is enriched with the component's LimeWebComponentContext if the provider was registered with an element reference.

    Returns

    An array of enriched context contributions, one from each provider that returned a non-null contribution.

    Returns GatheredAIContext[]

  • Get all registered providers.

    Useful for debugging or introspection.

    Returns

    Array of all registered providers.

    Returns AIContextProvider[]

  • Register a context provider.

    The provider will be called when context is gathered via gatherContext(). Multiple providers with the same contextType can coexist - each registration gets a unique internal key.

    Returns

    A function to unregister the provider. Call this when the component is disconnected or the context is no longer relevant.

    Example

    const unregister = registry.register({
    contextType: 'deal-card',
    getContext: () => ({
    purpose: 'Shows full details of a deal record. ' +
    'Users can edit fields and manage related records.',
    data: {
    limetype: 'deal',
    id: this.dealId,
    descriptive: this.deal.descriptive
    }
    })
    }, this.host);

    // Later, when component is disconnected:
    unregister();

    Parameters

    • provider: AIContextProvider

      The provider to register.

    • Optional element: HTMLElement & LimeWebComponent

      Optional host element of the component registering this provider. When provided, enables the registry to:

      • Read the component's LimeWebComponentContext to enrich contributions
      • Skip providers whose elements are not currently connected to the DOM

    Returns (() => void)

      • (): void
      • Register a context provider.

        The provider will be called when context is gathered via gatherContext(). Multiple providers with the same contextType can coexist - each registration gets a unique internal key.

        Returns

        A function to unregister the provider. Call this when the component is disconnected or the context is no longer relevant.

        Example

        const unregister = registry.register({
        contextType: 'deal-card',
        getContext: () => ({
        purpose: 'Shows full details of a deal record. ' +
        'Users can edit fields and manage related records.',
        data: {
        limetype: 'deal',
        id: this.dealId,
        descriptive: this.deal.descriptive
        }
        })
        }, this.host);

        // Later, when component is disconnected:
        unregister();

        Returns void